Boost logo

Boost :

From: Joel de Guzman (joel_at_[hidden])
Date: 2005-02-02 11:08:27


christopher diggins wrote:
> ----- Original Message ----- From: "Joel de Guzman"
> <joel_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Wednesday, February 02, 2005 6:32 AM
> Subject: [boost] Re: Gauging Interest: New Functional Library and
> Programming Language
>
>
>> christopher diggins wrote:
>> Jeez, you and I should really talk. I have a project started
>> 2 years ago called "Rave" which is reminiscent of this.
>> Example:
>>
>> object factorial;
>> factorial =
>> if_(_1 == 0)
>> [
>> 1
>> ]
>> .else_
>> [
>> _1 * factorial(_1-1)
>> ];
>>
>> object is a dynamic type (ala scheme/lisp). The difference is that
>> I use a syntax closer to c++. I don't quite like lots of parens
>> and commas.
>
>
>
> Hi Joel,
>
> That is pretty neat. What status is Rave in?

Very early alpha prototype. Too much to do to little...
...you know...

>Is there any documentation
> or code examples I can look at?

None yet.

> In Rave, is evaluation lazy?

Yes.

Are there
> lambda expressions in Rave?

Definitely!

In Unimperative a function is unevaluated
> when not at the beginning of a list. For instance you can write:
>
> Function AddOrSub = (If, (Eq, _1, 0), Add, Sub);
> Function F1 = (Eval, (AddOrSub, 0), 4, 3);
> Function F2 = (Eval, (AddOrSub, 1), 4, 3);
> f1.Evaluate(empty); // evaluates to 7
> f1.Evaluate(empty); // evaluates to 1
>
> How would this be done in Rave?

Hmmm. lemme see...

object add_or_sub = if_(_1 == 0)[lambda[_1+_2]].else_[lambda[_1-_2]];
object f1 = add_or_sub(0)(4, 3);
object f2 = add_or_sub(1)(4, 3);
eval(f1); // evaluates to 7
eval(f2); // evaluates to 1

<<< Aside: I'm not quite fond of CamelCase :-) >>

If you've seen Phoenix2(http://tinyurl.com/6crgp), Rave is its
dynamically-typed counterpart. It's really the same thing. I intend
to use it to implement the new AST features of Spirit2 as well as
a generic embedded runtime interpreter, say, for parsing c++.

Cheers,

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

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk