Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
RE: [Caml-list] Stroustrup et al. propose to introduce "lambdaclosures" in C++
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ 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.


-----Original Message-----
[] 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++


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

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.




Caml-list mailing list. Subscription management:
Beginner's list:
Bug reports: