Menu

#262 [a,b,c][0] => "["

closed
nobody
Lisp Core (457)
5
2006-07-04
2003-03-18
No

[a,b,c][0] => "[" --- should be an error

foo:[a,b,c]$ foo[0] => "[" --- same

The subscript operator should select the nth element of
a list-like object. It should NOT select the nth
component of a structure -- that is what part/inpart is for.

After all, (a+b)[0] is not "+". Similarly, [a,b][0] should
not be "[", but an error.

Currently, meval uses inpart for subscripting; this code
needs to be corrected.

5.9.0, GCL, Windows

Discussion

  • Robert Dodier

    Robert Dodier - 2006-07-04

    Logged In: YES
    user_id=501686

    Following patch committed as r1.27 src/mlisp.lisp. This is
    in MAPPLY1. Now [a,b,c][0] => error message. Closing this
    report as fixed.

    diff -u -r1.26 mlisp.lisp
    --- mlisp.lisp 15 Feb 2006 16:44:29 -0000 1.26
    +++ mlisp.lisp 4 Jul 2006 16:56:29 -0000
    @@ -155,6 +155,8 @@
    (if (not (or (= (length args) 1)
    (and (eq (caar fn) '$matrix) (= (length
    args) 2))))
    (merror "Wrong number of indices:~%~M" (cons
    '(mlist) args)))
    + (if (memq 0 args)
    + (merror "No such ~M element: ~M~%" (if (eq (caar fn)
    'mlist) "list" "matrix") `((mlist) ,@args)))
    (do ((args1 args (cdr args1)))
    ((null args1) (let (($piece $piece) ($partswitch
    'mapply))
    (apply #'$inpart (cons fn args))))

     
  • Robert Dodier

    Robert Dodier - 2006-07-04
    • status: open --> closed
    • labels: --> Lisp Core
    • summary: [a,b,c][0] => "[" --> [a,b,c][0] => "["
     

Log in to post a comment.