Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dubious Code in 'take.i' #20

Open
tajmone opened this issue Jul 28, 2021 · 1 comment
Open

Dubious Code in 'take.i' #20

tajmone opened this issue Jul 28, 2021 · 1 comment
Labels
💀 invalid This doesn't seem right ⭐ library Topic: ALAN Library 👅 EN English language

Comments

@tajmone
Copy link
Contributor

tajmone commented Jul 28, 2021

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."
@tajmone tajmone added 💀 invalid This doesn't seem right 👅 EN English language ⭐ library Topic: ALAN Library labels Jul 28, 2021
@thoni56
Copy link
Contributor

thoni56 commented Jul 28, 2021

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...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💀 invalid This doesn't seem right ⭐ library Topic: ALAN Library 👅 EN English language
Projects
None yet
Development

No branches or pull requests

2 participants