>From cltl2:
(setq x '(a b c))
(setq y '(d e f))
(nconc x y) => (a b c d e f)
x => (a b c d e f)
Is it correct ? Is literal constant '(a b c) modified by nconc ?
"Alexander" <········@gmail.com> writes:
> >From cltl2:
>
> (setq x '(a b c))
> (setq y '(d e f))
> (nconc x y) => (a b c d e f)
> x => (a b c d e f)
>
>
> Is it correct ? Is literal constant '(a b c) modified by nconc ?
This is the difference between an implementation that
obeys the standard, and a programmer who obeys it.
Alexander wrote:
>>From cltl2:
>
> (setq x '(a b c))
> (setq y '(d e f))
> (nconc x y) => (a b c d e f)
> x => (a b c d e f)
>
> Is it correct ? Is literal constant '(a b c) modified by nconc ?
CLtL2 is not a binding document. The binding document is the ANSI Common
Lisp specification. For example, the HyperSpec is derived from that
specification.
The example has been included in the ANSI CL spec, but:
- In 1.4.3 of the spec it is clearly stated that "subsections whose
names begin with the words ``Note'' or ``Notes'' or ``Example'' or
``Examples'' are provided for illustration purposes only, and are not
considered part of the standard."
- In 3.7.1 it is specified that side effects on literal objects have
undefined consequences.
The term "undefined consequences" means that a CL implementation is not
required to signal an error. In 1.4.2 it is stated that undefined
"consequences may range from harmless to fatal."
Apparently, the example was executed in a CL implementation that
"accidentally" yielded a (partially) correct result. (The source code
was probably not changed, therefore "partially".)
However, again in 1.4.2 it is stated that "no conforming code may depend
on the results or effects. Conforming code must treat the consequences
as unpredictable."
Pascal
--
OOPSLA'05 tutorial on generic functions & the CLOS Metaobject Protocol
++++ see http://p-cos.net/oopsla05-tutorial.html for more details ++++