food for thought - swift 5 released - bottom types, string interpolation, and stuff.
SeeWebsiteForEmail at erdani.org
Sat Apr 13 10:51:46 UTC 2019
On 4/13/19 3:04 AM, Julian wrote:
> On Saturday, 13 April 2019 at 04:40:08 UTC, Walter Bright wrote:
>> On 4/12/2019 9:15 PM, Nick Sabalausky (Abscissa) wrote:
>>> If for you, they're the same level of abstraction, that's great. For
>>> most, it isn't.
>> If you want to write a library of such, and contribute it to Dub, feel
>> free. If you find an audience for it, great.
> Done: https://code.dlang.org/packages/isodd
That we got to this kind of time investment is worrisome. There's so
many places where work needs to go, and this is at the very best of
Ironically isOdd and isEven were not approved for Swift - see
Implementation Notes. Instead, the only nontrivial function isMultiple
bool isMultiple(T)(T isThisMultiple, T of)
if (isThisMultiple == 0) return true;
if (of == 0) return false;
static if (T.min < 0)
if (isThisMultiple == T.min && of == -1) return true;
return isThisMultiple % of == 0;
Such a function has some subtleties and corner cases that even seasoned
programmers can get wrong. It can't be reasonably written as inlined
code. I find its presence in a language's standard library reasonable.
If isMultiple were proposed for Phobos, the argument should be centered
on frequency of use. It does happen that such queries appear with a
constant on the right (e.g. a power of two) but general queries for
arbitrary integers are rare.
More information about the Digitalmars-d