Browse thread
RE: [Caml-list] Stroustrup et al. propose to introduce "lambdaclosures" in C++
- Alexander Bottema
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Alexander Bottema <Alexander.Bottema@m...> |
| Subject: | RE: [Caml-list] Stroustrup et al. propose to introduce "lambdaclosures" in C++ |
It is interesting to see that they are trying to implement closures in
C++, something I wanted for a long time. Unfortunately, I don't think it
is useful without having a proper garbage collector. If you read the
specification (5.2) you can see it is something they struggle with. I
think it is time that they added garbage collection to C++ as the
default memory allocation strategy like all other high-level languages.
If we could restrict the semantics of C++ on how we use pointers then we
might be able to implement an efficient generational garbage collector
(e.g. a three generation based collector as in Microsoft .NET). An
alternative would be to use a conservative collector (such as Boehm),
but then there are less chances to do garbage collection optimizations
at compile-time.
Alexander
-----Original Message-----
From: caml-list-bounces@yquem.inria.fr
[mailto:caml-list-bounces@yquem.inria.fr] On Behalf Of Eijiro Sumii
Sent: Friday, March 17, 2006 5:08 AM
To: Caml List
Cc: Eijiro Sumii
Subject: [Caml-list] Stroustrup et al. propose to introduce
"lambdaclosures" in C++
Hi,
A friend of mine informed me of this report
Lambda expressions and closures for C++
Jeremiah Willcock, Jaakko Jarvi, Doug Gregor, Bjarne Stroustrup,
Andrew Lumsdaine
2006-02-26
http://public.research.att.com/~bs/N1968-lambda-expressions.pdf
and I thought you might be interested. (I searched a little and
didn't find any discussion on this report in this list.)
A few highlights:
----------------------------------------------------------------------
We propose to extend the C++ language with lambda expressions, and
define the semantics of these unnamed local functions via translation
to closures: function objects implemented using local classes.
...
void f() {
int sum = 0;
for each(a.begin(), a.end(),
<>(int x) -> int extern(sum) {return sum += x;});
}
...
2.1 Omitting the return type
The return type of a lambda expression can be omitted if the body
of the lambda function contains at most one return statement.
----------------------------------------------------------------------
Enjoy:-),
Eijiro
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs