[DGD] Bad argument 2 - should be 1?

Petter Nyström md1pette at mdstud.chalmers.se
Mon Jul 18 19:41:01 CEST 2005


I understand that there is a reason, but it is not clear if you say that 
this reason apply only for typechecking below 2? I do run the driver with 
typechecking 2, which you probably catched up from the fact that I used 
nil in my example?

Petter

On Mon, 18 Jul 2005, Felix A. Croes wrote:

> =?ISO-8859-1?Q?Petter_Nystr=F6m?= <md1pette at mdstud.chalmers.se> wrote:
>
>> Running this code:
>>
>>      string *a;
>>      a = nil; /* For emphasis. */
>>      a = a + ({"b"});
>>
>> Results in an error "Bad argument 2 for kfun +", shouldn't this be "Bad
>> argument 1 for kfun +"? Not so big a thing, but it had me confused for a
>> while as I searched for a bug in the wrong place.
>
> This is a side effect of using a typechecking mode below 2, where nil is
> equal to the integer value 0.  Obviously, 0 is a proper first argument
> for addition.
>
> Provided that there is still some degree of typechecking enabled, you
> could make the case that the interpreter knows at this point that the
> first argument should be of type string*, and that a 0/nil value is
> invalid.  But accepting this has historically been the case for LPC,
> and I consider any global typechecking mode below 2 as backward
> compatible.
>
> Regards,
> Dworkin
> __________________________________________
> http://mail.dworkin.nl/mailman/listinfo/dgd
>



More information about the DGD mailing list