|
Boost : |
From: Joel de Guzman (joel_at_[hidden])
Date: 2005-02-02 06:32:34
christopher diggins wrote:
> I have just completed a prototype for a functional programming language
> called Unimperative, which is also valid C++. This language is
> implemented in C++ by overloading the comma operator and use of the
> boost::any library.
>
> The language syntax is similar to Scheme but with the significant
> difference that a Function is called as (MyFxn, x, y). For instance
> where in Scheme you might write a factorial function as:
>
> (define factorial
> (lambda (n)
> (if (zero? n)
> 1
> (* n (fact (- n 1))))))
>
> In Unimperative you could write it as:
>
> Function Factorial =
> (If,
> (Eq, _1, 0),
> 1,
> (Mult, _1, (Eval, self, (Dec, _1))));
>
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.
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