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 | 3273 reads
|
Browse archives
Active forum topics |
Recent comments
20 weeks 1 day ago
20 weeks 1 day ago
20 weeks 1 day ago
42 weeks 2 days ago
46 weeks 4 days ago
48 weeks 1 day ago
48 weeks 1 day ago
50 weeks 6 days ago
1 year 3 weeks ago
1 year 3 weeks ago