Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Slots metaobjects access through MOP
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
  13 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
 
Mariano Montone  
View profile  
 More options Dec 28 2008, 9:04 am
Newsgroups: comp.lang.lisp
From: Mariano Montone <marianomont...@gmail.com>
Date: Sun, 28 Dec 2008 06:04:45 -0800 (PST)
Local: Sun, Dec 28 2008 9:04 am
Subject: Slots metaobjects access through MOP
Hi,
     I'd like to know how I can access an object slot metaobject from
outside slot-value-using-class. I mean, given an object instance and a
set of slot names, get the metaobjects, not the metaclass, of those
slots, to iterate over them, or bind them, for example.

Thanks

Mariano


    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 J. Bourguignon  
View profile  
 More options Dec 28 2008, 9:15 am
Newsgroups: comp.lang.lisp
From: p...@informatimago.com (Pascal J. Bourguignon)
Date: Sun, 28 Dec 2008 15:15:13 +0100
Local: Sun, Dec 28 2008 9:15 am
Subject: Re: Slots metaobjects access through MOP

Mariano Montone <marianomont...@gmail.com> writes:
>      I'd like to know how I can access an object slot metaobject from
> outside slot-value-using-class. I mean, given an object instance and a
> set of slot names, get the metaobjects, not the metaclass, of those
> slots, to iterate over them, or bind them, for example.

Yes. Have a look at: http://www.lisp.org/mop/index.html

However, perhaps you don't want that. Perhaps you just want to access
the slots by name: CLHS slot-value
http://www.lispworks.com/documentation/HyperSpec/Body/07_eb.htm

--
__Pascal Bourguignon__


    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.
Alex Mizrahi  
View profile  
 More options Dec 28 2008, 9:28 am
Newsgroups: comp.lang.lisp
From: "Alex Mizrahi" <udode...@users.sourceforge.net>
Date: Sun, 28 Dec 2008 16:28:03 +0200
Local: Sun, Dec 28 2008 9:28 am
Subject: Re: Slots metaobjects access through MOP
 MM>      I'd like to know how I can access an object slot metaobject from
 MM> outside slot-value-using-class. I mean, given an object instance and a
 MM> set of slot names, get the metaobjects, not the metaclass, of those
 MM> slots, to iterate over them, or bind them, for example.

if by "slot metaobject" you mean effective-slot-definitions then yes, you
can get them via CLASS-SLOTS function. like this:

