handful and interval

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Sep 3 07:04:47 PDT 2012


On 9/3/12 3:53 PM, David Nadlinger wrote:
> On Monday, 3 September 2012 at 12:58:05 UTC, Andrei Alexandrescu wrote:
>> On 9/3/12 1:24 PM, David Nadlinger wrote:
>>> On Monday, 3 September 2012 at 11:20:27 UTC, Sven Torvinger wrote:
>>>> if (a.among("struct", "class", "union")) { ... }
>>>
>>> Wouldn't that rather be a.among!("struct", "class", "union")?
>>
>> I'd rather have a regular function (more generally applicable) that
>> the inliner takes care of.
>
> Where would the real difference to ["struct", "class",
> "union"].canFind(a) then?

Convenience. I find the other easier to write and read.

> A sufficiently smart compiler (tm) could
> optimize this to a efficient string "prefix switch statement" just as well…

I agree. But then http://c2.com/cgi/wiki?SufficientlySmartCompiler.


Andrei




More information about the Digitalmars-d mailing list