euslisp / EusLisp

EusLisp is an integrated programming system for the research on intelligent robots based on Common Lisp and Object-Oriented programming. [Manual](http://euslisp.github.io/EusLisp/manual.html ) [マニュアル](http://euslisp.github.io/EusLisp/jmanual.html )
Other
57 stars 50 forks source link

`reverse (cons 1 2) ` returns `(1)` #257

Open knorth55 opened 6 years ago

knorth55 commented 6 years ago
32.E3-irteusgl$ (reverse (cons 1 2))
(1)

SBCL returns type error for argument.

$ sbcl
This is SBCL 1.1.14.debian, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* (reverse (cons 1 2))

debugger invoked on a TYPE-ERROR in thread
#<THREAD "main thread" RUNNING {1002A8AF33}>:
  The value 2 is not of type LIST.

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

(SB-IMPL::LIST-REVERSE* #<unavailable argument>)
0]    
Affonso-Gui commented 6 years ago

clisp also returns error:

> (reverse (cons 1 2))

*** - REVERSE: A proper list must not end with 2
YoheiKakiuchi commented 6 years ago

We can check common lisp standard at http://www.lispworks.com/documentation/HyperSpec/Front/

'reverse' is described at http://www.lispworks.com/documentation/HyperSpec/Body/f_revers.htm type-error if sequence is not a proper sequence.

So, SBCL and clisp keep common-lisp standard, but euslisp doesn't.

knorth55 commented 6 years ago

so you mean we need to set our standard?

YoheiKakiuchi commented 6 years ago

We have to be careful for changing behavior of existing software. Even if it seems right and easy to fix it. We have to evaluate profit and bad effect from fixing it.

In this case, I think we can fix it. some existing programs may change behavior, but not so many.

euslisp manual P.35 reverse sequence / reverse the order of sequence and returns a new sequence of the same type as sequence. ( Not described about improper sequence )

Affonso-Gui commented 6 years ago

EDIT Sorry, was completely unrelated. Posted on #258.

knorth55 commented 6 years ago

I think we have two options.

  1. follow common lisp, so return improper sequence error. I prefer this because most of documents on the internet is about common lisp. It is easier for us to follow common lisp.
  2. return something. I think (reverse (cons 1 2)) => (cons 2 1)can be useful. Actually, I expected to get the value as above.