Sean O'Rourke wrote:

> On Mon, 16 Sep 2002, Leopold Toetsch wrote:
> 
> 
>>Sean O'Rourke wrote:


>>...it should inherit from some basic_scalar.pmc, that
>>implements this for scalars. default.pmc is no more this default scalar
>>type, it's a "invalid.pmc".
>>Aggregates and Sub's and so on, don't need this function.

> Then they shouldn't define _any_ of the add operations.  


.... and the default.pmc will catch any abuse of adding a "Sub" to an int 
and throw an exception.

> ... IMHO once a class
> says how it can be interpreted as e.g. a number, it's eminently reasonable
> to default the rest of its numeric operations, and to do widening
> conversions to take advantage of implemented ops.


Yes of course. What once was in "default.pmc" will be "scalar.pmc", 
where all scalar like classes can inherit from.


> I guess one way to measure which way makes more sense is to put in the new
> default.pmc, then see if there end up being any classes inheriting from it
> directly, or if everything goes through an intermediate conversion class.


As I already stated, we had til now _no_ inheritance from "default.pmc" 
except for the famous "Subscript on something that's not an aggregate".


>>Then they should implement an empty init() function (Currently we don't
>>have this case AFAIK).

> "Should not!" ;)


This is one additional line. Please compare this with 5KB lines I saved 
in array.pmc.


> I'll admit, it took me a little while to figure out why my sub's invoke()
> method wasn't getting called, when I added an extra space between the
> 'void' and the '*'.  invoke() is a poster-child of a method that should
> _not_ have a default -- what does it mean to "invoke" an integer?  


It should throw an exception, which "default.pmc" now does (and in case 
of invoke already had done)

> But I
> suspect that there are a lot of operations that can be defined in terms of
> others without causing any surprises.  The bignum value of something that
> knows how to become an int seems perfectly clear to me.


Yes, that's the planned inheritance from a scalar.pmc.

Summary:
default.pmc catches errors, and may provide e.g. ->name or ->type.
scalar.pmc will be the default scalar base class.


> /s

leo

Reply via email to