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:

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:

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

Jan 20 2011