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

Robert Forshaw iouswuoibev at hotmail.com
Tue Mar 23 18:56:58 CET 2004


>From: Erwin Harte <harte at is-here.com>
>Unfortunately that is not going to work right for typechecking mode 2,
>because the assingment of a non-int value to 'i' in the if-condition
>will cause a runtime error of "Value is not an int" or something along
>those lines

Well, that example was only to demonstrate why the casting method would be 
better. I meant to have put i as 'mixed' instead of 'int' there since mixed 
is the type that query_property returns, and where this idea would be most 
usefully applied (since it can hold both an integer, and 0).

>
>I'd go for something like this:
>
>     int nil_to_int(mixed v)
>     {
>	return v == nil ? 0 : v;
>     }
>
>     ...
>
>     luck -= nil_to_int(query_property("luck_reduction"));
>
>If you put the nil_to_int() in an inheritable it doesn't look so bad?

Yes, it would not look as bad. You have provided another solution that 
serves the necessary purpose, but more importantly, it still lacks the 
compactness and efficiency that my proposed idea would have, which is the 
reason for which I suggested it. I'm aware that the task can be done in LPC 
code, but I find that the casting method is brief and effective and would be 
a trivial effort to implent. I'd like to know if there are any significant 
fallacies behind my reasoning here.

_________________________________________________________________
Find a cheaper internet access deal - choose one to suit you. 
http://www.msn.co.uk/internetaccess

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



More information about the DGD mailing list