(class-slots (find-class 'standard-generic-function))
(#<STANDARD-EFFECTIVE-SLOT-DEFINITION SB-PCL::SOURCE>
 #<STANDARD-EFFECTIVE-SLOT-DEFINITION SB-PCL::PLIST>
 #<STANDARD-EFFECTIVE-SLOT-DEFINITION SB-PCL::%DOCUMENTATION>
 #<STANDARD-EFFECTIVE-SLOT-DEFINITION SB-PCL::INITIAL-METHODS>


    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.
Mariano Montone  
View profile  
 More options Dec 28 2008, 9:38 am
Newsgroups: comp.lang.lisp
From: Mariano Montone <marianomont...@gmail.com>
Date: Sun, 28 Dec 2008 06:38:09 -0800 (PST)
Local: Sun, Dec 28 2008 9:38 am
Subject: Re: Slots metaobjects access through MOP
On 28 dic, 12:15, p...@informatimago.com (Pascal J. Bourguignon)
wrote:

> Mariano Montone <marianomont...@gmail.com> writes:
> >      I'd like to know how I can access an object slot metaobject from
> > outside slot-value-using-class. I mean, given an object instance and a
> > set of slot names, get the metaobjects, not the metaclass, of those
> > slots, to iterate over them, or bind them, for example.

> Yes. Have a look at:http://www.lisp.org/mop/index.html

> However, perhaps you don't want that. Perhaps you just want to access
> the slots by name: CLHS slot-valuehttp://www.lispworks.com/documentation/HyperSpec/Body/07_eb.htm

Sorry, but I can't find what I want. This is my problem. I have some
dataflow-slot-metaclass. Each dataflow-slot-metaclass defines a
listener slot. Then, I should be able to intercept the slot-value
setting with (setf slot-value-using-class) and iterate on the
listeners. That's ok, although I haven't tested it yet. But how can I,
given an object instance and a list of slots names, get those slot
metaobjects. The slot metaobjects are the ones that have the slot
listeners. My purpose is to implement a macro like (defmacro with-
dataflow-slots (slots object &rest body) ..) and bind the slot
metaobjects so that I can process the listeners of those slots.

If what I say is not understandable, it's ok. Maybe I should read the
MOP documentation more carefully.

Mariano


    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.
Mariano Montone  
View profile  
 More options Dec 28 2008, 9:46 am
Newsgroups: comp.lang.lisp
From: Mariano Montone <marianomont...@gmail.com>
Date: Sun, 28 Dec 2008 06:46:57 -0800 (PST)
Local: Sun, Dec 28 2008 9:46 am
Subject: Re: Slots metaobjects access through MOP
On 28 dic, 12:28, "Alex Mizrahi" <udode...@users.sourceforge.net>
wrote:

>  MM>      I'd like to know how I can access an object slot metaobject from
>  MM> outside slot-value-using-class. I mean, given an object instance and a
>  MM> set of slot names, get the metaobjects, not the metaclass, of those
>  MM> slots, to iterate over them, or bind them, for example.

> if by "slot metaobject" you mean effective-slot-definitions then yes, you
> can get them via CLASS-SLOTS function. like this:

> (class-slots (find-class 'standard-generic-function))
> (#<STANDARD-EFFECTIVE-SLOT-DEFINITION SB-PCL::SOURCE>
>  #<STANDARD-EFFECTIVE-SLOT-DEFINITION SB-PCL::PLIST>
>  #<STANDARD-EFFECTIVE-SLOT-DEFINITION SB-PCL::%DOCUMENTATION>
>  #<STANDARD-EFFECTIVE-SLOT-DEFINITION SB-PCL::INITIAL-METHODS>

Mmm...no...I don't want that. I would like something like: (slot-named
'lastname *person*) and that should give me the slot-definition with
the extra behavior and data I defined through a slot-metaclass for
that slot.

Mariano


    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.
Alex Mizrahi  
View profile  
 More options Dec 28 2008, 10:27 am
Newsgroups: comp.lang.lisp
From: "Alex Mizrahi" <udode...@users.sourceforge.net>
Date: Sun, 28 Dec 2008 17:27:29 +0200
Local: Sun, Dec 28 2008 10:27 am
Subject: Re: Slots metaobjects access through MOP
 MM> Mmm...no...I don't want that. I would like something like: (slot-named
 MM> 'lastname *person*) and that should give me the slot-definition with
 MM> the extra behavior and data I defined through a slot-metaclass for
 MM> that slot.

first, let's clarify this, slot definitions are created for each _class_,
not for
each object instance.

if you're looking for something that is associated with each instance,
 there is no ready-made machinery for this -- you'll have to make
your own.

if you really need a slot definition, there is no problem -- just
find them via class-slots.


    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.
Mariano Montone  
View profile  
 More options Dec 28 2008, 10:56 am
Newsgroups: comp.lang.lisp
From: Mariano Montone <marianomont...@gmail.com>
Date: Sun, 28 Dec 2008 07:56:49 -0800 (PST)
Local: Sun, Dec 28 2008 10:56 am
Subject: Re: Slots metaobjects access through MOP
On 28 dic, 13:27, "Alex Mizrahi" <udode...@users.sourceforge.net>
wrote:

>  MM> Mmm...no...I don't want that. I would like something like: (slot-named
>  MM> 'lastname *person*) and that should give me the slot-definition with
>  MM> the extra behavior and data I defined through a slot-metaclass for
>  MM> that slot.

> first, let's clarify this, slot definitions are created for each _class_,
> not for
> each object instance.

> if you're looking for something that is associated with each instance,
>  there is no ready-made machinery for this -- you'll have to make
> your own.

> if you really need a slot definition, there is no problem -- just
> find them via class-slots.

yeah...i see. I was mixing meta-levels.

Thanks!

Mariano


    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 J. Bourguignon  
View profile  
 More options Dec 28 2008, 11:07 am
Newsgroups: comp.lang.lisp
From: p...@informatimago.com (Pascal J. Bourguignon)
Date: Sun, 28 Dec 2008 17:07:57 +0100
Local: Sun, Dec 28 2008 11:07 am
Subject: Re: Slots metaobjects access through MOP

I don't know what the "slot listeners" are.
http://www.lisp.org/mop/concepts.html mentions only:

  The following information is associated with both direct and effective slot definitions metaobjects:

      * The name, allocation, and type are available as forms that could
        appear in a defclass form.

      * The initialization form, if there is one, is available as a form
        that could appear in a defclass form. The initialization form
        together with its lexical environment is available as a function
        of no arguments which, when called, returns the result of
        evaluating the initialization form in its lexical
        environment. This is called the initfunction of the slot.

      * The slot filling initialization arguments are available as a list
        of symbols.

      * The documentation is available as a string or nil.

  Certain other information is only associated with direct slot definition
  metaobjects. This information applies only to the direct definition of
  the slot in the class (it is not inherited).

      * The function names of those generic functions for which there are
        automatically generated reader and writer methods. This
        information is available as lists of function names. Any accessors
        specified in the defclass form are broken down into their
        equivalent readers and writers in the direct slot definition.

By "listener" do you mean "reader"?

--
__Pascal Bourguignon__


    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.
Kenny  
View profile  
 More options Dec 28 2008, 1:53 pm
Newsgroups: comp.lang.lisp
From: Kenny <kentil...@gmail.com>
Date: Sun, 28 Dec 2008 13:53:37 -0500
Local: Sun, Dec 28 2008 1:53 pm
Subject: Re: Slots metaobjects access through MOP

I do not understand: you have managed to define a metaclass and arranged
for custom slot definitions to be created and you cannot figure out how
to get the slot definition associated with a slot name? That's weird, so
maybe I do not understand you.

If I do understand you, there is no trick to it other than the fact that
there is no built-in call.

First ask for the slots of the class (probably with class-slots on the
class) and what you will get back (depending on which Lisp you use!)
will be the effective-slot-definitions. Then just find the symbolic
slot-name with a :key of slot-definition-name.

     (find 'my-slot (class-slots (find-class 'my-class))
        :key 'slot-definition-name)

hth,kenneth

ps.

> Maybe I should read the
> MOP documentation more carefully.

That was pretty tough sledding, as I recall. Don't be afraid to ask here.

pps. What Lisp are you using? The MOP varies from Lisp to Lisp. k


    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.
Mariano Montone  
View profile  
 More options Dec 28 2008, 8:49 pm
Newsgroups: comp.lang.lisp
From: Mariano Montone <marianomont...@gmail.com>
Date: Sun, 28 Dec 2008 17:49:02 -0800 (PST)
Local: Sun, Dec 28 2008 8:49 pm
Subject: Re: Slots metaobjects access through MOP
On 28 dic, 16:53, Kenny <kentil...@gmail.com> wrote:

> > Maybe I should read the
> > MOP documentation more carefully.

> That was pretty tough sledding, as I recall. Don't be afraid to ask here.

Problem solved. I was confused about the meta levels. Thank you all
for your help. I'll post here when I'm stuck.

Off topic: Kenny, what I'm playing with has to do with what your Cells
library is for. I've worked in a project and relized that dataflow is
somewhat critical, or very desirable at least, for some applications.
Not that your library isn't useful. Just that, you know, writing code
is easier than reading it, although I should probably learn it because
its already mature and working. But there are several things I don't
totally understand yet. For example, how do you deal with dependencies
between objects and memory. How do you free the memory. Do you use
weak-references?

This is what I've come up with with my library:

(defclass bank-account ()
  ((money :initform (make-instance 'dfvaluecell :value 0))))

(defparameter *ba* (make-instance 'bank-account))

(defparameter *w*
  (let ((suma (let ((slot (slot-value *ba* 'money))
                    (b 2))
                (df
                 (declare (external b))
                 (+ slot b)))))
    (df
     (format t "Getting value of suma1!!~%")
     (* suma 5))))

The magic is in the df macro. It takes free variables and assumes they
are dfvaluecells, unless you declare they are external with (declare
(external )). Then, each free variable is bound through a weak-
reference, so memory management is automatic. The df transformed body
is added to those free variables as listener. The format is just for
debugging purposes.

Now I'm trying to plug things in CLOS so that valuecells are
transparent to CLOS users.

Mariano


    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.
Mariano Montone  
View profile  
 More options Dec 28 2008, 8:51 pm
Newsgroups: comp.lang.lisp
From: Mariano Montone <marianomont...@gmail.com>
Date: Sun, 28 Dec 2008 17:51:09 -0800 (PST)
Local: Sun, Dec 28 2008 8:51 pm
Subject: Re: Slots metaobjects access through MOP
On 28 dic, 23:49, Mariano Montone <marianomont...@gmail.com> wrote:

Of course, whenever I change the bank account money slot, *w* is
updated.

    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.
Kenny  
View profile  
 More options Dec 28 2008, 9:50 pm
Newsgroups: comp.lang.lisp
From: Kenny <kentil...@gmail.com>
Date: Sun, 28 Dec 2008 21:50:04 -0500
Local: Sun, Dec 28 2008 9:50 pm
Subject: Re: Slots metaobjects access through MOP

No, as a matter of fact I use Cells. Look at the "owning" parameter to
the slot def... hang on. I forgot: you know Cells exists, you know where
to find the source, you are not going to take the time to look at it,
but you want me to spend time on explaining it.

I think you'll fit in pretty well around here!

kenneth


    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.
Mariano Montone  
View profile  
 More options Dec 28 2008, 10:16 pm
Newsgroups: comp.lang.lisp
From: Mariano Montone <marianomont...@gmail.com>
Date: Sun, 28 Dec 2008 19:16:34 -0800 (PST)
Local: Sun, Dec 28 2008 10:16 pm
Subject: Re: Slots metaobjects access through MOP
On 29 dic, 00:50, Kenny <kentil...@gmail.com> wrote:

haha  ok

    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