[DGD] Re: LPC repository

Felix A. Croes felix at dworkin.nl
Mon Dec 15 01:56:42 CET 1997


Azhrarn wrote:
>[...]
> > What about
> > 
> >     string s;
> > 
> >     s += "foo" + 0;
> > 
> > or even
> > 
> >     int n;
> > 
> >     n = 0;
> >     write("the value of n is " + n + ".\n");
> You are absolutely right, however I find the fix:
>     write("the value of n is " + (string)n + ".\n");
> much nicer than the two line fix of the mapping/array problem, and from a 
> language view even cleaner too.

What about "foo" + 5; did you go all the way and make the string cast
necessary for non-zero integer values, too?

What I dislike about the change is that 0 is at the same time an integer
value, and a neutral element for the other types.  Thus, intvar + ({ })
is legal when intvar has the value 0, but illegal when it has value 1.
This is especially obvious for floatvar + intvar, where there are numbers
on both sides, but again the expression leads to an error when the
integer is non-zero.

A change I would prefer (which would make the server incompatible with
LPmud 2.4.5, and thus was abandoned with regret) would be to initialize
variables to `null' rather than integer 0, `null' being a special value
that is equal to nothing but itself, and has typeof(null) == T_NONE.
Null can then be a safe neutral element for addition.

Regards,
Dworkin



More information about the DGD mailing list