Boost logo

Boost Users :

From: Joel de Guzman (joel_at_[hidden])
Date: 2006-09-14 22:08:27


David Abrahams wrote:
> Jens Theisen <jth02_at_[hidden]> writes:
>
>> I'm not complaining that `factor' must have been default constructed.
>> I'm worrying about the return value, which is represented by the `val'
>> closure member. The point where we know what to return is where the
>> assignments are, but by design we must have some value earlier than
>> that.
>
> Ah, I understand.

I think Jens got it incorrectly. The var will *not* be created at
all on an unsuccessful match. No, the value is not created prior to
entering the rule. The value is created *lazily* after, and only
after, a successful match is made. That's the beauty of lazy evaluation.
Don't be misled by the syntax. On a no-match, the result is an
optional<T>(), like in your example. See match class in match.hpp and
notice the optional_type val; that's your attribute.

Regards,

-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net

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