From: The Glauber
Subject: CLISP: possible problem with vector syntax
Date: 
Message-ID: <8rsiqo$u7d$1@nnrp1.deja.com>
I came across an interesting error with CLISP 2000-03-06, running under
Windows 98.

I have a function that has a vector represented like this:
    #(8 7 6 5 4 3 2 10 9 8 7 6 5 4 3 2)
(i'm new to Lisp, but i think this is a valid vector, right?)

When i run the function in interpreted mode, it works fine. If i try
compiling the function with (compile 'vin-check-checkdigit)

i get this error:

    ERROR in function VIN-CHECK-CHECKDIGIT :
    Invalid form: #(8 7 6 5 4 3 2 10 9 8 7 6 5 4 3 2)
    NIL ;


If i use the syntax
    (vector 8 7 6 5 4 3 2 10 9 8 7 6 5 4 3 2)

it works fine, both interpreted and compiled. It looks like the compiler is
not understanding the #( ) syntax for vectors.


Just thought i should report this.

glauber

--
Glauber Ribeiro
··········@my-deja.com    http://www.myvehiclehistoryreport.com
"Opinions stated are my own and not representative of Experian"


Sent via Deja.com http://www.deja.com/
Before you buy.

From: Rainer Joswig
Subject: Re: CLISP: possible problem with vector syntax
Date: 
Message-ID: <joswig-26461A.16164809102000@news.is-europe.net>
In article <············@nnrp1.deja.com>, The Glauber 
<··········@my-deja.com> wrote:

> I came across an interesting error with CLISP 2000-03-06, running under
> Windows 98.
> 
> I have a function that has a vector represented like this:
>     #(8 7 6 5 4 3 2 10 9 8 7 6 5 4 3 2)
> (i'm new to Lisp, but i think this is a valid vector, right?)
> 
> When i run the function in interpreted mode, it works fine. If i try
> compiling the function with (compile 'vin-check-checkdigit)
> 
> i get this error:
> 
>     ERROR in function VIN-CHECK-CHECKDIGIT :
>     Invalid form: #(8 7 6 5 4 3 2 10 9 8 7 6 5 4 3 2)
>     NIL ;
> 
> 
> If i use the syntax
>     (vector 8 7 6 5 4 3 2 10 9 8 7 6 5 4 3 2)
> 
> it works fine, both interpreted and compiled. It looks like the compiler is
> not understanding the #( ) syntax for vectors.

I guess it does. Try putting a QUOTE in front of the vector.
Like this:
 
 (subseq '#(8 7 6 5 4 3 2 10 9 8 7 6 5 4 3 2) 4 7)

CLISP has something like an ANSI CL compatible mode.
Are you using it? IIRC, it is a switch when you start up CLISP.
It should be mentioned somewhere in the docs.
Start CLISP in ANSI CL compatible mode and try
your examples again.

-- 
Rainer Joswig, Hamburg, Germany
Email: ·············@corporate-world.lisp.de
Web: http://corporate-world.lisp.de/
From: The Glauber
Subject: Re: CLISP: possible problem with vector syntax
Date: 
Message-ID: <8rsm2a$13m$1@nnrp1.deja.com>
In article <····························@news.is-europe.net>,
  Rainer Joswig <······@corporate-world.lisp.de> wrote:
> In article <············@nnrp1.deja.com>, The Glauber
> <··········@my-deja.com> wrote:
[...]

>> It looks like the compiler is
> > not understanding the #( ) syntax for vectors.
>
> I guess it does. Try putting a QUOTE in front of the vector.
> Like this:
>
>  (subseq '#(8 7 6 5 4 3 2 10 9 8 7 6 5 4 3 2) 4 7)
>
> CLISP has something like an ANSI CL compatible mode.
> Are you using it? IIRC, it is a switch when you start up CLISP.
> It should be mentioned somewhere in the docs.
> Start CLISP in ANSI CL compatible mode and try
> your examples again.


You're right. If i run CLISP with the -a (i.e.: maximum ansi) parameter, the
#( vector ) syntax works in interpreted and compiled mode. Interesting. I
guess i should use it this way, then, if i expect it to conform to the CL
spec.

Why's that? Is the '#( vector ) -- with quote -- syntax an older syntax
that's been superseded by #( vector ) -- without quote?

(BTW, if you try this and you can't (exit) from CLISP anymore, try
(lisp:exit) instead.)


glauber
--
Glauber Ribeiro
··········@my-deja.com    http://www.myvehiclehistoryreport.com
"Opinions stated are my own and not representative of Experian"


Sent via Deja.com http://www.deja.com/
Before you buy.
From: Tim Bradshaw
Subject: Re: CLISP: possible problem with vector syntax
Date: 
Message-ID: <ey3r95prcur.fsf@cley.com>
* The Glauber wrote:
> You're right. If i run CLISP with the -a (i.e.: maximum ansi) parameter, the
> #( vector ) syntax works in interpreted and compiled mode. Interesting. I
> guess i should use it this way, then, if i expect it to conform to the CL
> spec.

Before ANSI there was some confusion about which forms were
self-evaluating.  I think this got sorted out before CLISP -- perhaps
it's putting it in for historical correctness?

--tim
From: Barry Margolin
Subject: Re: CLISP: possible problem with vector syntax
Date: 
Message-ID: <LbqE5.34$bg1.698@burlma1-snr2>
In article <···············@cley.com>, Tim Bradshaw  <···@cley.com> wrote:
>* The Glauber wrote:
>> You're right. If i run CLISP with the -a (i.e.: maximum ansi) parameter, the
>> #( vector ) syntax works in interpreted and compiled mode. Interesting. I
>> guess i should use it this way, then, if i expect it to conform to the CL
>> spec.
>
>Before ANSI there was some confusion about which forms were
>self-evaluating.  I think this got sorted out before CLISP -- perhaps
>it's putting it in for historical correctness?

There was no confusion.  CLTL explicitly said:

    Any Common Lisp data object not explicitly defined here to be a valid
    form is not a valid form.  It is an error to evaluate anything but a
    valid form.

This is followed by an implementation note encouraging implementors to
signal an error if you try to evaluate an invalid form.  So CLISP in its
pre-ANSI mode is correct to report an error.

X3J13 reversed this, saying that all standard types other than symbols and
lists are self-evaluating.  The original idea was to leave the door open
for experimentation with other evaluation schemes (perhaps CLOS objects
could implement an EVAL-OBJECT generic function to evaluate themselves),
but nothing like that happened (probably because interfacing with the
compiler would be difficult), and several implementors had made arrays and
defstruct objects self-evaluating as an extension.

-- 
Barry Margolin, ······@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Tim Bradshaw
Subject: Re: CLISP: possible problem with vector syntax
Date: 
Message-ID: <ey3lmvwqzs0.fsf@cley.com>
* Barry Margolin wrote:

> There was no confusion.  CLTL explicitly said:

>     Any Common Lisp data object not explicitly defined here to be a valid
>     form is not a valid form.  It is an error to evaluate anything but a
>     valid form.

I stand corrected.  I was working from my memory that various
implementations did have variances in how they dealt with this, and
I'd obviously forged a memory that cltl said `is undefined' rather
than `is an error'.  My only excuse is that I'm on the wrong end of a
9600 baud mobile phone connection at the moment & can't look stuff
up...

--tim
From: Rainer Joswig
Subject: Re: CLISP: possible problem with vector syntax
Date: 
Message-ID: <joswig-3B2C07.17103909102000@news.is-europe.net>
In article <············@nnrp1.deja.com>, The Glauber 
<··········@my-deja.com> wrote:

> You're right. If i run CLISP with the -a (i.e.: maximum ansi) parameter, the
> #( vector ) syntax works in interpreted and compiled mode. Interesting. I
> guess i should use it this way, then, if i expect it to conform to the CL
> spec.
> 
> Why's that? Is the '#( vector ) -- with quote -- syntax an older syntax
> that's been superseded by #( vector ) -- without quote?

Well, it has nothing to do with the syntax. Both the
compiler and the interpreter usually see preparsed Lisp
code.

Try:

(read-from-string "(subseq #(8 7 6 5 4 3 2 10 9 8 7 6 5 4 3 2) 4 7)")

And inspect the result. You will see that the reader returns
a list and one element of the list is the vector.
So this isn't a problem of the syntax.

The question is: is a certain data object (number,
string, symbol, cons cell, vector, ...) self evaluating?

In ANSI CL vectors evaluate to themselves. This is obviously
not the case in a pre ANSI CL mode of CLISP.

Rainer Joswig

-- 
Rainer Joswig, Hamburg, Germany
Email: ·············@corporate-world.lisp.de
Web: http://corporate-world.lisp.de/