initialize slots without a modifier?
"Mike J. Bell" <[email protected]> Sat, 20 Oct 2007 19:00:22 -0400
| Newsgroups | gmane.comp.java.sisc.user |
|---|---|
| Message-ID | <[email protected]> |
I apologize if this hits the sisc-users list thrice; it hasn't shown up
(twice) for two days 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
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Sisc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sisc-users