[CM] something like let-set! for undefined vars?
iainduncanlists at gmail.com
Sat Feb 6 20:57:55 PST 2021
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
; 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))
(varlet env (car args) (cadr args))
(init-loop (cddr args)))))
On Sat, Feb 6, 2021 at 5:06 PM Iain Duncan <iainduncanlists at gmail.com>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Cmdist