[Sisc-users] initialize slots without a modifier?
Brought to you by:
mradestock,
scgmille
From: Mike J. B. <ck...@gm...> - 2007-10-20 04:33:41
|
I apologize if this hits the sisc-users list twice; it hasn't shown up for about 7 hours so I'm retrying... In the SSS manual chapter 7, there are examples of making slots with accessors and modifiers: (define-generics :x :y :y!) (define-class (<foo>)) (define-class (<bar>)) (define-class (<baz> <foo> <bar>) (x :x) (y :y :y!)) Then later, the procedure for initialization ("constructor") is explained: (define-generics :x :x!) (define-class (<baz>) (x :x :x!)) (define-method (initialize (<baz> b) (<number> x)) (:x! b x)) (define baz (make <baz> 2)) (:x baz) ;=> 2 So what I don't understand is how you would ever modify your slots in initialize if you didn't create a modifier? Like, in the first example, x only has an accessor. How do I set it? Is it constant, or unbound? I would imagine that the slot descriptor in the define-class specifies what slots an object has and then their visibility; i.e. in the following (define-generics :y :z :z!) (define-class (<foobar>) (x) (y :y) (z :z :z!)) x is for internal use only, y can be accessed but not modified, z is read-write (in general, for clients). Am I off-base here? What's the right way to think about this and what am I missing? Thanks! P.S. It might be nice to update the documentation with more real-world examples, i.e. instead of <foo> and <bar> make like a simple <queue> or <stack> class that people can relate to better. Oh, and the section in Chapter 8 about s2j interaction, where there's a table of "how to do __X__ in Java in SISC" is great...this might not be a bad idea for the oo chapter too, even though I'm sure SISC's oo system is a heckuva lot more powerful than Java's. Just a thought. -- Mike J. Bell on gmail |