food for thought - swift 5 released - bottom types, string interpolation, and stuff.
Timon Gehr
timon.gehr at gmx.ch
Fri Apr 12 13:31:39 UTC 2019
On 12.04.19 04:13, Walter Bright wrote:
> On 4/11/2019 6:24 PM, Timon Gehr wrote:
>>> bool isOdd(int i) { return i & 1; }
>>>
>>> Filling the standard library with trivia is not a good idea.
>>
>> Yes, if it is used often enough across many projects, adding functions
>> with a simple implementation can be a very good idea. The main point
>> is to standardize the function name and avoid duplicated equivalent
>> code in everyone's personal util libraries.
>
> That would make sense if there was some application-specific higher
> level meaning to oddness, such as maybe the low bit being used as a
> flag. But there isn't when it is named "isOdd".
> ...
Parity is an important property of integers. Not all integer data types
support efficient bitwise arithmetic.
>
>>> Not knowing about a common operator is not a reason to add library
>>> functions.
>> No, but there can be other reasons.
>
> That was the reason given. I'm open to hearing a better one.
std/range/primitives.d
---
@property ref T front(T)(T[] a) @safe pure nothrow @nogc
if (!isNarrowString!(T[]) && !is(T[] == void[]))
{
assert(a.length, "Attempting to fetch the front of an empty array
of " ~ T.stringof);
return a[0];
}
--
"Who's the clown who's put that there? Don't D programmers know about
the array index operator?!"
More information about the Digitalmars-d
mailing list