Boost logo

Boost Users :

From: Dale Peakall (dale.peakall_at_[hidden])
Date: 2002-08-21 10:23:47


On Wednesday 21 August 2002 3:48 pm, you wrote:
> > See http://www.boost.org/status/cs-win32.html
> >
> > Lambda does not and will not compile on MSVC until MSVC 7.1 is released
>
> (I'm
>
> > told that it does work in this environment).
> >
> > - Dale.
>
> wow, thanks for the quick reply!
>
> ah ok, guess I'll have to wait for their update.
> by the way, I read most of the lambda lib doc, but I was wondering if it
> works just like a lambda expression in other languages like lisp... fairly
> simple use: I have a Dialog class with a close() method and a Button class
> with a on_click event (which I guess would be the lambda function), and I'd
> like my button object to close the dialog.. so that I'd have..
>
> class mydialog : public virtual Dialog
> {
> public: Dialog() { mybutton.on_click = lambda({this->close();}); }
> ....
> protected:
> Button mybutton;
> };
>
> so I guess that lambda(...) part would actually be: bind(this,
> Dialog::close) ?

Nearly, try boost::bind(&mydialog::close, this).

Boost.Bind does work with current versions of MSVC.

> I guess my real question is, does the LL support closures in the sense that
> I can use all bound variables at the time of the lambda definition and
> create an in-place function, or is that too much to ask of c++? I'm trying
> to emulate something like internal variable this from a PLT Scheme dialog
> class:
>
> (define edit-btn (make-object button% ; class
> "Edit Painting" ; label
> this ; parent
> (lambda (obj event) ; on-click proc
> (send controller edit-view))))

I'll let someone else answer that as I'm not sure what your asking. My
functional programming lingua is poor, and I haven't read/written any Scheme
for ~10 years.

        - Dale.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net