David Hakim
2003-05-06 22:27:53 UTC
re: Could we add an "initialised" field to the MotoVal struct, and set
it in motov_new?
Well, all variables in moto are given an initial value at declaration
time. For objects this default value is just null (for numerics and
other atomic types its 0).
Also, variables cannot be used without being declared. If a programmer
tries to use a variable without declaring it first motov will report an
error.
So moto really does not allow variable use prior to inilialization as
such.
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 ?
-Dave
it in motov_new?
Well, all variables in moto are given an initial value at declaration
time. For objects this default value is just null (for numerics and
other atomic types its 0).
Also, variables cannot be used without being declared. If a programmer
tries to use a variable without declaring it first motov will report an
error.
So moto really does not allow variable use prior to inilialization as
such.
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 ?
-Dave
Dave,
there is no method, as far as I see, to test in motov if an object has
been
initialised. So the only way I found, inside motox, to test for a
method call
/* If this is not an object... */
if (v1->type->kind != REF_TYPE) {
/* Nothing to do */
return FTAB_NONE;
}
/* Test for a null object */
if (mode == MODE_MOTOI || mode == MODE_MOTOC) {
if (v1->refval.value == NULL) {
THROW("NullPointerException",
"A method overloaded operator may not be identified on
null");
}
}
i.e throwing an exception in motoi and motoc.
Could we add an "initialised" field to the MotoVal struct, and set it
in
motov_new?
Stefano
there is no method, as far as I see, to test in motov if an object has
been
initialised. So the only way I found, inside motox, to test for a
method call
/* If this is not an object... */
if (v1->type->kind != REF_TYPE) {
/* Nothing to do */
return FTAB_NONE;
}
/* Test for a null object */
if (mode == MODE_MOTOI || mode == MODE_MOTOC) {
if (v1->refval.value == NULL) {
THROW("NullPointerException",
"A method overloaded operator may not be identified on
null");
}
}
i.e throwing an exception in motoi and motoc.
Could we add an "initialised" field to the MotoVal struct, and set it
in
motov_new?
Stefano