Re: [PATCH 1/5] hashmap: add enum for hashmap free_entries option

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

 



Karsten Blees <karsten.blees@xxxxxxxxx> writes:

> Am 10.06.2014 12:17, schrieb Heiko Voigt:
>> The intention of Jonathans critique here[1] was that you do not see what
>> this parameter does on the callsite. I.e.:
>> 
>> 	hashmap_free(&map, 1);
>> 
>> compared to
>> 
>> 	hashmap_free(&map, HASHMAP_FREE_ENTRIES);
>> 
>> A boolean basically transfers the same information and would not help
>> the reader here.
>> 
>> Cheers Heiko
>> 
>> [1] http://article.gmane.org/gmane.comp.version-control.git/243917
>> 
>
> There are languages where you can have e.g. 'hashmap_free(...,
> free_entries: true)'. In C, however, you do not see what a
> parameter does at the call site. This is a general language
> feature, reducing redundancy and keeping it short and concise. IMO
> there's no reason to treat boolean parameters differently.

But given that you are writing in C, is any of that relevant?  We do
want to keep our call-sites readable and understandable, and 1 or
true would not help, unless (1) you are the one who wrote the
function and know that 1 means free the entries, or (2) the API is
so widely used and everybody knows what 1 means free the entries.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]