Hi Iain! Indeed lets are amazingly powerful :) I think what you're looking for here is (apply varlet env args)
On Sun, Feb 7, 2021, 05:58 Iain Duncan <[email protected]> wrote: > Answering myself! Just didn't understand the docs properly, got it all > working nicely with varlet. > > Though I am curious to know whether my way of iterating through a keyword > assoc list in a constructor is reasonable. This is what I'm doing, feedback > most welcome: > > ; loop through the init-args keyword arg list, which is an assoc list > of sym/value to set > ; this allows setting any instance vars from keyword list to > constructor > (let* init-loop ((args init-args)) > (if (not (null? args)) > (begin > (varlet env (car args) (cadr args)) > (init-loop (cddr args))))) > > > > > On Sat, Feb 6, 2021 at 5:06 PM Iain Duncan <[email protected]> > wrote: > >> Hi folks, I've been digging into S7s environment support and loving it. I >> have implemented a really convenient pseudo-inheritance-through-delegation >> setup for my process objects, and one thing I'm using is the let-set! >> function to allow updating internal variables from outside if desired. My >> little method looks like this (in side of a let inside a function) >> >> (define (set sym val) >> ;; TODO this doesn't allow setting values that are not yet set >> ;; need to check if symbol is in let and then set it >> (let-set! proc-env sym val)) >> >> However, this of course errors if I try to use if and sym is not defined. >> I tried mucking about with the defined? predicate, but got confused by the >> docs. If anyone can tell me how I can easily add to the above the >> following, that would be lovely: >> >> - if sym not defined in proc-env, define sym to val >> >> iain >> >> _______________________________________________ > Cmdist mailing list > [email protected] > https://cm-mail.stanford.edu/mailman/listinfo/cmdist >
_______________________________________________ Cmdist mailing list [email protected] https://cm-mail.stanford.edu/mailman/listinfo/cmdist
