caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* RE: [Caml-list] Stroustrup et al. propose to introduce "lambdaclosures" in C++
@ 2006-03-17 14:12 Alexander Bottema
  2006-03-17 17:32 ` skaller
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Bottema @ 2006-03-17 14:12 UTC (permalink / raw)
  To: Caml List

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-03-17 17:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-17 14:12 [Caml-list] Stroustrup et al. propose to introduce "lambdaclosures" in C++ Alexander Bottema
2006-03-17 17:32 ` skaller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).