User loginNavigation |
Do we need exactly two binding constructs?I'm recently thinking about the relation between objects and lexical environment. Objects, especially under a prototype-based object system, looks suspiciously similar to a lexical environment: slot-ref <-> environment-ref slot-set! <-> environment-set! add-slot! <-> environment-define parent(s)-of/delegate(s)-of <-> environment-parent(s) However, one problem remains in the way of unifying those 2 binding constructs completely: the slot-scoping problem. If I simply use symbols (like the case for environment) to designate slots, there's nothing to prevent two authors to come up with the same name (say 'x) and they can clash, especially in the presence of multiple delegation/inheritance. Therefore I figure I must use slot objects rather than symbols to designate slots: (within-environment user-1 (define x (make-slot))) (within-environment user-2 (define x (make-slot)) (make-object x 1 user-1:x 2)) and... now environments bind symbols to slot objects, and objects bind slot objects to values. This all looks fine, except that it makes me itch that I need to have two almost identical constructs, and I can't unify them into one! Are those two binding constructs exactly what we need, no more, no less? By Qiantan Hong at 2022-03-23 02:06 | LtU Forum | previous forum topic | next forum topic | other blogs | 3255 reads
|
Browse archives
Active forum topics |
Recent comments
17 weeks 8 hours ago
17 weeks 12 hours ago
17 weeks 12 hours ago
39 weeks 1 day ago
43 weeks 3 days ago
45 weeks 20 hours ago
45 weeks 20 hours ago
47 weeks 5 days ago
1 year 2 days ago
1 year 2 days ago