I’m reading through the code for punyinform’s cheap_scenery, and I’m puzzled by something:
Object CheapScenery "object"
with
article "an",
parse_name [ _ret;
cs_match_id = 0;
CSData-->CSDATA_MATCH_LENGTH = 0;
_ret = _ParseCheapScenery(location, cheap_scenery, wn);
if(CSDATA-->CSDATA_PRONOUN == CS_THEM) {
give self pluralname;
if(itobj == self) itobj = 0;
} else {
give self ~pluralname;
#ifdef PUNYINFORM_MAJOR_VERSION;
if(themobj == self) themobj = 0;
#Endif;
}
return _ret;
],
#Ifdef SceneryReply;
before [ * _i _k _w1pos _w1 _w2 _id_or_routine _self_bak;
#Ifnot;
before [_i _k _self_bak;
#Endif;
_i = CSData-->CSDATA_POINTER;
if(_i == 0) ! There is no match
print_ret (string) CS_DEFAULT_MSG;
_k = _i-->0;
if(_k > 0 && _k < 100)
_k = 1 + (_k / 10) + (_k % 10);
else
_k = 2;
_k = _i-->_k;
if(action == ##Examine && _k ofclass String)
print_ret (string) _k;
if(_k ofclass Routine) {
_self_bak = self;
self = location;
sw__var = action;
if(_k())
rtrue;
self = _self_bak;
}
#ifdef SceneryReply;
if(SceneryReply ofclass string)
print_ret (string) SceneryReply;
_w1 = _i-->_w1pos; ! XXX
_w2 = _i-->(_w1pos + 1); ! XXX
_id_or_routine = cs_match_id;
if(_w1 == CS_PARSE_NAME) {
if(_id_or_routine == 0)
_id_or_routine = _w2;
_w2 = 0;
} else if(_w1 > 0 && _w1 < 100) {
_k = _w1 / 10;
_w1 = 0;
if(_k) ! There is at least one adjective
_w1 = _w2;
_w2 = _i-->(_w1pos + 1 + _k);
}
if(SceneryReply(_w1, _w2, _id_or_routine))
rtrue;
#endif;
if(CS_DEFAULT_MSG ofclass Routine) {
CS_DEFAULT_MSG.Call();
rtrue;
}
print_ret (string) CS_DEFAULT_MSG;
],
react_after [ _i;
Go:
if(itobj == self) itobj = 0;
#ifdef PUNYINFORM_MAJOR_VERSION;
if(themobj == self) themobj = 0;
#Endif;
#Ifv5;
_i = 0; ! Get rid of warning
@copy_table CSData 0 10;
#Ifnot;
._BlankNext;
CSData-->_i = 0;
@inc_chk _i 4 ?~_BlankNext;
#Endif;
],
found_in [;
if(location provides cheap_scenery) rtrue;
],
has concealed scenery reactive
;
The routine uses the variable _w1pos (see XXX markers), but this is a local variable, not passed to the routine (puny reliably uses the leading underscore to document that, but even if the code is wrong, before isn’t passed things when the library calls it.
Am I misunderstanding something? Doesn’t t this always equal 0, as an uninitialized variable?