tajmone / alan-stdliblab Goto Github PK
View Code? Open in Web Editor NEWExperimental fork of Alan Standard Library
License: Other
Experimental fork of Alan Standard Library
License: Other
See AnssiR66/AlanStdLib#32 for a description of this bug.
See AnssiR66/AlanStdLib#42 for a description of this bug.
Remove useless IF clause to check that implicit-take went well in various verbs, for it's not needed.
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 VERB
s 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.
Take the .editorconfig
file from the ALAN Repository Template and add it to the project root folder.
This will add application agnostic setting for Alan related files (*.alan
, *.i
, *.a3sol
, *.a3log
) via EditorConfig, ensuring consistent code styling across different editors and IDEs, and improve Alan sources visualization on GitHub.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.