Interlisp / medley

The main repo for the Medley Interlisp project. Wiki, Issues are here. Other repositories include maiko (the VM implementation) and Interlisp.github.io (web site sources)
https://Interlisp.org
MIT License
369 stars 19 forks source link

Shouldn't happen error when calling PL with quoted symbol #1073

Open pamoroso opened 1 year ago

pamoroso commented 1 year ago

Describe the bug Calling PL with a quoted symbol as argument opens a break window with the error Help! Shouldn't happen:.

To Reproduce Steps to reproduce the behavior:

  1. sign into your Interlisp Online account
  2. under Initial Exec, select Interlisp
  3. click Run Medley
  4. at the Exec, evaluate PL 'SYM

Expected behavior No break window or error.

Screenshots The break window: PLbreak1

The full desktop: PLbreak2

Context (please complete the following information):

Additional context For PL 'SYM I'd expect a behavior similar to PL SYM, i.e. no error or break. Or at most a warning printed to the output stream.

masinter commented 1 year ago

There's a lot that is questionable about Medley Lisp's behavior here. But the behavior of PL isn't really defined for a non-symbol argument. This might be s critique of Interlisp's Exec, which has at least 4 different ways of entry that overlap:

  1. as an expression to eval of the form (fn arg1 arg2) which evals arg1 and arg2.
  2. in "evalqt" format, fn(arg1 arg2) where arg1 and arg2 are NOT evaled (or, put another way, implicitly quoted) so fn(a1 a2) == (fn 'a1 'a2) or more accurately (apply 'fn '(a b)).
  3. as a "command" of the form cmd a1 a2 ... an with no wrapping parens -- a command isn't a function and only works in the exec, it's case insensitive and package independent as well.
  4. as an Interlisp NLAMBDA function (when entered like evalqt case 2). This usage dates from before user-defined "commands" were added: NLAMBDA functions were used for "special forms" like COND and SETQ, for "shorthand" implementations like (FILESLOAD TEDIT SKETCH ) and for things that probably should have been done as commands: PP comes to mind.

This is mainly from memory and there are likely cases I've missed. There are some commands that are debugger-only (BT) and the history commands might have a different implementation.

Commands take precedence if you have a special variable with the same name as a command -- e.g., I had a variable named DIR which I had to enter as (PROGN DIR).

The NLAMBDA functions are symbols -- case and package sensitive, so to call 'PP' in a common lisp exec you need to type IL:PP. (continued)

masinter commented 1 year ago

(continued) The difference between X and (QUOTE X) -- which can be typed or printed as 'X -- is one of the most difficult for newcomers to Lisp to get. PL is a "command" and doesn't evaluate its arguments. PL 'X can also be typed as pl (QUOTE X) which isn't defined because the list (QUOTE X) doesn't have a property list.

pamoroso commented 1 year ago

What I find unusual about the reported behavior is the break window instead of an error or warning printed in the Exec.

rmkaplan commented 1 year ago

Generally, I think the code that runs a command should know that it is really an exec-typein, and therefore should never cause a break just because it can’t interpret its own arguments. Error or warning instead.

If something goes wrong in the code that it is actually trying to execute, then normal breaks should (not) appear, depending on depth, flags, whatever.

In this case, PL knows that it wants only an atom. If it gets something else (that it can’t obviously coerce, like stripping QUOTE), it should error/warn.

On Feb 7, 2023, at 6:15 AM, Paolo Amoroso @.***> wrote:

What I find unusual about the reported behavior is the break window instead of an error or warning printed in the Exec.

— Reply to this email directly, view it on GitHub https://github.com/Interlisp/medley/issues/1073#issuecomment-1420846343, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQSTUJOZ6KPVHOEDGCT7IHTWWJKJLANCNFSM6AAAAAAUSUJTTM. You are receiving this because you are subscribed to this thread.