From: ArcLucifer
Subject: Newbie problem- Setf command
Date: 
Message-ID: <20020613102411.10298.00000005@mb-cd.aol.com>
I'm trying to learn LISP at the moment with Colin Allen and Maneesh Dhagat's
LISP Primer. I'm getting the hang of it except I'm having problems with the
Setf command. The lesson on Setf starts by making a list called words:
(setq words (a list of words))

that's fine, then I'm supposed to use the Setf command to change the first word
to "the" with the following code:
(setf (first words) 'the)

However, when I try this I get the error:
error: bad place form

I'm using the XLisp-Plus compiler which says that it is fully compatable with
Common LISP but I can't work out what is wrong with this. If insted of "first"
I use "car":
(setf (car words) 'the)

then it works. Also, the "first" command works if I try to call up the first
word of a list:
e.g. (first words)

However, it won't work with the setf command.

Could someone please explain what I should do, I've tried reading the FAQs and
Help files but I don't seem to be find the solution. 

Does anyone know what the problem is and how I should solve it? Should I get a
new compiler or something else?

Thanks in advance

-Jacob

(··········@aol.com)

From: Donald Fisk
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <3D08222A.6420CAD7@enterprise.net>
ArcLucifer wrote:
> 
> I'm trying to learn LISP at the moment with Colin Allen and Maneesh Dhagat's
> LISP Primer. I'm getting the hang of it except I'm having problems with the
> Setf command. The lesson on Setf starts by making a list called words:
> (setq words (a list of words))
> 
> that's fine,

You missed out a quote, but I assume that's a typo.

> then I'm supposed to use the Setf command to change the first word
> to "the" with the following code:
> (setf (first words) 'the)
> 
> However, when I try this I get the error:
> error: bad place form
> 
> I'm using the XLisp-Plus compiler which says that it is fully compatable with
> Common LISP but I can't work out what is wrong with this. If insted of "first"
> I use "car":
> (setf (car words) 'the)

Strange, because running XLispStat (which is an extension of
XLisp-Plus), I get

Command: xlispstat
XLISP-PLUS version 3.04
Portions Copyright (c) 1988, by David Betz.
Modified by Thomas Almy and others.
XLISP-STAT Release 3.52.18 (Beta).
Copyright (c) 1989-1999, by Luke Tierney.
 
> (setf x '(a b c))
(A B C)
> (setf (first x) 'd)
D
> x
(D B C)

No error when I run it.   Are you using an old version of xlisp-plus?

Le Hibou
-- 
Dalinian: Lisp. Java. Which one sounds sexier?
RevAaron: Definitely Lisp. Lisp conjures up images of hippy coders,
drugs,
sex, and rock & roll. Late nights at Berkeley, coding in Lisp fueled by
LSD.
Java evokes a vision of a stereotypical nerd, with no life or social
skills.
From: ArcLucifer
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <20020620111719.06289.00001571@mb-mc.aol.com>
Thanks guys for repling, I've had a bad week which is why I didn't get back
sooner.

I can't find that article, I don't think its on the database any more of the
Sunday Times Website.

It was written by Danny O Brian who runs a newsletter called Need to Know
(http://www.ntk.com). I think the point he was making was that programmers
don't require languages to be perfect (which he said LISP was an example of)
but just be 80% perfect (like C, C++ etc. etc.)

I'll have a look at all your coding suggestions when I can use my real computer
again.

Thanks

-Jacob
From: Joel Ray Holveck
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <y7cr8ishx45.fsf@sindri.juniper.net>
> It was written by Danny O Brian who runs a newsletter called Need to Know
> (http://www.ntk.com). I think the point he was making was that programmers
> don't require languages to be perfect (which he said LISP was an example of)
> but just be 80% perfect (like C, C++ etc. etc.)

This is related to the point made by another paper by Peter Gabriel:
"Lisp: Good News, Bad News, How to Win Big"...
  http://www.ai.mit.edu/docs/articles/good-news/good-news.html

Cheers,
joelh
From: Joe Marshall
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <qERS8.211107$6m5.174183@rwcrnsc51.ops.asp.att.net>
"Joel Ray Holveck" <·····@juniper.net> wrote in message ····················@sindri.juniper.net...
> > It was written by Danny O Brian who runs a newsletter called Need to Know
> > (http://www.ntk.com). I think the point he was making was that programmers
> > don't require languages to be perfect (which he said LISP was an example of)
> > but just be 80% perfect (like C, C++ etc. etc.)
>
> This is related to the point made by another paper by Peter Gabriel:
> "Lisp: Good News, Bad News, How to Win Big"...
>   http://www.ai.mit.edu/docs/articles/good-news/good-news.html

I was wondering what he was up to since quitting Genesis...
From: Lars J. Aas
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <afhc5n$rr7$1@news.ost.eltele.no>
In article <·······················@rwcrnsc51.ops.asp.att.net>,
Joe Marshall <·············@attbi.com> wrote:
>"Joel Ray Holveck" <·····@juniper.net> wrote in message
>····················@sindri.juniper.net...
>> > It was written by Danny O Brian who runs a newsletter called Need to Know
>> > (http://www.ntk.com). I think the point he was making was that programmers
>> > don't require languages to be perfect (which he said LISP was an example of)
>> > but just be 80% perfect (like C, C++ etc. etc.)
>>
>> This is related to the point made by another paper by Peter Gabriel:
>> "Lisp: Good News, Bad News, How to Win Big"...
>>   http://www.ai.mit.edu/docs/articles/good-news/good-news.html
>
>I was wondering what he was up to since quitting Genesis...

He didn't lisp back then, did he?

  Lars J
-- 
This is your life and it's ending one minute at a time.
From: Herb Martin
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <Ga3O8.192557$9F5.10102023@typhoon.austin.rr.com>
> I'm using the XLisp-Plus compiler which says that it is fully compatable
with
> Common LISP but I can't work out what is wrong with this. If insted of
"first"

Where did you find an XLisp-Plus that claimed Common
Lisp compatibility -- I would like to download it too.


Herb Martin
Try ADDS for great Weather too:
http://adds.aviationweather.noaa.gov/projects/adds

"ArcLucifer" <··········@aol.com> wrote in message
··································@mb-cd.aol.com...
> I'm trying to learn LISP at the moment with Colin Allen and Maneesh
Dhagat's
> LISP Primer. I'm getting the hang of it except I'm having problems with
the
> Setf command. The lesson on Setf starts by making a list called words:
> (setq words (a list of words))
>
> that's fine, then I'm supposed to use the Setf command to change the first
word
> to "the" with the following code:
> (setf (first words) 'the)
>
> However, when I try this I get the error:
> error: bad place form
>
> I'm using the XLisp-Plus compiler which says that it is fully compatable
with
> Common LISP but I can't work out what is wrong with this. If insted of
"first"
> I use "car":
> (setf (car words) 'the)
>
> then it works. Also, the "first" command works if I try to call up the
first
> word of a list:
> e.g. (first words)
>
> However, it won't work with the setf command.
>
> Could someone please explain what I should do, I've tried reading the FAQs
and
> Help files but I don't seem to be find the solution.
>
> Does anyone know what the problem is and how I should solve it? Should I
get a
> new compiler or something else?
>
> Thanks in advance
>
> -Jacob
>
> (··········@aol.com)
From: Christopher Browne
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <aeafl8$5fppp$1@ID-125932.news.dfncis.de>
"Herb Martin" <·····@LearnQuick.Com> wrote:
>> I'm using the XLisp-Plus compiler which says that it is fully compatable
> with
>> Common LISP but I can't work out what is wrong with this. If insted of
> "first"

> Where did you find an XLisp-Plus that claimed Common Lisp
> compatibility -- I would like to download it too.

A typical report on it is thus:
========================================================================
Xlisp

Xlisp is a public domain Lisp, developed by David Betz. The latest
versions are sub-sets of Common Lisp. It is archived at many sites on
the Net. PC, Macintosh and other versions are available. NB Xlisp-Stat
is Xlisp with statistical and graphical extensions.

<http://sol.brunel.ac.uk/~bainbrid/xlisp.html>
========================================================================

After Betz released "XScheme," which was more Scheme-like, I recall
him revisiting XLisp, and others, such as Tom Almy, trying to get
XLisp to become "more CL-like."

The notion that it got all the way there is pretty preposterous...
-- 
(reverse (concatenate 'string ········@" "enworbbc"))
http://cbbrowne.com/info/nonrdbms.html
"MSDOS didn't get as bad as it  is overnight -- it took over ten years
of careful development."  -- <········@aix1.uottawa.ca>
From: ArcLucifer
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <20020613121306.04153.00000545@mb-bk.aol.com>
I downloaded on recomendation from one of the tutors. I can't remember which
one because I looked at a few. Sorry :-(. However, closer inspection of the
help file does make it clearer that it is not Common Lisp.
I think I just assumed that because the tutor was about Common Lisp and that
this program was recommended by it, that it would be common Lisp as well.

This is what the help file says:
XLISP-PLUS is an enhanced version of David Michael Betz's XLISP to have
additional features of Common Lisp. XLISP-PLUS is distributed for the IBM-PC
family and for UNIX, but can be easily ported to other platforms. Complete
source code is provided ( in "C") to allow easy modification and extension.

	Since XLISP-PLUS is based on XLISP, most XLISP programs will run on
XLISP-PLUS. Since XLISP-PLUS incorporates many more features of Common Lisp,
many small Common Lisp applications will run on XLISP-PLUS with little
modification.

	Many Common Lisp functions are built into XLISP-PLUS. In addition , XLISP
defines the objects 'Object' and 'Class' as primitives. 'Object' is the only
class that has no superclass and hence is the root of the class heirarchy tree.
'Class' is the class of which all classes are instances (it is the only object
that is an instance of itself).

-Jacob
From: Marco Antoniotti
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <y6cvg8mlv08.fsf@octagon.mrl.nyu.edu>
··········@aol.com (ArcLucifer) writes:

> I downloaded on recomendation from one of the tutors.

Tell your tutors that as a punishment for suggesting that they should
read comp.lang.lisp for six months (of course without posting) :)

Cheers

-- 
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group        tel. +1 - 212 - 998 3488
719 Broadway 12th Floor                 fax  +1 - 212 - 995 4122
New York, NY 10003, USA                 http://bioinformatics.cat.nyu.edu
                    "Hello New York! We'll do what we can!"
                           Bill Murray in `Ghostbusters'.
From: sv0f
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <none-1306022138010001@129.59.212.53>
In article <···············@octagon.mrl.nyu.edu>, Marco Antoniotti
<·······@cs.nyu.edu> wrote:

>··········@aol.com (ArcLucifer) writes:
>
>> I downloaded on recomendation from one of the tutors.
>
>Tell your tutors that as a punishment for suggesting that they should
>read comp.lang.lisp for six months (of course without posting) :)

So that's why Tim Bradshaw and Kent Pitman have disappeared ;-)
From: Daniel Barlow
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <87hek7m70s.fsf@noetbook.telent.net>
··········@aol.com (ArcLucifer) writes:

> (setq words (a list of words))

I don't think that's what you typed really, is it?  That's a syntax
error - unless you previously defined a function called A, anyway.
Probably you actually typed

  (setq words '(a list of words))

and if so you should be aware that even though it appeared to work,
modifying the list later will cause undefined behaviour (analogous to
modifying a string constant in C, if you know C).  See the very long
thread about literals ("weird function behaviour", and "modify quoted
list") elsewhere in this group.

If you'd rather go with an approach that won't bite you later, you
need to do something like

  (setq words (list 'a 'list 'of 'words)) ; LIST allocates fresh storage

or

  (setq words (copy-list '(a list of words))) ; COPY-LIST copies its
                                              ;  arg into fresh storage
  
instead.  This appplies to Common Lisp, so also note the other
articles in this thread advising you that XLisp isn't particularly
compatible with CL.  If you want to follow a tutorial based on CL, get
an actual CL implementation ...


-dan

-- 

  http://ww.telent.net/cliki/ - Link farm for free CL-on-Unix resources 
From: ArcLucifer
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <20020613135758.01801.00000647@mb-bk.aol.com>
>
>I don't think that's what you typed really, is it?  That's a syntax
>error - unless you previously defined a function called A, anyway.

Yes, that was a typo :-)

>and if so you should be aware that even though it appeared to work,
>modifying the list later will cause undefined behaviour (analogous to
>modifying a string constant in C, if you know C).  See the very long
>thread about literals ("weird function behaviour", and "modify quoted
>list") elsewhere in this group.
>
I'm not too clear what you mean by this. I'll have a look in the rest of the
group. My programming skills are limited to much simpler languages like various
versions of Basic and the only reason I even looked for LISP on the web was
because an article in the Sunday Times talked about it being "too perfect to be
useful" and "the classical Greek of programming languages". When I had a look
at it, I then realised that it could do things that I'd always found extreamly
difficult in other languages, and that it seemed very simple to get going with,
unlike some of the other "advanced" languages like Java.

Anyway, I'm way off topic now :-)

>
>  (setq words (list 'a 'list 'of 'words)) ; LIST allocates fresh storage

Yes, I've had that sent to me a couple of times. It doesn't achually work for
XLisp, but now I am certain that XLisp is just way too idosyncratic for a
beginner and so I'll get a new program.

Although it does puzzel me why it has changed how one of the most basic
commands, setf, has been changed.

Anyway, thanks for your help :-)

-Jacob
From: Joel Ray Holveck
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <y7celfasuns.fsf@sindri.juniper.net>
> Although it does puzzel me why it has changed how one of the most basic
> commands, setf, has been changed.

From what I saw (which admittedly is not much), XLisp incorporates
"many of the features" of Common Lisp.  It may simply be that it never
incorporated the SETF FIRST bit.

Note that SETF is only one piece of the puzzle.  The other piece is
that each "place form" (such as FIRST) you want to use, needs to be
defined too.  SETF simply dispatches to (SETF CAR), or (SETF FIRST),
or whatever.

ObTechnicality: This is not quite precise, but it's close enough for
the point.

joelh
From: vsync
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <87znxy7s47.fsf@prion.quadium.net>
··········@aol.com (ArcLucifer) writes:

> >and if so you should be aware that even though it appeared to work,
> >modifying the list later will cause undefined behaviour (analogous to
> >modifying a string constant in C, if you know C).  See the very long
> >thread about literals ("weird function behaviour", and "modify quoted
> >list") elsewhere in this group.
> >
> I'm not too clear what you mean by this. I'll have a look in the

A "literal" means something that is hard-coded into your program.  The
problem with modifying it is that in some circumstances you can
actually modify your program.  This can be handy, if you _want_ to
create self-modifying code, but most of the time you don't.  :) Plus,
according to the spec, you can't depend on it anyway.

For example,

[1]> (defun bad () (setf a '(1 2 3)) (setf (cdr a) 7))
BAD
[2]> (symbol-plist 'bad)
(SYSTEM::DEFINITION
  ((DEFUN BAD NIL (SETF A '(1 2 3)) (SETF (CDR A) 7)) .
    #(NIL NIL NIL NIL ((DECLARATION OPTIMIZE DECLARATION)))
) )
[3]> (bad)
7
[4]> (symbol-plist 'bad)
(SYSTEM::DEFINITION
  ((DEFUN BAD NIL (SETF A '(1 . 7)) (SETF (CDR A) 7)) .
    #(NIL NIL NIL NIL ((DECLARATION OPTIMIZE DECLARATION)))
) )

Note that the definition of BAD has changed.

> rest of the group. My programming skills are limited to much simpler
> languages like various versions of Basic and the only reason I even
> looked for LISP on the web was because an article in the Sunday
> Times talked about it being "too perfect to be useful" and "the
> classical Greek of programming languages". When I had a look at it,
> I then realised that it could do things that I'd always found
> extreamly difficult in other languages, and that it seemed very
> simple to get going with, unlike some of the other "advanced"
> languages like Java.
> 
> Anyway, I'm way off topic now :-)

Not that any of us are going to complain about such great advocacy.

> >  (setq words (list 'a 'list 'of 'words)) ; LIST allocates fresh storage
> 
> Yes, I've had that sent to me a couple of times. It doesn't achually work for
> XLisp, but now I am certain that XLisp is just way too idosyncratic for a
> beginner and so I'll get a new program.

Out of curiosity, what doesn't work?  Does the SETQ function not
exist, or does LIST complain about something, or what?

> 
> Although it does puzzel me why it has changed how one of the most basic
> commands, setf, has been changed.

It seems that in your case the problem is that the setf method for
FIRST has not been defined.  When you call (setf (foo bar) baz) in
Common Lisp, the function (setf foo) is actually called.  You may wish
to look up "accessors" when you get a little further along, and/or
check out the entry for SETF in the CLHS.

(Corrections to my explanation are welcome; my terminology gets a
little rusty at times.)

-- 
vsync
http://quadium.net/
(cons (cons (car (cons 'c 'r)) (cdr (cons 'a 'o))) ; Orjner
      (cons (cons (car (cons 'n 'c)) (cdr (cons nil 's))) nil))
From: Thomas F. Burdick
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <xcvadpwcovu.fsf@conquest.OCF.Berkeley.EDU>
vsync <·····@quadium.net> writes:

> (Corrections to my explanation are welcome; my terminology gets a
> little rusty at times.)

Okay

> When you call (setf (foo bar) baz) in Common Lisp, the function
> (setf foo) is actually called.  You may wish to look up "accessors"
> when you get a little further along, and/or check out the entry for
> SETF in the CLHS.

Almost.  You can define a setter for FOO in a few ways.  When
(setf (foo bar) baz) gets expanded, the system looks for a
setf-method, and if one exists, the SETF call gets expanded like a
macro.  If one doen't exist, then it expands into a call to the
function (SETF FOO).

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'                               
From: Barry Margolin
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <TT9O8.20$Kt2.134@paloalto-snr1.gtei.net>
In article <·····························@mb-bk.aol.com>,
ArcLucifer <··········@aol.com> wrote:
>Although it does puzzel me why it has changed how one of the most basic
>commands, setf, has been changed.

It wasn't.  XLisp was originally written in the days of Maclisp and
Interlisp, which didn't have SETF.  In those days there was a different
setter for every type of place: SETQ for variables, SET for symbol value
cells, RPLACA/RPLACD for conses, and ASET for arrays (those were all the
primitive types that the language had 20 years ago).  I think SETF was
originally added as a macro that accompanied the DEFSTRUCT macro, and it
was later generalized to handle all the other types as well.

XLisp has picked up some of this, but not its full generality.

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, 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: Jacek Generowicz
Subject: Re: Newbie problem- Setf command
Date: 
Message-ID: <tyf3cvnftd0.fsf@pcitapi22.cern.ch>
··········@aol.com (ArcLucifer) writes:

> the only reason I even looked for LISP on the web was because an
> article in the Sunday Times talked about it being "too perfect to be
> useful" and "the classical Greek of programming languages".

Do you remember the date of the article, or maybe even have a link to
an on-line version?

Did it just mention Lisp in passing, or did it say more about it ?