[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LISP - [SPECS ERR] - Backquote - please confirm. - [#V0.3]



I've found a simple bug in the ANSI Common Lisp specification.

At least i think so.

I've published this in comp.lang.lisp, and asked for validation.

The bug is very simple.

But i got no responses that leads to a confirmation.

I had this again. When i was claiming that:

----------------------------------------------------------------
() can be changed to [] with 2 lines of ANSI Common Lisp Code

An ANSI Conforming Common Lisp implementation *must* execute:

(set-syntax-from-char #\] #\) )  ; => T
(set-syntax-from-char #\[ #\( )  ; => T
[+ 3 2]                          ; => 5

http://groups.google.com/groups?selm=alot2c$pkv$1@usenet.otenet.gr

(LispWorks *does*, Franz Allegro *does not*, Corman Lisp *does not*, 
other versions: don't know, i got no feedback !
----------------------------------------------------------------

But this case is much simpler.

Interested in "The 'Savages' of C.L.L." ?

Interested in LISP?

Interested in Software Engeneering?

Here's a showcase.

The Medium 'Public Newsgroups'.

Used for quick 'Language Evolution'.

==============================================================

--------------------------------------------------------------------

NESTED BACKQUOTE

--------------------------------------------------------------------

The [online-version of the] standard-document states:

http://www.lispworks.com/reference/HyperSpec/Body/02_df.htm

"[...] If the backquote syntax is nested, the innermost backquoted form 
should be expanded first. This means that if several commas occur in a 
row, the leftmost one belongs to the innermost backquote.[...]"

=> "the *innermost* backquoted form *should be* expanded first"

This definition is wrong.

------------------------------------------------------------------------
Testing with implementations:

Allegro:
(setq d 1  c 'd  b 'c  a 'b )
`(,a `(,b ,,c))               ; => (B (EXCL::BQ-LIST B D))
              ;;; which is same as: (B `(,B ,D))

LispWorks:

`(,a `(,b ,,c))               ; => (B (SYSTEM::BQ-LIST B D))
              ;;; which is same as: (B `(,B ,D))


We see in the processing of both implementations:

- The *outermost* backquoted form is expanded first
=> direct contradiction to the specification

- The *innermost* backquoted form is processed *partially* by the 
outermost backquote to evaluate the ,,c => ,D.

This confirms: The definition of nested backquote is wrong.

------------------------------------------------------------------------
one could say now:

The specification is correct. The implementors are wrong.

--------------------------------------------------------------------
The 'natural' flow of things will help out.

Naturally (as given by reading in the stream) the outermost backquote is 
expanded first.

The Lisp-Reader cannot preview more than *one* char. Thus it is 
impossible to detect the existence of the innermost quote to avoid 
evaluation of the outermost backquote.

--------------------------------------------------------------------

(setq d 1  c 'd  b 'c  a 'b )

`(,a `(,b ,,c))               ; => (b `(c ,d))
      |_|__||
|_|________|

the only  , prior to a will be processed from the outermost `
the only  , prior to b will be processed from the innermost `
the left  , prior to c will be processed from the innermost `
the right , prior to c will be processed from the outermost `

--------------------------------------------------------------------
The author meant probably this:

If the backquote syntax is nested, the innermost backquoted form should 
be *served*[not expanded] first [with a comma]. This means that if 
several commas occur in a row, the leftmost one belongs to the innermost 
backquote [and so on].

in any case:

http://www.lispworks.com/reference/HyperSpec/Body/02_df.htm

"[...] If the backquote syntax is nested, the innermost backquoted form 
should be expanded first.[...]"

is wrong.

--------------------------------------------------------------------
'Looking around'

i follow an suggested link in the specs:

http://www.lispworks.com/reference/HyperSpec/Body/02_dfa.htm

"[...] Implementors who have no particular reason to make one choice or 
another might wish to refer to IEEE Standard for the Scheme Programming 
Language,[...]"

http://www.cs.indiana.edu/scheme-repository/doc.standards.html

nothing found there,

but i reached finally this point:

http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-7.html#%_sec_4.2.6
"[...]
Quasiquote forms may be nested. Substitutions are made only for unquoted 
components appearing at the same nesting level as the outermost 
backquote. The nesting level increases by one inside each successive 
quasiquotation, and decreases by one inside each unquotation.

`(a `(b ,(+ 1 2) ,(foo ,(+ 1 3) d) e) f)
                 ===>  (a `(b ,(+ 1 2) ,(foo 4 d) e) f)
(let ((name1 'x)
       (name2 'y))
   `(a `(b ,,name1 ,',name2 d) e))
                 ===>  (a `(b ,x ,'y d) e)
[...]
"

Which confirms what already is obvious:

The ANSI Common Lisp specification about nested Backquote is wrong.

My main interest now is:

I've lost *many* time due to this wrong specification, which ruins my 
understanding process for days.

I've invested *many* time to find out whats happened and to write 
everything down, so other newcomers to lisp (i'm a lisp-novice) don't 
run into the same problem.

Now look at the behaviour of comp.lang.lisp.

And explain me please:

- Is this a common behaviour of Lisp people?

- Or is this only the behaviour of the few people online in cll?

- are other languages-lovers like this people? i mean, declaring the 
specs as a religion which has no errors? Believe - don't doubt.

Are this people not able to say:
- Yes, it's maybe an bug.
- Yes, it's an bug.
- Ok, we've a bug in the specs, so what?
- Ok, we've a bug in the specs, lets look what to do.

Simply to raise the image and the quality of comp.lang.lisp. And of 
Common Lisp.

I've a strange feeling, that the nature of Common Lisp is like the 
nature oth the people in c.l.l.

Talking, talking, talking.

And silence, when it is time to talk.

-

I'm a lisp-novice.

Be happy.