Git Product home page Git Product logo

alan-stdliblab's Introduction

☕ Espresso-Fuelled ☕ — 100% Italian Zest

I'm Tristano Ajmone from Italy, a programmer with special interest in software documentation, Interactive Fiction and computer graphics.

Proud member of the Alan IF Dev team, the Cosmigo org, and collaborator of the Highlight project.

I 💘 version-controlled collaborative documentation editing, and my favourite lightweight markup languages are AsciiDoc and PML.

alan-stdliblab's People

Contributors

tajmone avatar

Watchers

 avatar  avatar

alan-stdliblab's Issues

Optimize Verbs With Implicit Taking

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.