[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: General Questions
- To: firstname.lastname@example.org
- Subject: Re: General Questions
- From: Bay.Chang@Eng.Sun.COM (Bay-Wei Chang)
- Date: Mon, 12 Oct 92 21:05:32 PDT
- Resent-date: Mon, 12 Oct 92 22:16:22 PDT
- Resent-from: Urs Hoelzle <urs@otis>
- Resent-message-id: <9210130516.AA01849@otis.Stanford.Edu>
- Resent-to: real-self-interest
> 1. Is there any way to type-check arguments passed to a method?
No, Self doesn't have any type-checking.
> (a) I have a vector
> class. I want to override the '*' operation so that I do something
> different when I get a vector or a float as an argument. In the first
> operation I am performing a dot product, and in the second one I am
> performing a vector-scalar multiplication.
One solution to this problem is multiple dispatch--instead of simply
dispatching on the receiver, the message send chooses the method to
execute based on the receiver and other arguments. Self (currently)
does not have multiple dispatch; we solve problems like the one above
using explicit double dispatching:
* a = ( a timesVector: self ).
timesVector: v = ( dotProduct: v ).
timesVector: v = ( scalarVectorMult: v ).
> (b) I may want to limit a
> specific class of objects from being able to receive a message, even
> though they understand it.
There isn't a way to achieve this in Self. ... And I'm not sure why
you would want to.
> 2. Are there any prospects in the future for producing more alternatives
> to slot accesibility? Maybe I want some slot to be visible to some
> objects, but not visible to others.
I'd like this too. "Cooperating abstractions" should have access to
slots within each other that other objects shouldn't. We've bandied
about all sorts of encapsulation schemes (some of which allow this
behavior), but none have risen to the top yet.
> 3. [...] How does Self deal with
> passing one (encapsulated) C++ object as an argument to another
> (encapsulated) C++ object's method?
Self's glue facility handles this fine. See, for example, the glued
in pixrect primitives.
> 4. Is there a way, once I have defined how my application is going to
> be, provide a snapshot of the world (together with compiled code) in
> such a way, so that once I run the snapshot a predetermined method is
> called at startup?
The virtual machine sends certain messages before and after reads and
writes of snapshots (e.g., after a read, it sends 'snapshotAction
postRead'). The object defined in snapshotAction.self allows responds
to these messages and executes a set of messages that you can add to.