Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Namespaces of class slot names and accessors
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
 
Scott McKay  
View profile  
 More options Apr 25 2004, 8:29 am
Newsgroups: comp.lang.lisp
From: "Scott McKay" <scott.mc...@comcast.net>
Date: Sun, 25 Apr 2004 12:29:11 GMT
Local: Sun, Apr 25 2004 8:29 am
Subject: Re: Namespaces of class slot names and accessors

"Paolo Amoroso" <amor...@mclink.it> wrote in message

news:878ygk9tnw.fsf@plato.moon.paoloamoroso.it...

> To which namespace do class slot names belong?  And slot accessors?

> More specifically, I would like to know whether it is possible for
> different classes--in the same package--to have slots with the same
> names, such as:

>   (defclass class1 ()
>     ((same-slot :initarg :same-slot)))

>   (defclass class2 ()
>     ((same-slot :initarg :same-slot)))

> or for different classes to have slots with the same accessor names:

>   (defclass class1 ()
>     ((class1-slot :initarg :class1-slot :accessor same-accessor)))

>   (defclass class2 ()
>     ((class2-slot :initarg :class2-slot :accessor same-accessor)))

'same-accessor' is just the name of a generic function for
the slot's accessor method, so this will work.  However,
even though there is no enforcement, I think that you
should be sure that 'same-accessor' implements the
same sort of semantics for each class.

FWIW, when I share accessor names between multiple
classes, I first define generic functions for those accessors.

As for slot names, well, they're just names of symbols.
After the Dylan experience, slot names as distinct from
accessors seem like a mistake to me now.


    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.

Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google