coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: strengthening ARRAY_CARDINALITY


From: Eric Blake
Subject: Re: strengthening ARRAY_CARDINALITY
Date: Fri, 20 Jan 2017 07:57:29 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0

On 01/19/2017 09:43 PM, Mike Frysinger wrote:
>>>>
>>>> gnulib module + extra checks + name change to ARRAY_SIZE sound good!
>>>> For a convenience feature, ARRAY_CARDINALITY is not a convenient name.
>>>
>>> yeah, "cardinality" sounds more like someone trying to show off their
>>> familiarity with the english language ;).  then again, my spell checker
>>> says it's not a word.
>>>
>>> linux, glibc, bootloaders, use ARRAY_SIZE.  types use "size" -- it's
>>> size_t, not cardinality_t.  this is the first time i've seen this name
>>> used myself.
>>
>> FYI, I chose "cardinality" over "size" quite deliberately: the former
>> refers to the number of things (typically in a set), and while "size"
>> may also refer to that number, it is often used to refer to the number
>> of bytes, which is usually a larger number.
> 
> a fair point.  i think in practice, people are used to the behavior
> of the macro so it's not an issue.  plus, sizeof already does this.

I like the name ARRAY_SIZE for its shorter length, but agree that
ARRAY_CARDINALITY is a bit more precise.  I also agree that since
projects like the kernel are using ARRAY_SIZE that there is now a
familiarity factor so that developers recognize it as being the number
of elements in the array (and not the size in bytes of the array).  It's
always possible to create both names (one as an alias forwarding to the
other), if you want to use a preferred spelling in a particular project.
 Which name would be better in a gnulib module?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]