handful and interval

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Sep 2 08:17:29 PDT 2012


On 9/2/12 4:51 PM, Jacob Carlborg wrote:
> On 2012-09-02 16:22, Andrei Alexandrescu wrote:
>> I'd like to add a simple function to std called "handful". It would
>> return a small, read-only set of which main facility is membership test:
>>
>> string a = "class";
>> if (a in handful("struct", "class", "union"))
>> {
>> ...
>> }
>>
>> Would it be generally useful, and if so what module does it belong to?
>
> I really don't like the name "handful". What would be the difference
> compared to a regular set container? To me it sounds like we should have
> a standard set container in Phobos, std.container.set.

The difference is in scale and primitives offered. Handful would be 
read-only and limited to the size of its initializer. Its representation 
would take advantage of that.

Anyhow, I think among would be a simpler solution for this all.


Andrei




More information about the Digitalmars-d mailing list