From: Frédéric BEAULIEU
Subject: RE: p-lists in Common Lisp
Date: 
Message-ID: <3ACB711D.8E7B8426@iname.com>
Hi,

Thanks for all the messages replying and discussing my previous question about p-lists. I've worked hard on it, and my p-lists work fine.

But I've another problem : i need to have a symbol contained in another symbol's p-list. I've managed to do this using a simple setf, but the resulting "symbol-preperty" is in fact the same symbol as the one i created before putting it into the p-list.

Here's an exemple (preferable to my awful english ;-) :

(intern "X" "USER")
(setf (get 'X 'type) 'list)
(setf (get 'X 'name) "V1")
(setf (get 'X 'value) '(1 2 3))
(intern "Y" "USER")
; now, i want X to be a "property" of Y
(setf (get 'Y 'Test) 'X)
; and i'd like to be able to modify X without altering the property X of Y, e.g. :
(setf (get 'X 'name) "V2")
(symbol-plist (get 'Y 'Test))
; returns : (VALUE (1 2 3) NAME "V2" TYPE LIST)
; i'd like : (VALUE (1 2 3) NAME "V1" TYPE LIST)

Two Questions :

1) Is it possible ?
2) HOW !?

Thanks in advance for any answer.

--
BEAULIEU Fr�d�ric
·········@iname.com

From: Martti Halminen
Subject: Re: p-lists in Common Lisp
Date: 
Message-ID: <3ACB898B.36EEB2CD@solibri.com>
Fr�d�ric BEAULIEU wrote:

> But I've another problem : i need to have a symbol contained in another >symbol's p-list. I've managed to do this using a simple setf, but the >resulting "symbol-preperty" is in fact the same symbol as the one i >created before putting it into the p-list.

So it is. What gave you the idea that it would be something else?
Putting some object into a p-list doesn't change the object in any way,
it just adds to the list a pointer to the object.



> Here's an exemple (preferable to my awful english ;-) :
> 
> (intern "X" "USER")

- This looks a little odd. Explicit INTERN calls are relatively seldom
needed, you should probably be using DEFVAR here.


> (setf (get 'X 'type) 'list)
> (setf (get 'X 'name) "V1")
> (setf (get 'X 'value) '(1 2 3))
> (intern "Y" "USER")
> ; now, i want X to be a "property" of Y
> (setf (get 'Y 'Test) 'X)
> ; and i'd like to be able to modify X without altering the property X of Y, e.g. :
> (setf (get 'X 'name) "V2")
> (symbol-plist (get 'Y 'Test))
> ; returns : (VALUE (1 2 3) NAME "V2" TYPE LIST)
> ; i'd like : (VALUE (1 2 3) NAME "V1" TYPE LIST)


> Two Questions :
> 
> 1) Is it possible ?

If you try (eq 'X (get 'Y 'Test)), you get T, so there is no chance of
modifying them separately as they are the same object.

> 2) HOW !?

This looks like something that would be easier to do with structs, for
example. Generally, property lists are seldom used in modern code. They
are a handy place to hang some occasional cruft, but other data
structures are often better for more involved use.

How about:

(defstruct item type name value)

(setq x (make-item :type 'list :name "V1" :value '(1 2 3)))

(setf (get 'Y 'Test) x)

(setq x (make-item :type 'list :name "V2" :value '(1 2 3)))

 (get 'Y 'Test) --> #S(ITEM :TYPE LIST :NAME "V1" :VALUE (1 2 3))
        x       --> #S(ITEM :TYPE LIST :NAME "V2" :VALUE (1 2 3))


The trick here is that each make-item creates a new object.

--
From: Frédéric BEAULIEU
Subject: Re: p-lists in Common Lisp
Date: 
Message-ID: <3ACB8B21.175A6CDB@iname.com>
Hi,

Thank you for you precise and quick answer.
I agree with you : structures would be better, but it's part of a homework and our teacher asked us to use p-lists. So i'm compelled to use them, even if i don't like that ;-(.

Bye
Frederic

Martti Halminen a �crit :

> Fr�d�ric BEAULIEU wrote:
>
> > But I've another problem : i need to have a symbol contained in another >symbol's p-list. I've managed to do this using a simple setf, but the >resulting "symbol-preperty" is in fact the same symbol as the one i >created before putting it into the p-list.
>
> So it is. What gave you the idea that it would be something else?
> Putting some object into a p-list doesn't change the object in any way,
> it just adds to the list a pointer to the object.
>
> > Here's an exemple (preferable to my awful english ;-) :
> >
> > (intern "X" "USER")
>
> - This looks a little odd. Explicit INTERN calls are relatively seldom
> needed, you should probably be using DEFVAR here.
>
> > (setf (get 'X 'type) 'list)
> > (setf (get 'X 'name) "V1")
> > (setf (get 'X 'value) '(1 2 3))
> > (intern "Y" "USER")
> > ; now, i want X to be a "property" of Y
> > (setf (get 'Y 'Test) 'X)
> > ; and i'd like to be able to modify X without altering the property X of Y, e.g. :
> > (setf (get 'X 'name) "V2")
> > (symbol-plist (get 'Y 'Test))
> > ; returns : (VALUE (1 2 3) NAME "V2" TYPE LIST)
> > ; i'd like : (VALUE (1 2 3) NAME "V1" TYPE LIST)
>
> > Two Questions :
> >
> > 1) Is it possible ?
>
> If you try (eq 'X (get 'Y 'Test)), you get T, so there is no chance of
> modifying them separately as they are the same object.
>
> > 2) HOW !?
>
> This looks like something that would be easier to do with structs, for
> example. Generally, property lists are seldom used in modern code. They
> are a handy place to hang some occasional cruft, but other data
> structures are often better for more involved use.
>
> How about:
>
> (defstruct item type name value)
>
> (setq x (make-item :type 'list :name "V1" :value '(1 2 3)))
>
> (setf (get 'Y 'Test) x)
>
> (setq x (make-item :type 'list :name "V2" :value '(1 2 3)))
>
>  (get 'Y 'Test) --> #S(ITEM :TYPE LIST :NAME "V1" :VALUE (1 2 3))
>         x       --> #S(ITEM :TYPE LIST :NAME "V2" :VALUE (1 2 3))
>
> The trick here is that each make-item creates a new object.
>
> --
From: Marco Antoniotti
Subject: Re: p-lists in Common Lisp
Date: 
Message-ID: <y6cg0fo4a3r.fsf@octagon.mrl.nyu.edu>
Fr�d�ric BEAULIEU <·········@iname.com> writes:

> Hi,
> 
> Thank you for you precise and quick answer.
> I agree with you : structures would be better, but it's part of a
> homework and our teacher asked us to use p-lists. So i'm compelled
> to use them, even if i don't like that ;-(.

You should also show the homework using DEFSTRUCT.  It is time to
teach something to your teacher. :)

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: Hannah Schroeter
Subject: Re: p-lists in Common Lisp
Date: 
Message-ID: <9ahq5c$bgf$1@c3po.schlund.de>
Hello!

In article <···············@octagon.mrl.nyu.edu>,
Marco Antoniotti  <·······@cs.nyu.edu> wrote:

>Fr�d�ric BEAULIEU <·········@iname.com> writes:

>> Hi,

>> Thank you for you precise and quick answer.
>> I agree with you : structures would be better, but it's part of a
>> homework and our teacher asked us to use p-lists. So i'm compelled
>> to use them, even if i don't like that ;-(.

>You should also show the homework using DEFSTRUCT.  It is time to
>teach something to your teacher. :)

One way to comply with the teacher:

The class traits could be a structure, linked to the plist of
the symbol representing the class name:

(let ((class-description (make-class-traits ...)))
  (setf (get class-name 'class-description) class-description))

For slot names, the class-traits structure can have a field named
slot-hash, which is a #'eq hash table mapping from symbols (field
names) to a description of the field (e.g. number of the slot
in the vector which implements an instance, possible type spec, ...).

Perhaps *that* use of a symbol plist wouldn't even be too overrated
in nowadays real world usage of Lisp (except that you wouldn't implement
your own object system but use clos / some MOP instead).

Kind regards,

Hannah.
From: Tim Moore
Subject: Re: p-lists in Common Lisp
Date: 
Message-ID: <9ag4ac$d1j$0@216.39.145.192>
On Wed, 4 Apr 2001, [iso-8859-1] Frédéric BEAULIEU wrote:

> Hi,
> 
> Thank you for you precise and quick answer.
> I agree with you : structures would be better, but it's part of a homework and our teacher asked us to use p-lists. So i'm compelled to use them, even if i don't like that ;-(.

I knew it!!  Let me guess, you're using some Lisp or AI text from the
'80s? :)

Tim
From: Frédéric BEAULIEU
Subject: Re: p-lists in Common Lisp
Date: 
Message-ID: <3ACB9CAE.9837C1D7@iname.com>
No,
the (stupid ? didactic ?) goal of my project is to implement an object-oriented "layer" on LISP (and, YES, i know about CLOS and my teacher too ;-)).

I represent classes and objects as symbols, and i wanted to represent each field with a single symbol allowing me to store its type, value, name, special properties (public, private,
...). I'm considering to use hashtables or structs to do this, what would be the best ?

Frederic

Tim Moore a �crit :

> On Wed, 4 Apr 2001, [iso-8859-1] Fr�d�ric BEAULIEU wrote:
>
> > Hi,
> >
> > Thank you for you precise and quick answer.
> > I agree with you : structures would be better, but it's part of a homework and our teacher asked us to use p-lists. So i'm compelled to use them, even if i don't like that ;-(.
>
> I knew it!!  Let me guess, you're using some Lisp or AI text from the
> '80s? :)
>
> Tim
From: Tim Moore
Subject: Re: p-lists in Common Lisp
Date: 
Message-ID: <9ag75o$kjn$0@216.39.145.192>
On Thu, 5 Apr 2001, [iso-8859-1] Frédéric BEAULIEU wrote:

> No,
> the (stupid ? didactic ?) goal of my project is to implement an object-oriented "layer" on LISP (and, YES, i know about CLOS and my teacher too ;-)).
> 
> I represent classes and objects as symbols, and i wanted to represent each field with a single symbol allowing me to store its type, value, name, special properties (public, private,
> ...). I'm considering to use hashtables or structs to do this, what would be the best ?

Ahhh... my advice would be to use structs for objects and classes and to
use hashtables to map between class names and their "properties."  If your
class properties are objects in your system, you're well on the way to
making your implementation meta-circular, just like the real thing :)
That should bug out your teacher.

"I'm sorry, but despite the fact that you've implemented a meta-object
protocol, you didn't use property lists in the assignment.  That's 50
points off."

Tim

> Frederic
> 
> Tim Moore a écrit :
> 
> > On Wed, 4 Apr 2001, [iso-8859-1] Frédéric BEAULIEU wrote:
> >
> > > Hi,
> > >
> > > Thank you for you precise and quick answer.
> > > I agree with you : structures would be better, but it's part of a homework and our teacher asked us to use p-lists. So i'm compelled to use them, even if i don't like that ;-(.
> >
> > I knew it!!  Let me guess, you're using some Lisp or AI text from the
> > '80s? :)
> >
> > Tim
> 
> 
> 
From: Barry Margolin
Subject: Re: p-lists in Common Lisp
Date: 
Message-ID: <OGNy6.283$U4.10371@burlma1-snr2>
In article <············@216.39.145.192>,
Tim Moore  <·····@herschel.bricoworks.com> wrote:
>"I'm sorry, but despite the fact that you've implemented a meta-object
>protocol, you didn't use property lists in the assignment.  That's 50
>points off."

If part of the object of the assignment is to learn about property lists,
then it's a deserved penalty, don't you think?

You can't judge homework assignments the same way you judge real-world
projects.  In the real world the goal is to solve a problem, and you should
use the best tool for the job.  In an academic exercise, the goal is often
to learn how to use a particular tool.  If this were an art class and this
week's assignment was on water colors, an oil painting would get a failing
grade no matter how beautiful it is.

-- 
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: ········@hex.net
Subject: Re: p-lists in Common Lisp
Date: 
Message-ID: <woOy6.125850$lj4.3815736@news6.giganews.com>
Barry Margolin <······@genuity.net> writes:
> In article <············@216.39.145.192>,
> Tim Moore  <·····@herschel.bricoworks.com> wrote:
> >"I'm sorry, but despite the fact that you've implemented a meta-object
> >protocol, you didn't use property lists in the assignment.  That's 50
> >points off."
> 
> If part of the object of the assignment is to learn about property lists,
> then it's a deserved penalty, don't you think?
> 
> You can't judge homework assignments the same way you judge real-world
> projects.  In the real world the goal is to solve a problem, and you should
> use the best tool for the job.  In an academic exercise, the goal is often
> to learn how to use a particular tool.  If this were an art class and this
> week's assignment was on water colors, an oil painting would get a failing
> grade no matter how beautiful it is.

It's not quite the same as art class; water and oil are in active
continuing use.

In contrast, the use of plists is, if not deprecated _explicitly_,
certainly deprecated _implicitly_ by the fact that CL has both STRUCTs
as well as CLOS.

The unfortunate side-effect of the pedagogy in question is to teach
students to use things for which there are likely superior
replacements.

It is _possible_ that the instructor has better intent than that; if
DEFSTRUCT gets used, or CLOS, later in the course, then that's
certainly the case.

Otherwise, a pessimistic view seems not out of order...
-- 
(reverse (concatenate 'string ··········@" "enworbbc"))
http://www.ntlug.org/~cbbrowne/resume.html
I was  thinking about how  people seem to  read the Bible a  whole lot
more as they  get older then it dawned on  me...they were cramming for
their finals.
From: Barry Margolin
Subject: Re: p-lists in Common Lisp
Date: 
Message-ID: <FxOy6.285$U4.10433@burlma1-snr2>
In article <························@news6.giganews.com>,
 <········@hex.net> wrote:
>It's not quite the same as art class; water and oil are in active
>continuing use.
>
>In contrast, the use of plists is, if not deprecated _explicitly_,
>certainly deprecated _implicitly_ by the fact that CL has both STRUCTs
>as well as CLOS.

So you're saying that this assignment is like asking an art student to turn
in a cave painting? :)

>The unfortunate side-effect of the pedagogy in question is to teach
>students to use things for which there are likely superior
>replacements.

I agree.  But the right way to deal with it is not to turn in work that
doesn't meet the requirements.  Do the assignment and then talk to the
teacher after class about updating the curriculum.

-- 
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: Marco Antoniotti
Subject: Re: p-lists in Common Lisp
Date: 
Message-ID: <y6c1yr74g9e.fsf@octagon.mrl.nyu.edu>
Barry Margolin <······@genuity.net> writes:

> In article <············@216.39.145.192>,
> Tim Moore  <·····@herschel.bricoworks.com> wrote:
> >"I'm sorry, but despite the fact that you've implemented a meta-object
> >protocol, you didn't use property lists in the assignment.  That's 50
> >points off."
> 
> If part of the object of the assignment is to learn about property lists,
> then it's a deserved penalty, don't you think?
> 
> You can't judge homework assignments the same way you judge real-world
> projects.  In the real world the goal is to solve a problem, and you should
> use the best tool for the job.  In an academic exercise, the goal is often
> to learn how to use a particular tool.  If this were an art class and this
> week's assignment was on water colors, an oil painting would get a failing
> grade no matter how beautiful it is.

I agree.  But I have not seen the syllabus of the course.  Does the
syllabus contain far more extensive coverage of CLOS than p-lists or
not?  If not, the course is bogus and harmful to the "Common Lisp
Community" as a whole.

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'.