* EARRAYSIZE
@ 2014-04-03 19:30 Eli Zaretskii
2014-04-03 19:34 ` EARRAYSIZE Daniel Colascione
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2014-04-03 19:30 UTC (permalink / raw)
To: Daniel Colascione; +Cc: emacs-devel
+/* Find number of elements in array */
+#define EARRAYSIZE(arr) (sizeof (arr) / sizeof ((arr)[0]))
I find the name of this macro to be unfortunate: what it returns is
not "size" in the accepted meaning of that word.
How about ALEN, or ARRAYELTS instead?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: EARRAYSIZE
2014-04-03 19:30 EARRAYSIZE Eli Zaretskii
@ 2014-04-03 19:34 ` Daniel Colascione
2014-04-03 20:10 ` EARRAYSIZE David Kastrup
0 siblings, 1 reply; 9+ messages in thread
From: Daniel Colascione @ 2014-04-03 19:34 UTC (permalink / raw)
To: Eli Zaretskii, Daniel Colascione; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 596 bytes --]
On 04/03/2014 12:30 PM, Eli Zaretskii wrote:
> +/* Find number of elements in array */
> +#define EARRAYSIZE(arr) (sizeof (arr) / sizeof ((arr)[0]))
>
> I find the name of this macro to be unfortunate: what it returns is
> not "size" in the accepted meaning of that word.
"Length", "size", and "count" are hopelessly confounded anyway. I'm not
attached to any particular term: I chose EARRAYSIZE because ARRAYSIZE
and ARRAY_SIZE hace been common in other projects I've worked on.
> How about ALEN, or ARRAYELTS instead?
Of these, I prefer ARRAYELTS. I'll change the name.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 901 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: EARRAYSIZE
2014-04-03 19:34 ` EARRAYSIZE Daniel Colascione
@ 2014-04-03 20:10 ` David Kastrup
2014-04-04 7:45 ` EARRAYSIZE Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: David Kastrup @ 2014-04-03 20:10 UTC (permalink / raw)
To: emacs-devel
Daniel Colascione <dancol@dancol.org> writes:
> On 04/03/2014 12:30 PM, Eli Zaretskii wrote:
>> +/* Find number of elements in array */
>> +#define EARRAYSIZE(arr) (sizeof (arr) / sizeof ((arr)[0]))
>>
>> I find the name of this macro to be unfortunate: what it returns is
>> not "size" in the accepted meaning of that word.
>
> "Length", "size", and "count" are hopelessly confounded anyway. I'm not
> attached to any particular term: I chose EARRAYSIZE because ARRAYSIZE
> and ARRAY_SIZE hace been common in other projects I've worked on.
>
>> How about ALEN, or ARRAYELTS instead?
>
> Of these, I prefer ARRAYELTS. I'll change the name.
Since Elisp has (length "333"), (length '(4 5 6)), and (length [4 5 3]),
for Emacs code LENGTH or LEN should be a reasonably straightforward
naming choice.
--
David Kastrup
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: EARRAYSIZE
2014-04-03 20:10 ` EARRAYSIZE David Kastrup
@ 2014-04-04 7:45 ` Eli Zaretskii
2014-04-04 8:04 ` EARRAYSIZE Paul Eggert
2014-04-04 8:06 ` EARRAYSIZE Dmitry Antipov
0 siblings, 2 replies; 9+ messages in thread
From: Eli Zaretskii @ 2014-04-04 7:45 UTC (permalink / raw)
To: David Kastrup; +Cc: emacs-devel
> From: David Kastrup <dak@gnu.org>
> Date: Thu, 03 Apr 2014 22:10:08 +0200
>
> Daniel Colascione <dancol@dancol.org> writes:
>
> > On 04/03/2014 12:30 PM, Eli Zaretskii wrote:
> >> +/* Find number of elements in array */
> >> +#define EARRAYSIZE(arr) (sizeof (arr) / sizeof ((arr)[0]))
> >>
> >> I find the name of this macro to be unfortunate: what it returns is
> >> not "size" in the accepted meaning of that word.
> >
> > "Length", "size", and "count" are hopelessly confounded anyway. I'm not
> > attached to any particular term: I chose EARRAYSIZE because ARRAYSIZE
> > and ARRAY_SIZE hace been common in other projects I've worked on.
> >
> >> How about ALEN, or ARRAYELTS instead?
> >
> > Of these, I prefer ARRAYELTS. I'll change the name.
>
> Since Elisp has (length "333"), (length '(4 5 6)), and (length [4 5 3]),
> for Emacs code LENGTH or LEN should be a reasonably straightforward
> naming choice.
I suggested ALEN because we have AREF and ASIZE. Maybe AELTS or
ALENGTH would be better.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: EARRAYSIZE
2014-04-04 7:45 ` EARRAYSIZE Eli Zaretskii
@ 2014-04-04 8:04 ` Paul Eggert
2014-04-04 8:14 ` EARRAYSIZE Eli Zaretskii
2014-04-04 8:41 ` EARRAYSIZE David Kastrup
2014-04-04 8:06 ` EARRAYSIZE Dmitry Antipov
1 sibling, 2 replies; 9+ messages in thread
From: Paul Eggert @ 2014-04-04 8:04 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
Eli Zaretskii wrote:
> I suggested ALEN because we have AREF and ASIZE. Maybe AELTS or
> ALENGTH would be better.
The most common name for this macro in other projects is probably
ARRAY_SIZE. That's what's in libiberty, for example. There are other
names (ARRAY_CARDINALITY, SIZEOF) but ARRAY_SIZE seems to be more popular.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: EARRAYSIZE
2014-04-04 7:45 ` EARRAYSIZE Eli Zaretskii
2014-04-04 8:04 ` EARRAYSIZE Paul Eggert
@ 2014-04-04 8:06 ` Dmitry Antipov
2014-04-04 8:15 ` EARRAYSIZE Eli Zaretskii
1 sibling, 1 reply; 9+ messages in thread
From: Dmitry Antipov @ 2014-04-04 8:06 UTC (permalink / raw)
To: Eli Zaretskii, David Kastrup; +Cc: emacs-devel
On 04/04/2014 11:45 AM, Eli Zaretskii wrote:
> I suggested ALEN because we have AREF and ASIZE. Maybe AELTS or
> ALENGTH would be better.
IMO this will confuse the reader because AREF and ASIZE are for Lisp_Objects and not for C arrays.
What about MS-style countof (http://msdn.microsoft.com/en-us/library/ms175773%28v=VS.100%29.aspx)?
Dmitry
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: EARRAYSIZE
2014-04-04 8:04 ` EARRAYSIZE Paul Eggert
@ 2014-04-04 8:14 ` Eli Zaretskii
2014-04-04 8:41 ` EARRAYSIZE David Kastrup
1 sibling, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2014-04-04 8:14 UTC (permalink / raw)
To: Paul Eggert; +Cc: emacs-devel
> Date: Fri, 04 Apr 2014 01:04:37 -0700
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: emacs-devel@gnu.org
>
> Eli Zaretskii wrote:
> > I suggested ALEN because we have AREF and ASIZE. Maybe AELTS or
> > ALENGTH would be better.
>
> The most common name for this macro in other projects is probably
> ARRAY_SIZE. That's what's in libiberty, for example. There are other
> names (ARRAY_CARDINALITY, SIZEOF) but ARRAY_SIZE seems to be more popular.
The SIZE part was what I originally objected: "size" in C is mostly
measured in bytes, which this one isn't. ARRAY_SIZE will be confusing
since we already have ASIZE.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: EARRAYSIZE
2014-04-04 8:06 ` EARRAYSIZE Dmitry Antipov
@ 2014-04-04 8:15 ` Eli Zaretskii
0 siblings, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2014-04-04 8:15 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: dak, emacs-devel
> Date: Fri, 04 Apr 2014 12:06:59 +0400
> From: Dmitry Antipov <dmantipov@yandex.ru>
> CC: emacs-devel@gnu.org
>
> On 04/04/2014 11:45 AM, Eli Zaretskii wrote:
>
> > I suggested ALEN because we have AREF and ASIZE. Maybe AELTS or
> > ALENGTH would be better.
>
> IMO this will confuse the reader because AREF and ASIZE are for Lisp_Objects and not for C arrays.
It could, yes.
> What about MS-style countof (http://msdn.microsoft.com/en-us/library/ms175773%28v=VS.100%29.aspx)?
I'd prefer a capitalized name, FWIW.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: EARRAYSIZE
2014-04-04 8:04 ` EARRAYSIZE Paul Eggert
2014-04-04 8:14 ` EARRAYSIZE Eli Zaretskii
@ 2014-04-04 8:41 ` David Kastrup
1 sibling, 0 replies; 9+ messages in thread
From: David Kastrup @ 2014-04-04 8:41 UTC (permalink / raw)
To: emacs-devel
Paul Eggert <eggert@cs.ucla.edu> writes:
> Eli Zaretskii wrote:
>> I suggested ALEN because we have AREF and ASIZE. Maybe AELTS or
>> ALENGTH would be better.
>
> The most common name for this macro in other projects is probably
> ARRAY_SIZE. That's what's in libiberty, for example. There are other
> names (ARRAY_CARDINALITY, SIZEOF) but ARRAY_SIZE seems to be more
> popular.
I see it in the Git codebase. I don't have the Linux source available
at the moment, but since it is involved with the same kind of crowd,
I consider it likely that they use it as well.
Even in Emacs, we have OBARRAY_SIZE defined as a member count rather
than a byte count (there is no other "ARRAY_SIZE" string in Emacs so
far).
Can't be that confusing to people.
--
David Kastrup
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-04-04 8:41 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-03 19:30 EARRAYSIZE Eli Zaretskii
2014-04-03 19:34 ` EARRAYSIZE Daniel Colascione
2014-04-03 20:10 ` EARRAYSIZE David Kastrup
2014-04-04 7:45 ` EARRAYSIZE Eli Zaretskii
2014-04-04 8:04 ` EARRAYSIZE Paul Eggert
2014-04-04 8:14 ` EARRAYSIZE Eli Zaretskii
2014-04-04 8:41 ` EARRAYSIZE David Kastrup
2014-04-04 8:06 ` EARRAYSIZE Dmitry Antipov
2014-04-04 8:15 ` EARRAYSIZE Eli Zaretskii
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.