Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
CLOS Qs
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
danb  
View profile  
 More options Apr 24 2008, 12:29 pm
Newsgroups: comp.lang.lisp
From: danb <sogwal...@gmail.com>
Date: Thu, 24 Apr 2008 09:29:30 -0700 (PDT)
Local: Thurs, Apr 24 2008 12:29 pm
Subject: CLOS Qs
Just a couple questions about CLOS:

1. What's the best/most-reliable way to determine whether
a value is a clos object, ie. something that may have slots that
can be accessed with slot-value?  So far, the two possibilities
seem to be
  (subtypep (type-of val) 'standard-object)
and
  (find-class val)

2. How can you tell whether a particular symbol names
an accessor for a particular object?

--Dan

------------------------------------------------
Dan Bensen
http://www.prairienet.org/~dsb/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rainer Joswig  
View profile  
 More options Apr 24 2008, 1:35 pm
Newsgroups: comp.lang.lisp
From: Rainer Joswig <jos...@lisp.de>
Date: Thu, 24 Apr 2008 19:35:00 +0200
Subject: Re: CLOS Qs
In article
<9b79cf3a-16fd-406f-bb85-3103bc7e0...@z72g2000hsb.googlegroups.com>,

 danb <sogwal...@gmail.com> wrote:
> Just a couple questions about CLOS:

> 1. What's the best/most-reliable way to determine whether
> a value is a clos object, ie. something that may have slots that
> can be accessed with slot-value?  So far, the two possibilities
> seem to be
>   (subtypep (type-of val) 'standard-object)

(typep val 'standard-object) ?

> and
>   (find-class val)

> 2. How can you tell whether a particular symbol names
> an accessor for a particular object?

You can check whether the symbol is a generic function,
has one parameter and is applicable with the object
as an argument.

With the MOP you could check whether the applicable
method is of the class STANDARD-READER-METHOD .

> --Dan

> ------------------------------------------------
> Dan Bensen
> http://www.prairienet.org/~dsb/

--
http://lispm.dyndns.org/

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas A. Russ  
View profile  
 More options Apr 24 2008, 1:59 pm
Newsgroups: comp.lang.lisp
From: t...@sevak.isi.edu (Thomas A. Russ)
Date: 24 Apr 2008 10:59:27 -0700
Local: Thurs, Apr 24 2008 1:59 pm
Subject: Re: CLOS Qs

danb <sogwal...@gmail.com> writes:
> Just a couple questions about CLOS:

> 1. What's the best/most-reliable way to determine whether
> a value is a clos object, ie. something that may have slots that
> can be accessed with slot-value?  So far, the two possibilities
> seem to be
>   (subtypep (type-of val) 'standard-object)
> and
>   (find-class val)

(typep val 'standard-object)  is perhaps simpler still.

> 2. How can you tell whether a particular symbol names
> an accessor for a particular object?

You would have to use some of the MOP functions to do this.
For example:

  (mop:finalize-inheritance (find-class 'class-name))
  (mapcar #'mop:slot-definition-readers
          (mop:class-slots (find-class 'class-name)))

will give you a list of the symbols naming slot reader functions for the
class in question.

You might also need to check mop:slot-definition-writers and possibly
parse the (SETF SLOTNAME) forms that returns if you really want
accessors and not specifically readers and writers.

You will presumably also need to figure out what package corresponds to
MOP in your particular implementation as well.

--
Thomas A. Russ,  USC/Information Sciences Institute


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal Costanza  
View profile  
 More options Apr 24 2008, 3:42 pm
Newsgroups: comp.lang.lisp
From: Pascal Costanza <p...@p-cos.net>
Date: Thu, 24 Apr 2008 21:42:15 +0200
Local: Thurs, Apr 24 2008 3:42 pm
Subject: Re: CLOS Qs

danb wrote:
> Just a couple questions about CLOS:

> 1. What's the best/most-reliable way to determine whether
> a value is a clos object, ie. something that may have slots that
> can be accessed with slot-value?  So far, the two possibilities
> seem to be
>   (subtypep (type-of val) 'standard-object)
> and
>   (find-class val)

Others have mentioned (typep val 'standard-object), but (typep (class-of
val) 'standard-class) should be even more reliable (but for most
practical cases, they are equivalent).

> 2. How can you tell whether a particular symbol names
> an accessor for a particular object?

You can't because symbols don't name accessors. Symbols can name generic
functions, and some of the methods associated with a generic function
can be accessor methods, but accessor methods themselves are anonymous.

What you say you want could be expressed as follows (provided you can
use the CLOS MOP):

(loop for method in (generic-function-methods (fdefinition fname))
       thereis (subtypep method 'standard-accessor-method))

...but I doubt that this is what you really want...

What problem are you actually trying to solve?

Pascal

--
1st European Lisp Symposium (ELS'08)
http://prog.vub.ac.be/~pcostanza/els08/

My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
danb  
View profile  
 More options Apr 24 2008, 5:06 pm
Newsgroups: comp.lang.lisp
From: danb <sogwal...@gmail.com>
Date: Thu, 24 Apr 2008 14:06:52 -0700 (PDT)
Local: Thurs, Apr 24 2008 5:06 pm
Subject: Re: CLOS Qs
On Apr 24, 2:42 pm, Pascal Costanza <p...@p-cos.net> wrote:

> Others have mentioned (typep val 'standard-object),
> but (typep (class-of val) 'standard-class) should be
> even more reliable (but for most practical cases,
> they are equivalent).

Thanks.

> > 2. How can you tell whether a particular symbol names
> > an accessor for a particular object?

> You can't because symbols don't name accessors.
> Symbols can name generic functions

I mean indirectly, given the type of the object.

> What you say you want could be expressed as follows
> (provided you can use the CLOS MOP):
> (loop for method in
>   (generic-function-methods (fdefinition fname))
>   thereis (subtypep method 'standard-accessor-method))
> ...but I doubt that this is what you really want...

Maybe not.  We'll see.

> What problem are you actually trying to solve?

I'm trying to generate code that matches a value against
a pattern that's looking for a clos object with certain
accessors.  There's a man page here:
http://www.prairienet.org/~dsb/clmatch-api.htm#accsrs

Thanks for the help, Pascal.

--Dan

------------------------------------------------
Dan Bensen
http://www.prairienet.org/~dsb/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal Costanza  
View profile  
 More options Apr 24 2008, 5:44 pm
Newsgroups: comp.lang.lisp
From: Pascal Costanza <p...@p-cos.net>
Date: Thu, 24 Apr 2008 23:44:51 +0200
Local: Thurs, Apr 24 2008 5:44 pm
Subject: Re: CLOS Qs

I find the description of the accsrs form weird, but the description of
the slots form seems to be relatively clear. Do you want the same for
accrs as for slots, but just with accessor functions instead of slot names?

If so, you could use the following functions of the CLOS MOP:

- class-direct-slots gives the direct slot definitions for a given class
metaobject

- class-direct-superclasses gives you all the (direct and indirect)
superclasses of a class. This allows you to collect all direct slots

- slot-definition-readers and slot-definition-writers gives you the
function names of the accessors of a specific direct slot (they don't
work on effective slots)

I hope this helps.

Pascal

--
1st European Lisp Symposium (ELS'08)
http://prog.vub.ac.be/~pcostanza/els08/

My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kent M Pitman  
View profile  
 More options Apr 24 2008, 5:45 pm
Newsgroups: comp.lang.lisp
From: Kent M Pitman <pit...@nhplace.com>
Date: 24 Apr 2008 17:45:21 -0400
Local: Thurs, Apr 24 2008 5:45 pm
Subject: Re: CLOS Qs

danb <sogwal...@gmail.com> writes:
> Just a couple questions about CLOS:

> 1. What's the best/most-reliable way to determine whether
> a value is a clos object,

Check whether you're using Common Lisp. If you're using CL and you
have an object, it's a CLOS object.

CLOS describes (to a greater or lesser degree) all object behaviors,
even the metaclasses used for built-in classes, structures, and
errors.

This isn't the question you meant to be asking, and someone else will
surely answer on the substance of what you were asking (about standard
classes), but it's a common terminology error to refer to the thing
you do with defclass as "using CLOS" and the other stuff as "not using
CLOS".  In fact, CLOS is a spanning philosophy for all of the system,
since Lisp has no data that isn't an object.  Some objects are more
transparent than others, so you may not be able to get inside some objects,
but that doesn't make them not objects.

Many real-world items (rocks, for example) don't have a lot of
reflection capability for analyzing their internals from the outside.
But that doesn't make them any less "objects".  In fact, the original
meaning of object-oriented was more about identity than about
definition style and reflection...


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
danb  
View profile  
 More options Apr 24 2008, 6:57 pm
Newsgroups: comp.lang.lisp
From: danb <sogwal...@gmail.com>
Date: Thu, 24 Apr 2008 15:57:42 -0700 (PDT)
Local: Thurs, Apr 24 2008 6:57 pm
Subject: Re: CLOS Qs
On Apr 24, 4:44 pm, Pascal Costanza <p...@p-cos.net> wrote:

> I find the description of the accsrs form weird

Not surprising.  I just copied it from the SLOTs entry.

> but the description of the slots form seems to be
> relatively clear. Do you want the same for accrs as
> for slots, but just with accessor functions instead
> of slot names?

I have no idea.  Whatever's reasonable or useful.

> If so, you could use the following functions of
> the CLOS MOP:
> - class-direct-slots
> - class-direct-superclasses
> - slot-definition-readers and slot-definition-writers
> I hope this helps.

Thanks, that's something to think about.

--Dan

------------------------------------------------
Dan Bensen
http://www.prairienet.org/~dsb/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
danb  
View profile  
 More options Apr 24 2008, 7:02 pm
Newsgroups: comp.lang.lisp
From: danb <sogwal...@gmail.com>
Date: Thu, 24 Apr 2008 16:02:19 -0700 (PDT)
Local: Thurs, Apr 24 2008 7:02 pm
Subject: Re: CLOS Qs
On Apr 24, 4:45 pm, Kent M Pitman wrote:

> CLOS describes (to a greater or lesser degree)
> all object behaviors, even the metaclasses used for
> built-in classes, structures, and errors.
> CLOS is a spanning philosophy for all of the system

Thanks for the info, Kent.

--Dan

------------------------------------------------
Dan Bensen
http://www.prairienet.org/~dsb/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal Bourguignon  
View profile  
 More options Apr 25 2008, 1:48 am
Newsgroups: comp.lang.lisp
From: Pascal Bourguignon <p...@informatimago.com>
Date: Fri, 25 Apr 2008 07:48:09 +0200
Local: Fri, Apr 25 2008 1:48 am
Subject: Re: CLOS Qs
Kent M Pitman <pit...@nhplace.com> writes:

Therefore (typep thing 'standard-object)

--
__Pascal Bourguignon__                     http://www.informatimago.com/

CONSUMER NOTICE: Because of the "uncertainty principle," it is
impossible for the consumer to simultaneously know both the precise
location and velocity of this product.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google