Re: Oddity when inheriting Gmp.mpz

"Per Hedbor () @ Pike (-) importm?te f?r mailinglistan" <[email protected]>
Newsgroups gmane.comp.lang.pike.user
Message-ID <[email protected]>
>That is sort of a good question. It did not really matter when it was
>not possible to inherit the class and get sensible functionality.

Now I remember. It is because the function was changed to not check
the number of arguments and their type.

Granted, it will only matter if you cann the function without
typechecking, since you will not be allowed to call it incorrectly
otherwise.

That is:

function f = cast;
f(); // <-- will access an invalid element on the stack.

The only effect will be that one element too much is popped (the rest
of the code is safe enough), but that might be inconvnient since the
topmost value on the stack will be incorrectly pop:ed and replaced
with a zero.

I added a number-of-argument check so it avoid pop:ing too much.

Since the assumed string in the svalue is not really accessed, only
compared against "int" "string" and "float" it is safe enough to avoid
checking the argument type, still.

-- 
Per Hedbor
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.