[Grace-core] On numbers and objects

Andrew P. Black black at cs.pdx.edu
Mon Nov 8 13:34:33 PST 2010


On 8 Nov 2010, at 13:17, James Noble wrote:

> The hard part is what about constructors for *user-defined value types*.
> Do they always run? Or run most of the time?  Or run, but then the object may be deleted
> and replaced with an indistinguishable clone?

I'm still trying to figure out what this means.

> Actually, I quite like the last option: this should work, I think, if we continue to forbid
> the use of "self" within constructors.


Maybe this is the question:  Suppose I write an object constructor that creates an object (called maybe) whose type conforms to that of Boolean.   Can I use mabe in an if?

The pragmatic answer is "no".  This is a blemish on the language, because our story is that '''if''' is just a message on an object, and anything that quacks like a duck is a duck.   The Self answer is "of course yes", and we would end up standing on our hands trying to implement it efficiently, just like the Self team did.   

In Emerald we just said that a few basic types can't be reimplemented by user-defined types.  I think that Boolean should be one of those.  I think that String should NOT be one of those.    If we had Nat32 built-in, then it should not be re-implementable either, but since we have Rational, which will be slow anyway, allowing re-implementation should be OK.

	Andrew


More information about the Grace-core mailing list