[chuck-users] Guile C++ wrap
haberg-1 at telia.com
Mon Mar 22 05:31:36 EDT 2010
I started to write a bit on a Guile C++ wrap*), and it strike me it
may give some inputs on the discussion on giving ChucK functional
First, Guile has a conservative GC (meaning that it just tries to
collect some pointers, not necessarily all). It makes C++
implementation very simple: you don't have to write operator=() and
copy constructors, because normally, when an object is mutated, it is
being done using *this = f(*this) where f is a function of the
functional language (so normal object referencing just needs to hand
over the pointer). But the question is if such a GC can be made
without causing timing problems.
Then I use templates to do some Haskell style static typing, though C+
+ is a bit too limited. But it is fully possible see what kind of
syntax might be possible. For example, one can define an increment
function1<integer, integer> inc = x >>= x + 1
(though I must use a more complicated syntax in the actual code due C+
+ and Guile limitations). Here, ">>=" is the lambda, and in math it is
the symbol ↦, in ASCII looking like |->.
The Haskell-like define-function-by-cases syntax would be something
function1<integer, integer> inc;
inc(x) = x + 1;
though it is hard to get it to instantiate properly using C++
templates. But if built into a ChucK parser, that should be no problem.
But it seems that the current ChucK syntax might be enhanced with
functional language features.
More information about the chuck-users