[chuck-users] Guile C++ wrap
nando at ccrma.Stanford.EDU
Tue Mar 30 18:55:44 EDT 2010
On Mon, 2010-03-22 at 14:30 +0100, Hans Aberg wrote:
> On 22 Mar 2010, at 14:01, Kassen wrote:
> > Isn't Guile a Scheme dialect/implementation?
> Yes, it is a C-library version. It turns out that it has the lambda
> symbol available in a header <eval.h>. So it is possible to use it to
> build lambda expressions form scratch, which is otherwise not possible
> in Scheme.
Another option which might be interesting is s7 (by Bill Schottstaedt),
"It exists as just two files, s7.c and s7.h, that want only to disappear
into someone else's source tree"
More details in the "manual" link in that page.
> There are some problems here: a compiled lambda expression becomes
> proceudre, which cannot be treated as an expression anymore. For
> example if I define
> expression e1 = y >> x + y;
> and compiles it into a procedure f, then if I write
> expression e2 = x >> f;
> and then compile it into g, the symbol "x" in f will be unbound and
> always produce an unbound variable error.
> > I'm starting to really like some of Scheme's tricks.
> So it is good for playing around with too see what might be required,
> but is not suitable as a library.
> > I thought about writing some utility functions for ChucK inspired by
> > it, like the anonymous -in line- "if". I really like that one. Sadly
> > that won't currently fly in any sensible way due to the type-system,
> > while we could actually make sure during parsing/compilation that
> > this particular "if" will return values of the appropriate type and
> > wouldn't need to wait for runtime muck-ups.
> > Mind you, I'm not sure this sort of stunt would be a good idea at
> > all, but I could see how it would at least be possible.
> Yes, that is not only possible but important to have. I have started
> to work with the "case" function; its symbol is also in the <eval.h>
> If one uses a Haskell style definition with conditions
> function1<integer, integer> f;
> f(x) | x < 0 = -1;
> f(x) | x == 0 = 0;
> f(x) | x > 0 = 1;
> then that is in Haskell translated into
> f = x >>= case x of
> (x < 0) -> -1
> (x == 0) -> 0
> (x > 0) -> 1
> In other words, by making those conditional formulas available as
> objects, one can reduce such function definitions to just the lambda.
> > We should be careful about chucking out the baby because we want to
> > add new bathwater.
> So that is not necessary.
More information about the chuck-users