April 11, 2019
On 4/11/2019 2:21 PM, Dennis wrote:
> I don't get it. What's shocking about it, that people often need to know the parity of a number or that people aren't born with the knowledge that the % operator can be used for that?

  bool isOdd(int i) { return i & 1; }

Filling the standard library with trivia is not a good idea. Not knowing about a common operator is not a reason to add library functions.
April 11, 2019
On Thursday, 11 April 2019 at 21:21:16 UTC, Dennis wrote:
> On Thursday, 11 April 2019 at 20:32:33 UTC, mate wrote:
>> On Wednesday, 10 April 2019 at 21:39:36 UTC, Walter Bright wrote:
>>> On 4/8/2019 11:23 PM, aliak wrote:
>>>> [2] https://github.com/apple/swift-evolution/blob/master/proposals/0225-binaryinteger-iseven-isodd-ismultiple.md
>>>
>>>
>>> "Stack Overflow questions: c - How do I check if an integer is even or odd? 300,000+ views java - Check whether number is even or odd 350,000+ views Check if a number is odd or even in python 140,000+ views"
>>>
>>> Huh.
>>
>> Shocking indeed.
>
> I don't get it. What's shocking about it, that people often need to know the parity of a number or that people aren't born with the knowledge that the % operator can be used for that?

Exactly, but funny how you attacked me for calling a person ignorant yet say the same thing. We are all born ignorant. There was a time when everyone in this forum and all the "greatest" programmers didn't even know what an even number was.

We are all born in to ignorance and as we learn we add to our knowledge base. There are 7B people on this planet, if 1/10 of those are children and 1/10 of those are kids that are into programming and if we further drop it down 1/10*1/100 just for the hell of it, that is 70k.

Also, I doubt views are a good estimate of what is related to how much people know something.

The shocking fact is, is that all human beings know squat in the absolute since. We are all morons... some of us, well, very few, just realize that.

You can bet there is a musician somewhere in some forum saying how shocking it is that "What is a tritone" got 100k views and thinks everyone else in the world is a moron for not knowing that... and he's right, he just forgets to include himself. Or some chemist and talking about some basic chemistry fact... or whatever.

The problem with knowledge/intelligence is that those who have the least of it think they have the most.

April 11, 2019
...and my point was that knowledge/intelligence is learned. So people that don't know something or understand something is due to them not having learned it. It has nothing to do with some innate abilities(which is just BS perpetrated on us by other ignorant people who use things like genetics to explain why some people are ignorant and others are "geniuses"(of which most "geniuses" are morons at everything else)).





April 11, 2019
On Tuesday, 9 April 2019 at 06:23:26 UTC, aliak wrote:
>

> [0] https://swift.org/blog/swift-5-released/

Still, no (official at least) Windows support. Don't know if that is because there is no interest in broadening the usage or if it is considered too difficult or not worth the effort to do so.


April 11, 2019
On Thursday, 11 April 2019 at 23:03:00 UTC, Walter Bright wrote:

>   bool isOdd(int i) { return i & 1; }
>
> Filling the standard library with trivia is not a good idea. Not knowing about a common operator is not a reason to add library functions.

For me it's not about knowledge of the operator.  It's about conveying the reason for why that operation is being done.  For example, if you do `i & 1` are you checking for even or odd, or are you masking off irrelevant bits.  Creating functions like `isOdd` or `GetLeastSignificantBit` help convey intent without having to supplement code with comments.

Mike
April 12, 2019
On 12.04.19 01:03, Walter Bright wrote:
> On 4/11/2019 2:21 PM, Dennis wrote:
>> I don't get it. What's shocking about it, that people often need to know the parity of a number or that people aren't born with the knowledge that the % operator can be used for that?
> 
>    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.

> Not knowing about a common operator is not a reason to add library functions.

No, but there can be other reasons.
April 11, 2019
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".


>> 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.
April 11, 2019
On 4/11/2019 4:24 PM, Mike Franklin wrote:
> On Thursday, 11 April 2019 at 23:03:00 UTC, Walter Bright wrote:
> 
>>   bool isOdd(int i) { return i & 1; }
>>
>> Filling the standard library with trivia is not a good idea. Not knowing about a common operator is not a reason to add library functions.
> 
> For me it's not about knowledge of the operator.

That was the reason given for it.


> It's about conveying the reason for why that operation is being done.  For example, if you do `i & 1` are you checking for even or odd, or are you masking off irrelevant bits.

If you're masking bits, you should call it:

   return i & MyBitFlag;


> Creating functions like `isOdd` or `GetLeastSignificantBit` help convey intent without having to supplement code with comments.

No they don't. For example, if I saw "isOdd" in code, I'd wonder what the heck that was doing. I'd go look up its documentation, implementation, test cases, etc., find out "oh, it's just doing the obvious thing", and be annoyed at the waste of my time.

It wastes the time of everyone reading the code, documenting the function, and the QA staff. It hides the useful stuff in the library when it's alongside a morass of junk like this. It wastes the time of the poor shlub perusing the library. It makes the library look like a bunch of filler rather than useful stuff.

I don't believe anybody's code is so well-documented that this is all that's left. Meaning you're wasting your time documenting the wrong things.

I call this sort of stuff the "Illusion of Progress".
April 11, 2019
On 4/11/19 10:29 PM, Walter Bright wrote:
>> Creating functions like `isOdd` or `GetLeastSignificantBit` help convey intent without having to supplement code with comments.
> 
> No they don't. For example, if I saw "isOdd" in code, I'd wonder what the heck that was doing. I'd go look up its documentation, implementation, test cases, etc., find out "oh, it's just doing the obvious thing", and be annoyed at the waste of my time.
> 
> It wastes the time of everyone reading the code, documenting the function, and the QA staff. It hides the useful stuff in the library when it's alongside a morass of junk like this. It wastes the time of the poor shlub perusing the library. It makes the library look like a bunch of filler rather than useful stuff.
> 
> I don't believe anybody's code is so well-documented that this is all that's left. Meaning you're wasting your time documenting the wrong things.
> 
> I call this sort of stuff the "Illusion of Progress".

Very well put.

Funny tidbit: "% 2 == 0 appears 63 times in the Apple/Swift repository." That argument is quoted straight from the proposal. Of course, they conveniently neglect to mention that the project has over 2.4 MILLION lines of code. That's 0.002625% or better put 26 ppm. IF there's an argument in there, it must be of a homeopathic nature.

The day we talk ourselves into entering the ilk of isOdd and isEven into the standard library someone please slip me that misericorde.
April 12, 2019
On Friday, 12 April 2019 at 03:04:19 UTC, Andrei Alexandrescu wrote:
> The day we talk ourselves into entering the ilk of isOdd and isEven into the standard library someone please slip me that misericorde.

Just for fun:

https://old.reddit.com/r/programming/comments/886zji/why_has_there_been_nearly_3_million_installs_of/

https://news.ycombinator.com/item?id=16901188

Matheus.