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
language capabilities.
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
function using
function1
On 22 March 2010 10:31, Hans Aberg
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 language capabilities.
Isn't Guile a Scheme dialect/implementation? I'm starting to really like some of Scheme's tricks. 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. We should be careful about chucking out the baby because we want to add new bathwater. Yours, Kas.
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
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
We should be careful about chucking out the baby because we want to add new bathwater.
So that is not necessary. Hans
One of the main things that I like about Scheme is the REPL. It struck me that the original plan for chuck --shell isn't completely unlike a REPL in how interaction might work for performance or rapid prototyping. We have some framework for that, in that our parser, compiler and VM all live in the same memory space so if we would want to update some function foo() the system should be able to find what bytecode was generated from the original foo() and replace that with the new one. Sadly that idea hasn't received much attention in recent days, but in the Bad Old Days it was treated as rather central to ChucK. Personally I'm more interested in the method of interaction than in the exact language used for it; I'd rather look into that stuff than into a more functional (in the CS sense of the word) syntax as such. Kas.
On 22 Mar 2010, at 15:07, Kassen wrote:
One of the main things that I like about Scheme is the REPL.
It struck me that the original plan for chuck --shell isn't completely unlike a REPL in how interaction might work for performance or rapid prototyping. We have some framework for that, in that our parser, compiler and VM all live in the same memory space so if we would want to update some function foo() the system should be able to find what bytecode was generated from the original foo() and replace that with the new one.
Sadly that idea hasn't received much attention in recent days, but in the Bad Old Days it was treated as rather central to ChucK.
Personally I'm more interested in the method of interaction than in the exact language used for it; I'd rather look into that stuff than into a more functional (in the CS sense of the word) syntax as such.
The way Guile works, being a library, is that there are functions for
interpreting code. So I implemented those functions into some class
objects, so that one can write:
function1
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
. 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), available here: https://ccrma.stanford.edu/software/snd/ "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. -- Fernando
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
header: If one uses a Haskell style definition with conditions function1
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.
Hans
On Tue, Mar 30, 2010 at 11:55 PM, Fernando Lopez-Lezcano
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
. 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), available here:
https://ccrma.stanford.edu/software/snd/
"It exists as just two files, s7.c and s7.h, that want only to disappear into someone else's source tree"
You might be aware that there is actually a real-time audio programming environment built on top of SND that is similar in a way to ChucK and has a hard real-time garbage collector. DSP algorithms written in Scheme (or perhaps a DSL based on Scheme) are dynamically compiled to C, then to native code by gcc, and then dynamically loaded and executed. I've played with it a little and it is very cool. http://archive.notam02.no/arkiv/doc/snd-rt/ It takes a bit of set-up and is intended to be used with Emacs. Steve
On 31 Mar 2010, at 00:55, Fernando Lopez-Lezcano 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
. 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), available here:
https://ccrma.stanford.edu/software/snd/
"It exists as just two files, s7.c and s7.h, that want only to disappear into someone else's source tree"
Scheme itself does no admit using the lambda and other hard-wired symbols as first-class objects. Guile just happens to supply them as a library. So if s7 doesn't do that, one cannot do the same external- building of expressions. Hans
On Wed, 2010-03-31 at 20:25 +0200, Hans Aberg wrote:
On 31 Mar 2010, at 00:55, Fernando Lopez-Lezcano 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
. 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), available here:
https://ccrma.stanford.edu/software/snd/
"It exists as just two files, s7.c and s7.h, that want only to disappear into someone else's source tree"
Scheme itself does no admit using the lambda and other hard-wired symbols as first-class objects. Guile just happens to supply them as a library. So if s7 doesn't do that, one cannot do the same external- building of expressions.
Sorry, I have not clear idea (I think it is possible), Bill should be able to answer that (cc'ed). -- Fernando
Hello A very very simple question and I'm going to completely show myself up here..... What language is ChucK based on? It looks similar to Common Music which is based on Scheme I think? I'm just wondering so I can try understand things better/quicker. Thanks James
James;
A very very simple question and I'm going to completely show myself up here..... What language is ChucK based on? It looks similar to Common Music which is based on Scheme I think? I'm just wondering so I can try understand things better/quicker.
Mostly Java, with the addition of our massively overloaded "=>" operator, which is mostly (rather tasty) syntactic sugar, and our method for timing and concurrency. Of course modern musical languages will be influenced by the old ones, like Common Music and CSound and you may see traces of that influence but it's really very much unlike something like Scheme. If you keep Java in mind you will mostly be fine. If you keep Scheme in mind and try to write in that style you may get interesting results but after a while I predict brick-walls and disappointments. Hope that helps. Kas.
OK thanks Kas. Cheers James On 22 Mar 2010, at 14:19, Kassen wrote:
James;
A very very simple question and I'm going to completely show myself up here..... What language is ChucK based on? It looks similar to Common Music which is based on Scheme I think? I'm just wondering so I can try understand things better/quicker.
Mostly Java, with the addition of our massively overloaded "=>" operator, which is mostly (rather tasty) syntactic sugar, and our method for timing and concurrency.
Of course modern musical languages will be influenced by the old ones, like Common Music and CSound and you may see traces of that influence but it's really very much unlike something like Scheme. If you keep Java in mind you will mostly be fine. If you keep Scheme in mind and try to write in that style you may get interesting results but after a while I predict brick-walls and disappointments.
Hope that helps. Kas. _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (5)
-
Fernando Lopez-Lezcano
-
Hans Aberg
-
James Mcwilliam
-
Kassen
-
Stephen Sinclair