[DGD] Re: casting nil (another idea...)
Steve Wooster
swooster at xprt.net
Tue Mar 23 21:44:43 CET 2004
>I think !!nil illustrates this best. : )
>
>And just to further my point on equivelance, (string)1 evaluates to "1".
>In other words, "1" is the string equivilent of 1 (but is not equal to 1).
>I think logically, it follows that 0 is the integer equivilent of nil,
>perhaps not to the same precision but it makes sense to me. I think to
>rationally determine the merit of including such a feature as typecasting
>nil to 0, you have to weigh the problems it would introduce. Since casting
>(int) on a nil currently does nothing, and because nil and 0 have logical
>equvilence, I don't see it introducing any problems at all.
This is a good point, but there's another way of thinking of nil that
suggests that it shouldn't be castable. In C, when you declare/allocate a
new variable, it initially contains random "garbage"; you don't want to do
anything with what's in the variable initially. If you think of nil as
representing the value of an unset variable, it makes sense that you
wouldn't be able to cast it, since it doesn't make sense to cast garbage.
Of course, if this is true, it doesn't make sense to be able to do 'if
(var)' or 'if (!var)' without runtiming when var == nil. ...so maybe this
wasn't a good point.
In any case, I admittedly agree with you that it would be nice to be able
to explicitly cast nil to an int. Heh, I'm still miffed that "test"[2..6]
runtimes instead of returning "st". What I wouldn't give for a config
option to change that... Ah well, Dworkin has given us the sun and the
moon, so there's no reason to ask for the stars too.
-Steve Wooster
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list