You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Remove useless IF clause to check that implicit-take went well in various verbs, for it's not needed.
Find all verbs that have implicit-take and an IF clause to check that it succeeded.
Remove the IF clause surrounding the code to be executed after the implicit take.
Find if other verbs have similar redundant IF clauses, in contexts other than implicit taking.
Rationale
Various verbs that carry out implicit-taking use an IF clause to check that the implicit take succeeded. E.g. from lib_classes.i, verb give on liquid:
VERB give -- LIQUID
WHEN obj
DOES ONLY
-- >>> implicit take >>>
IF THIS NOT IN hero
THEN
IF vessel OF THIS = null_vessel OR vessel OF THIS IS NOT takeable
THEN "You can't carry" SAY THE THIS. "around in your bare hands."
ELSE LOCATE vessel OF THIS IN hero.
"(taking" SAY THE vessel OF THIS. "of" SAY THIS. "first)$n"
END IF.
END IF.
-- <<< implicit take <<<
IF THIS IN hero
-- i.e. if the implicit taking was successful
THEN
"You give" SAY THE vessel OF THIS. "of" SAY THIS. "to" SAY THE recipient. "."
LOCATE vessel OF THIS IN recipient.
END IF.
The problem here is that there's no need to carry out that check, for if the LOCATE statement in the implicit-take action were to fail for any reason (e.g. the object is held by an actor) then the rest of the verb execution would be aborted, so there's no risk (nor chance) that the rest of the DOES body is executed anyhow — therefore the whole IF clause surrounding the final part of the verb is unneeded.
Unfortunately, this aspect of Alan VERBs is not covered clearly in the Alan Manual, but here is a proof of this:
--==============================================================================
-- "Test Verb Execution Abortion" by Tristano Ajmone
--==============================================================================
THE room IsA LOCATION
END THE room.
THE box IsA object AT room.
CONTAINER
EXTRACT CHECK
"You can't take things from Bruno's box, he'd be mad at you!"
END THE box.
THE ball IsA object IN box.
END THE ball.
SYNTAX take = take (obj)
WHERE obj IsA object
ELSE "You can only take objects."
ADD TO EVERY object
VERB take
DOES
locate obj in Hero.
"You take $+1." --> If the previous line fails this is not executed!
END VERB take.
END ADD TO object.
Start at room.
The text was updated successfully, but these errors were encountered:
Remove useless IF clause to check that implicit-take went well in various verbs, for it's not needed.
Rationale
Various verbs that carry out implicit-taking use an IF clause to check that the implicit take succeeded. E.g. from
lib_classes.i
, verbgive
onliquid
:The problem here is that there's no need to carry out that check, for if the
LOCATE
statement in the implicit-take action were to fail for any reason (e.g. the object is held by an actor) then the rest of the verb execution would be aborted, so there's no risk (nor chance) that the rest of theDOES
body is executed anyhow — therefore the wholeIF
clause surrounding the final part of the verb is unneeded.Unfortunately, this aspect of Alan
VERB
s is not covered clearly in the Alan Manual, but here is a proof of this:The text was updated successfully, but these errors were encountered: