Search found 226 matches

by edgar-rft
Fri Sep 04, 2015 8:26 am
Forum: Common Lisp
Topic: Is that an NREVERSE bug? (SBCL)
Replies: 7
Views: 9407

Re: Is that an NREVERSE bug? (SBCL)

The reason why destructive oprations can be dangerous is that if variables share list elements like in the following example: (defparameter x (list 0 1 2 3)) (defparameter y (cdr x)) x => (0 1 2 3) y => (1 2 3) The pointers of the CONS cells in memory look like this: Y -------------------, +-----+--...
by edgar-rft
Thu Sep 03, 2015 3:15 am
Forum: Common Lisp
Topic: Is that an NREVERSE bug? (SBCL)
Replies: 7
Views: 9407

Re: Is that an NREVERSE bug? (SBCL)

Finally found it - Citation from the CLISP implementation notes Section 17.3 - Functions NREVERSE and NRECONC : The result of NREVERSE [in CLISP] is always EQ to the argument ... NREVERSE on a LIST swaps the first and the last element and reverses the list chaining between them. This explains why in...
by edgar-rft
Thu Sep 03, 2015 2:48 am
Forum: Common Lisp
Topic: Is that an NREVERSE bug? (SBCL)
Replies: 7
Views: 9407

Re: Is that an NREVERSE bug? (SBCL)

The same explanation with some box-and-arrows artwork :P The original list: +-----+-----+ +-----+-----+ +-----+-----+ +-----+-----+ | | | | | | | | | | | | X --->| 0 | *------->| 1 | *------->| 2 | *------->| 3 | *------> NIL | | | | | | | | | | | | +-----+-----+ +-----+-----+ +-----+-----+ +-----+-...
by edgar-rft
Wed Sep 02, 2015 8:41 pm
Forum: Common Lisp
Topic: Is that an NREVERSE bug? (SBCL)
Replies: 7
Views: 9407

Re: Is that an NREVERSE bug? (SBCL)

It's only the return-value of NREVERSE that counts, the argument's value is allowed to be destructively modified into a complete mess: NREVERSE sequence => reversed-sequence For NREVERSE, [the original] sequence [argument] might be destroyed and re-used to produce the [ reversed-sequence ] result. ....
by edgar-rft
Fri Aug 28, 2015 1:38 pm
Forum: Common Lisp
Topic: long line output
Replies: 3
Views: 5710

Re: long line output

How things are printed on the screen is mostly implementation dependent,but here is what I do in such cases. The following function shows the values of all Common Lisp variables that have anything to do with printing: (defun printer-status () (format t ";; *print-array* = ~a~%" *print-array*) (forma...
by edgar-rft
Wed Aug 26, 2015 2:33 pm
Forum: Common Lisp
Topic: Incremental programming style
Replies: 2
Views: 4287

Re: Incremental programming style

The following is not intended to be an "Emacs with SLIME" commercial, but "If you are looking for a good Common Lisp IDE you have the choice between Emacs with SLIME, Emacs with SLIME, and Emacs with SLIME." I would like to give credits to the original author of this citation, but stupidly I have fo...
by edgar-rft
Tue Aug 25, 2015 9:54 pm
Forum: Common Lisp
Topic: Saving and loading objects that reference of objects?
Replies: 2
Views: 3950

Re: Saving and loading objects that reference of objects?

The standard way to save inter-dependency and values of all currently defined Lisp objects is dumping a Lisp image. The Lisp image can be loaded at any time later and still will contain all Lisp objects with their inter-dependency and values from the time when the image was dumped. Unfortunately Lis...
by edgar-rft
Fri Aug 21, 2015 7:13 pm
Forum: The Lounge
Topic: remote lisp - a server side lisp interpreter
Replies: 6
Views: 11913

Re: remote lisp - a server side lisp interpreter

Several hours later... It looks as if the interpreter can't handle quoted lists: (car (list 1 2 3)) => 1 ; works (car '(1 2 3)) => error: function 'CAR' expected (list) as arguments, but got ((1, 2, 3) (car (quote 1 2 3)) => error: Undefined symbol 'QUOTE' This is probably because the QUOTE operator...
by edgar-rft
Fri Aug 21, 2015 3:54 pm
Forum: The Lounge
Topic: remote lisp - a server side lisp interpreter
Replies: 6
Views: 11913

Re: remote lisp - a server side lisp interpreter

First of all: Thank you for sharing the link to this great Lisp interpreter! I had lots of fun during the last hour to type all kind of Lisp-nonsense into the input field and it survived all my attemts to crash the interpreter pretty well so far. :D I think ATOMs, CONS cells, LISTs, and math functio...
by edgar-rft
Fri Aug 21, 2015 2:06 pm
Forum: Common Lisp
Topic: Variable reference in structures
Replies: 18
Views: 27972

Re: Variable reference in structures

In Common Lisp, using multimethods is only one option of many. You do not need to use them if you don't want, but they can help in some situations. In contrast to most other programming languages, in Common Lisp there is no paradigm like "you must solve things in one specific way because there is no...