www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Stack-allocared linear closures in ATS

The ATS language contains a metric ton of nice ideas. ATS programs are
sometimes faster than C ones (because its type system allows to avoid some
runtime tests done in C programs, allows some higher order optimizations, etc)
despite the programmer has ways to write them in much safer way than C ones.
ATS faces this mix of so strong design requirements with a very complex type
system that's hard to use. So it's not a normal language, you need to think of
it as something else, more like a theorem proving language like Agda that also
produces very efficient binaries.

This is a little example of a safer usage of a C library from ATS:
http://www.bluishcoder.co.nz/2010/06/02/safer-c-code-using-ats.html

Recently I have found that ATS has two main kinds of closures, normal
heap-allocated ones managed by the GC (as D2 ones), and linear closures that
require manual freeing of their memory. Linear closure may also allocated on
the stack, avoiding the need of the free, and making them quite efficient:
http://www.bluishcoder.co.nz/2010/06/20/closures-in-ats.html
http://www.bluishcoder.co.nz/2010/08/02/lin-and-llam-with-closures.html

Being D2 a language that looks for performance too, the idea of stack closures
may be of interest.

Bye,
bearophile
Jan 20 2011