cadr
2018-3-13 16:41:07

@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!


mflatt
2018-3-13 16:44:26
#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)

mflatt
2018-3-13 16:44:43

Instantiating the linklet changes x but leaves y alone


cadr
2018-3-13 16:56:26

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!


cadr
2018-3-13 16:58:46

@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?


mflatt
2018-3-13 16:59:18

Right