[DGD] casting nil (another idea...)

Robert Forshaw iouswuoibev at hotmail.com
Tue Mar 23 18:27:30 CET 2004


>From: "Colin Ross" <c.ross at cantab.net>
>You could make the query_property() function do the work for you and
>return a 0 for non-existent properties.  That's what I tend to do
>in these cases where a default of 0 makes sense.

But in my case, nil means a distinctly different thing to 0 when querying a 
property; nil indicates that the property has not been set, whereas 0 means 
the property holds the value 0. In that case I put forward it just happens 
not to matter if the value is nil or 0, if it is nil the function wants to 
assume 0. Besides, just because I could tailor a solution for any particular 
problem, doesn't negate that it would be more convenient and efficient to 
have nil castable to an integer. As I demonstrated in my initial post, there 
is an alternative solution in LPC, and as I pointed out, the casting method 
is a lot tidier (the other method takes an additional 3 lines of code).

_________________________________________________________________
Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo

_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list