I would like to ask what naming conventions people use for slot accessors.
Eg I have a class named foo, and I want an accessor for a slot named bar.
The choices that occur to me are bar, bar-of, foo-bar, bar-of-foo. But
maybe there are others.
Sorry if the question is trivial, I would like to develop a good coding
style.
Thank you,
Tamas
From: Javier
Subject: Re: naming conventions for slot accessors
Date:
Message-ID: <ge4nuo$l7h$1@aioe.org>
Tamas K Papp escribió:
> I would like to ask what naming conventions people use for slot accessors.
>
> Eg I have a class named foo, and I want an accessor for a slot named bar.
> The choices that occur to me are bar, bar-of, foo-bar, bar-of-foo. But
> maybe there are others.
>
> Sorry if the question is trivial, I would like to develop a good coding
> style.
Isn't (slot-vale object 'slot-name) a good coding style? ;-)
As I said, CL is full of things like that...
Javier <······@askmyadress.com> writes:
> Tamas K Papp escribió:
>> I would like to ask what naming conventions people use for slot accessors.
>>
>> Eg I have a class named foo, and I want an accessor for a slot named bar.
>> The choices that occur to me are bar, bar-of, foo-bar, bar-of-foo.
>> But maybe there are others.
>>
>> Sorry if the question is trivial, I would like to develop a good
>> coding style.
>
> Isn't (slot-vale object 'slot-name) a good coding style? ;-)
>
> As I said, CL is full of things like that...
Yeah, object.instance_variable_get(·@slot_name) is so much better and
cleaner.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
In article <············@aioe.org>, Javier <······@askmyadress.com>
wrote:
> Tamas K Papp escribió:
> > I would like to ask what naming conventions people use for slot accessors.
> >
> > Eg I have a class named foo, and I want an accessor for a slot named bar.
> > The choices that occur to me are bar, bar-of, foo-bar, bar-of-foo. But
> > maybe there are others.
> >
> > Sorry if the question is trivial, I would like to develop a good coding
> > style.
>
> Isn't (slot-vale object 'slot-name) a good coding style? ;-)
>
> As I said, CL is full of things like that...
Object slots can be accessed
via SLOT-VALUE and accessors (+ readers, writers).
These two mechanisms provide different functionality.
Tamas was asking how to name accessor functions.
Proposing to use SLOT-VALUE does not help, since
that provides slightly different functionality.
--
http://lispm.dyndns.org/
From: Javier
Subject: Re: naming conventions for slot accessors
Date:
Message-ID: <ge4qbl$v6i$1@aioe.org>
Rainer Joswig wrote:
> Tamas was asking
Tamas was not asking.
He is measuring how much people is getting his attention.
He is feeling insecure.
In article <············@aioe.org>, Javier <······@askmyadress.com>
wrote:
> Rainer Joswig wrote:
>
> > Tamas was asking
>
> Tamas was not asking.
> He is measuring how much people is getting his attention.
> He is feeling insecure.
Hmm, I think you are now in my killfile. Sorry about that...
--
http://lispm.dyndns.org/
From: Javier
Subject: Re: naming conventions for slot accessors
Date:
Message-ID: <ge506q$ls1$1@aioe.org>
Rainer Joswig escribi�:
> Hmm, I think you are now in my killfile. Sorry about that...
So, do you sympathize with the insecurity of your friend?
From: Raymond Wiker
Subject: Re: naming conventions for slot accessors
Date:
Message-ID: <m2hc6xn6pu.fsf@RAWMBP.local>
Javier <······@askmyadress.com> writes:
> Rainer Joswig escribi�:
>
>> Hmm, I think you are now in my killfile. Sorry about that...
>
> So, do you sympathize with the insecurity of your friend?
Rainer doesn't hear you, because you have placed yourself in
his killfile. That means that your chances of getting good,
informative answers to your questions in this newsgroup have
decreased.
From: Javier
Subject: Re: naming conventions for slot accessors
Date:
Message-ID: <ge5c2m$86g$1@aioe.org>
Raymond Wiker escribi�:
> Javier <······@askmyadress.com> writes:
>
>> Rainer Joswig escribi�:
>>
>>> Hmm, I think you are now in my killfile. Sorry about that...
>> So, do you sympathize with the insecurity of your friend?
>
> Rainer doesn't hear you, because you have placed yourself in
> his killfile. That means that your chances of getting good,
> informative answers to your questions in this newsgroup have
> decreased.
I insist on calling that insecurity of themselves, and afraid of
differences, which is intolerance.
I'm sure that if they could vote for seeing me disappear or something
worse like dye, they would do. But, with all my defects, I would never
desire such a thing for them.
If we were at war, this is the kind of people who denounce others to
take them to extermination camps. It seems like an exaggeration, but
remember that at critical moments, it is when the true personality comes
out. I can see deep into the rotten hearts of these people. A killfile
is just a sign.
Javier wrote:
> If we were at war, this is the kind of people who denounce others to
> take them to extermination camps. It seems like an exaggeration, but
> remember that at critical moments, it is when the true personality comes
> out. I can see deep into the rotten hearts of these people. A killfile
> is just a sign.
No, it's just a time management device.
--
__Pascal Bourguignon__
http://www.informatimago.com
From: Javier
Subject: Re: naming conventions for slot accessors
Date:
Message-ID: <ge5fqp$n0s$2@aioe.org>
Pascal Bourguignon escribi�:
> Javier wrote:
>> If we were at war, this is the kind of people who denounce others to
>> take them to extermination camps. It seems like an exaggeration, but
>> remember that at critical moments, it is when the true personality
>> comes out. I can see deep into the rotten hearts of these people. A
>> killfile is just a sign.
>
> No, it's just a time management device.
>
Are you saying that viewing the messages and ignoring them is
significantly slower than killfiling users?
Time is just an excuse.
On Oct 27, 11:12 pm, Pascal Bourguignon <····@informatimago.com>
wrote:
> Javier wrote:
> > If we were at war, this is the kind of people who denounce others to
> > take them to extermination camps. It seems like an exaggeration, but
> > remember that at critical moments, it is when the true personality comes
> > out. I can see deep into the rotten hearts of these people. A killfile
> > is just a sign.
>
> No, it's just a time management device.
And added to my collection of quotes.
bobi
http://www.penney.org/ggkiller.html
>
> --
> __Pascal Bourguignon__http://www.informatimago.com
On Oct 27, 7:10 pm, Javier <······@askmyadress.com> wrote:
> Rainer Joswig escribió:
>
> > Hmm, I think you are now in my killfile. Sorry about that...
>
> So, do you sympathize with the insecurity of your friend?
Plonk
From: Javier
Subject: Re: naming conventions for slot accessors
Date:
Message-ID: <ge7c72$iqd$1@aioe.org>
Slobodan Blazeski escribi�:
> On Oct 27, 7:10 pm, Javier <······@askmyadress.com> wrote:
>> Rainer Joswig escribi�:
>>
>>> Hmm, I think you are now in my killfile. Sorry about that...
>> So, do you sympathize with the insecurity of your friend?
> Plonk
What a boring nazi people.
They put the excuse of the "time". But what are you doing here if you
don't have time?
The fact is that you don't want to see me around here because I'm
different, I don't alienate with the official thinking (even if I still
prefer Lisp as I constantly say), you can't understant that, and act as
the intolerant guy that you are.
Because of your insecurity, you first give an answer with a desperate
attack, clearly with the intention of hurt, and then, when you feel that
I'm enough hurt, run away as the cowards you are.
Anyway, I'm not unhappy. This is good to avoid stupid answers from
insecure, highly alienated, and very closed minds.
There are people in c.l.l which still have dignity and are secure of
themselves. Those ones are the ones I prefer to discuss with.
On Oct 27, 5:30 pm, Javier <······@askmyadress.com> wrote:
> Rainer Joswig wrote:
> > Tamas was asking
>
> Tamas was not asking.
> He is measuring how much people is getting his attention.
> He is feeling insecure.
This group is for discussion of lisp. Though now and then we all make
exceptions, consistently staying offtopic isn't apreciated.
Please discuss your personal issues with Tamas or anybody else
elsewhere.
bobi
Tamas K Papp wrote:
> I would like to ask what naming conventions people use for slot accessors.
>
> Eg I have a class named foo, and I want an accessor for a slot named bar.
> The choices that occur to me are bar, bar-of, foo-bar, bar-of-foo. But
> maybe there are others.
>
> Sorry if the question is trivial, I would like to develop a good coding
> style.
Don't add the class name as prefix, or so. That reveals information
about the class hierarchy, especially for (direct or indirect)
subclasses, which may change over time.
Personally, I don't like the "-of" suffix, I think that's redundant.
Lisp doesn't read like English overall, so adding something like that
for small snippets of code seems weird to me. YMMV.
Pascal
--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
In article <··············@mid.individual.net>,
Tamas K Papp <······@gmail.com> wrote:
> I would like to ask what naming conventions people use for slot accessors.
>
> Eg I have a class named foo, and I want an accessor for a slot named bar.
> The choices that occur to me are bar, bar-of, foo-bar, bar-of-foo. But
> maybe there are others.
Usually I would use the name of the class, -, and the slot name.
So FOO-BAR. If I subclass FOO, I would use the name
of the base class - so usually leave it with FOO-BAR.
Sometimes I just use something like the slot name or
GET-BAR.
For some use it might be fine to use something like . between
the class and the rest:
So alternatives might be:
(maximum-weight my-airbus)
(get-maximum-weight my-airbus)
(plane-get-maximum-weight my-airbus)
(sailing-plane-get-maximum-weight my-plane)
(plane.maximum-weight my-airbus)
(sailing-plane.maximum-weight my-airbus)
I would choose something that is clearer for the
particular piece of source I'm about to write.
>
> Sorry if the question is trivial, I would like to develop a good coding
> style.
>
> Thank you,
>
> Tamas
--
http://lispm.dyndns.org/
On Oct 27, 4:22 pm, Rainer Joswig <······@lisp.de> wrote:
> In article <··············@mid.individual.net>,
> Tamas K Papp <······@gmail.com> wrote:
>
> > I would like to ask what naming conventions people use for slot accessors.
>
> > Eg I have a class named foo, and I want an accessor for a slot named bar.
> > The choices that occur to me are bar, bar-of, foo-bar, bar-of-foo. But
> > maybe there are others.
>
> Usually I would use the name of the class, -, and the slot name.
> So FOO-BAR. If I subclass FOO, I would use the name
> of the base class - so usually leave it with FOO-BAR.
> Sometimes I just use something like the slot name or
> GET-BAR.
>
> For some use it might be fine to use something like . between
> the class and the rest:
>
> So alternatives might be:
>
> (maximum-weight my-airbus)
>
> (get-maximum-weight my-airbus)
>
Isn't get a bit of a misnomer if you're naming a accessor, i.e.
SETFable?
-- Mikael
In article
<····································@40g2000prx.googlegroups.com>,
Mikael Jansson <··············@gmail.com> wrote:
> On Oct 27, 4:22�pm, Rainer Joswig <······@lisp.de> wrote:
> > In article <··············@mid.individual.net>,
> > �Tamas K Papp <······@gmail.com> wrote:
> >
> > > I would like to ask what naming conventions people use for slot accessors.
> >
> > > Eg I have a class named foo, and I want an accessor for a slot named bar.
> > > The choices that occur to me are bar, bar-of, foo-bar, bar-of-foo. �But
> > > maybe there are others.
> >
> > Usually I would use the name of the class, -, and the slot name.
> > So FOO-BAR. If I subclass FOO, I would use the name
> > of the base class - so usually leave it with FOO-BAR.
> > Sometimes I just use something like the slot name or
> > GET-BAR.
> >
> > For some use it might be fine to use something like . between
> > the class and the rest:
> >
> > So alternatives might be:
> >
> > (maximum-weight my-airbus)
> >
> > (get-maximum-weight my-airbus)
> >
>
> Isn't get a bit of a misnomer if you're naming a accessor, i.e.
> SETFable?
>
> -- Mikael
Not really. The idea is that you SETF a place. The form
(get-something from-here) is the place when used with SETF:
(setf (get-something from-here) new-value)
#'get-something is the reader
and #'(setf get-something) is the writer.
--
http://lispm.dyndns.org/
On 2008-10-28, Mikael Jansson <··············@gmail.com> wrote:
>> (get-maximum-weight my-airbus)
>>
>
> Isn't get a bit of a misnomer if you're naming a accessor, i.e.
> SETFable?
You mean like (setf (gethash ...) value)?
On Oct 27, 4:43 pm, Tamas K Papp <······@gmail.com> wrote:
> I would like to ask what naming conventions people use for slot accessors.
>
> Eg I have a class named foo, and I want an accessor for a slot named bar.
> The choices that occur to me are bar, bar-of, foo-bar, bar-of-foo. But
> maybe there are others.
Redshank [1] contains editing support for GET-FOO, FOO-OF, FOO-REF and
FOO, given a slot named %FOO or FOO.
[1] <http://www.foldr.org/~michaelw/lisp/redshank/>
On Oct 27, 4:43 pm, Tamas K Papp <······@gmail.com> wrote:
> I would like to ask what naming conventions people use for slot accessors.
>
> Eg I have a class named foo, and I want an accessor for a slot named bar.
> The choices that occur to me are bar, bar-of, foo-bar, bar-of-foo. But
> maybe there are others.
>
> Sorry if the question is trivial, I would like to develop a good coding
> style.
I would prefer bar, that's Franz coding standard , isn't it. The
problem is that very often I have a name clash with some other name.
So I usually use bar-slot for accessor and get-bar for reader. If one
of the slots gets prefixed or postifixed than I postifix and prefix
all of them.
Example for the most notorious name clash, happened to me at least 30
times.
(defclass timer()
((time :accessor time)))
Error: Non-generic function already exists with name TIME
This is only general advice, sometime naming slot with something that
makes more sense in the context of the problem is far better than
stick with the naming standard.
In the end it's up to you to decide what's better for yourself.
bobi
>
> Thank you,
>
> Tamas
On 2008-10-27, Tamas K Papp <······@gmail.com> wrote:
> I would like to ask what naming conventions people use for slot accessors.
>
> Eg I have a class named foo, and I want an accessor for a slot named bar.
> The choices that occur to me are bar, bar-of, foo-bar, bar-of-foo. But
> maybe there are others.
Anything with the class name in it will no longer seem like such a hot
idea when you specialize the same accessor to other classes (perhaps
ones derived from foo, or perhaps not).
Rememeber, an accessor is a generic function, and generic functions stand
apart from classes!
The ``of'' is kind of superfluous.
Consider that some people pronounce f(x) as ``f of x''. You can do the same:
write (grade student) but read it ``grade of student''.
Kaz Kylheku <········@gmail.com> wrote:
+---------------
| Rememeber, an accessor is a generic function, and generic functions
| stand apart from classes!
|
| The ``of'' is kind of superfluous.
|
| Consider that some people pronounce f(x) as ``f of x''. You can
| do the same: write (grade student) but read it ``grade of student''.
+---------------
One situation where "-of" (and similar suffixes) might be useful
is where the accessor name you'd naturally want to used is already
defined as a function inherited from the CL package [which generally
can't have methods added to them], and you'd rather not SHADOW it, e.g.:
(phase-of signal)
Such names can of course be used as accessors for unrelated classes, e.g.:'
(phase-of moon)
-Rob
-----
Rob Warnock <····@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
····@rpw3.org (Rob Warnock) writes:
> One situation where "-of" (and similar suffixes) might be useful
> is where the accessor name you'd naturally want to used is already
> defined as a function inherited from the CL package
But religiously having an "-of" suffix can be irritating as well. We
have heaps of automatically generated classes using that suffix.
Causes endless irritation whenever we want to access the slot called
"type".
...Peder...
--
I wish a new life awaited _me_ in some off-world colony.
Peder O. Klingenberg <·····@news.klingenberg.no> wrote:
+---------------
| ····@rpw3.org (Rob Warnock) writes:
| > One situation where "-of" (and similar suffixes) might be useful
| > is where the accessor name you'd naturally want to used is already
| > defined as a function inherited from the CL package
|
| But religiously having an "-of" suffix can be irritating as well.
| We have heaps of automatically generated classes using that suffix.
| Causes endless irritation whenever we want to access the slot called
| "type".
+---------------
Er... yes, well... I *did* say "might be useful"... ;-} ;-}
If you "have heaps of automatically generated classes", rather
than adding the "-OF" suffix it might be better to name all your
automatically generated classes and their slots in a separate
package [that *doesn't* USE the CL package!], and use "PKG:" prefixes
on all the class & slot references. If the package name is one
or two characters long, it needn't be less convenient than the
"-OF" suffix, e.g., O:MAX versus MAX-OF.
-Rob
-----
Rob Warnock <····@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
Tamas K Papp <······@gmail.com> writes:
> I would like to ask what naming conventions people use for slot accessors.
>
> Eg I have a class named foo, and I want an accessor for a slot named bar.
> The choices that occur to me are bar, bar-of, foo-bar, bar-of-foo. But
> maybe there are others.
My personal preference is for BAR, since that works nicely both for
reading and writing.
For just a reader, I would go with BAR or GET-BAR. I think that writing
(setf (get-bar x) y) is a bit odd, although it does parallel the usage
of the built-ins gethash, getf, etc.
I particularly don't like the idea of adding the class name, since it
seems like doing that obscures the abstraction level of the generic
function and inheritance by making you have to be aware of where the
(top level) method for the generic function is defined.
It is also counter to the notion that generic functions stand on their
own as objects separate from classes, and is thus unhelpful,
particularly for newer lisp programmers. It stands in the way of a
proper conceptualization of generic functions.
--
Thomas A. Russ, USC/Information Sciences Institute