[CM] sprouts & closure in CM

taube@uiuc.edu taube@uiuc.edu
Fri, 10 Jun 2005 16:21:07 -0500


You could chain processes using the 'finally' clause:

(define (foo reps lev)
  (process repeat reps
           output <whatever>
           wait <whenever>
           finally 
           (if (> lev 0) 
               (sprout (foo reps (- lev 1)) 
                       (now)))))

(events (foo 20 3) "foo.bar")

i should probably (re)implement a container like the old Thread class that would
process each subcontainer and generates all items before moving on to the next
subcontainer. the problem is that there is no 'rhythm slot for relative time
values and I havent quite figured out how to fold this into object-time
(absolute) time values. any ideas welcome!


---- Original message ----
>Date: Fri, 10 Jun 2005 14:58:36 -0400
>From: Drew Krause <drkrause@mindspring.com>  
>Subject: [CM] sprouts & closure in CM  
>To: CMDIST <cmdist@ccrma.Stanford.EDU>
>
>I'd like to do something fairly simple in CM: define a function that 
>would place sections end-to-end, starting one section when the previous 
>section ends. I can do this by setting a global variable:
>
>(setf glob-ending '())
>
>Then defining the 'collecting' program ...
>
>(define sections (&rest sprts)
>    (process (for sprt in sprts
>    sprout (eval sprt)
>    wait glob-ending)))
>
>... and adding the following line to each 'sprouted' section I'm using, 
>so it's passed back to "sections":
>
>finally (setf glob-ending (now))
>
>This is not the most desirable method for obvious reasons -- 
>specifically, I'd like this section-length variable to be closed inside 
>"sections". Any solutions/other approaches out there? Thanks!
>
>_______________________________________________
>Cmdist mailing list
>Cmdist@ccrma.stanford.edu
>http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist