#421 substpart changes its argument in cmucl maxima

closed
nobody
None
5
2004-11-23
2003-10-10
Anonymous
No

Paolo Nason, INFN, sez. di Milano
Universita' di Milano-Bicocca,
Dip. di Fisica "G. Occhialini",
Piazza della Scienza, 3
20126 Milano
Paolo.Nason@mib.infn.it

In cmucl maxima substpart has side effects:

(C26) lll:[1,2,3];
(D26) [1,2,3]

(C27) substpart(5,lll,2);
(D27) [1,5,3]

(C28) lll;
(D28) [1,5,3]

lll has been modified.

In gcl maxima:

(C1) lll:[1,2,3];
(D1) [1, 2, 3]

(C2) substpart(5,lll,2);
(D2) [1, 5, 3]

(C3) lll;
(D3) [1, 2, 3]
lll remains the same, as it should.

Discussion

  • Wolfgang Jenkner

    Logged In: YES
    user_id=581700

    Thanks for the bug report.

    The problem seems to be that MPART (in comm.lisp) contains the form

    (SETQ EXP (copy-all-levels EXP))

    and COPY-ALL-LEVELS is defined (in maxmac.lisp) as

    (DEFMACRO COPY-ALL-LEVELS (LIST)
    #+(or cl NIL) `(COPY-TREE ,LIST)
    #-(or lispm NIL) `(SUBST NIL NIL ,LIST))

    So the form above does the same thing as

    (setq exp (subst nil nil exp)). Now the CLHS says

    If no changes are made [by SUBST or friends], the original tree
    may be returned.

    This explains why GCL behaves in a different way from CMUCL (SBCL and
    CLISP behave like CMUCL).

    Since COPY-ALL-LEVELS occurs only twice in the whole of Maxima and we
    support only ANSI CL anyway, I think that we don't need such an
    abstraction and we could just replace it by COPY-TREE. Objections?

     
  • Wolfgang Jenkner

    Logged In: YES
    user_id=581700

    Patch committed.

     
  • Raymond Toy

    Raymond Toy - 2004-11-23
    • status: open --> closed
     
  • Raymond Toy

    Raymond Toy - 2004-11-23

    Logged In: YES
    user_id=28849

    This doesn't happen in CVS.

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks