@mflatt The docs says in instantiation the target’s existing variables remain intact if they are not modified by a linklet definition, can you give an example of a linklet definition that modifies a target’s variable? Thanks!
#lang racket/base
(require '#%linklet)
(define l (compile-linklet '(linklet () (x) (define-values (x) 1))))
(define i (make-instance #f #f #f 'x -1 'y 2))
(instantiate-linklet l null i)
(instance-variable-value i 'x)
(instance-variable-value i 'y)
Instantiating the linklet changes x
but leaves y
alone
Ah I see, so the linklet’s variables are always going to overwrite target’s variables with the same name, unless it’s uninitialized. I seem to have misunderstood this : “When target is provided any existing variable with the same name will be left as-is, instead of set to undefined”, now it make sense, thanks!
@mflatt It shouldn’t make it any different if we defined i as (define i (instantiate-linklet (compile-linklet '(linklet () () (define-values (x) -1) (define-values (y) 2))) null))
instead of using make-instance right?
Right