
John Lato wrote:
So here's a very simple expression:
t1 = let v = sigGen (cnst 1) in outs v v
which is what led to my question. I'm binding the sigGen to 'v' to introduce sharing at the meta-level. Would it be better to introduce support for this in the dsl?
Often this is not a question of preference but that of necessity. Sharing at the meta-level may help the generator, but it does _not_ translate into the sharing at the object level. In the generated code, the code for 'sigGen (cnst 1)' shall be duplicated. It could be that two csound blocks must share the same signal source, to receive samples in parallel. Meta-level sharing (Haskell's let) would not do. We need a construct for an object-level let, for example t1 = let_ (SigGen (cnst 1)) (\v -> outs v v) (Template Haskell can improve the syntax.) The term `off-shoring' was coined by Walid Taha and collaborators, and first appeared in the paper Implicitly Heterogeneous Multi-Stage Programming. GPCE'05 (whose first draft was written in Feb 2004).