alan-if / alan-i18n

ALAN Internationalization Project
Other
0 stars 1 forks source link

Dubious Code in 'take.i' #20

Open tajmone opened 3 years ago

tajmone commented 3 years ago

Module take.i contains a dubious piece of code, which we might want to fix, also in out ports to Swedish and Italian:

Syntax
  take_from = 'take' (obj) 'from' (holder)
    Where [...]

Add to every object
  Verb take_from
    When obj
      Check obj not in hero  -- <1>
        else "You already have" say the obj. "."
      And obj in holder      -- <2>
        else Say the obj. "is not there."
      Does
        If holder=hero then  -- <3>
          "You don't need to take things from yourself!"
        else
          Locate obj in hero.
          "You take" say the obj. "."
        End if.
  End verb.
End add.

How can the following code ever execute:

      Does
        If holder=hero then  -- <3>
          "You don't need to take things from yourself!"

if checks <1> and <2> passed? i.e.:

  1. The obj is not in Hero.
  2. The obj is in holder.

The hero can't possibly be the holder of obj at point <3>!

Or am I missing out something here (because it's late night and I'm half asleep)?

From my experience with libraries, it makes more sense to put absurd/nonsensical command on top of the CHECKs lists, so I'd change that to:

    When obj
      Check holder <> hero
       esle "You don't need to take things from yourself!"
      And obj not in hero
        else "You already have" say the obj. "."
      And obj in holder
        else Say the obj. "is not there."
thoni56 commented 3 years ago

Your experience is probably a good teacher ;-)

After a brief glance it does look suspicious, and should probably be fixed as you suggest.

(One must remember that the 0.6 library was never really finished and amended over the years as Alan and our learnings grew. There are probably many such places...)