Re: Test for an initialised object
Stefano Corsi <[email protected]> Wed, 7 May 2003 00:34:02 +0000
| Newsgroups | gmane.comp.lang.moto.devel |
|---|---|
| Organization | Moto Project |
| Message-ID | <[email protected]> |
>
> Did you want to add this field so motov could report a warning to
> programmers that they 'might' be using a variable that they did not yet
> assign a value to ?
>
Yes, the problem is that if you try to lookup the correct method operator=
=20
(like +=3D -- ++ *=3D and so on) in motox_try_overload_..., and the under=
lying=20
object is not initialized, you get a Null Pointer exception.=20
ex:
${
use "codex.util";
// SymbolTable i =3D new SymbolTable();
SymbolTable i;
i["dasd"] =3D "pippo";
=20
}$
Uncaught NullPointerException
message:A method overloaded operator may not be identified on null
NullPointerException thrown in <main>(motox.c:228)
The same happens if you call a method on a non initialized object...=20
Wouldn't be possible (and maybe cleaner) to warn the user that he's using=
a=20
non-initialized object?
Stefano