food for thought - swift 5 released - bottom types, string interpolation, and stuff.

Julian julian.fondren at gmail.com
Thu Apr 11 22:44:04 UTC 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?

The perspective of the shocked is: these people are asking if a
value has a particular property. Rather than *thinking* about the
property and the tools at hand, and connecting them to arrive at a
solution, they're just groping for a language valueHasProperty
feature--and are given it, when it's lacking. This obviously can't
scale to real software, though. There's no expectation that Swift
learners will put Applications.Games.SimilarTo(Games.AngryBirds,
0.95); in a file and compile that and then ship the result.

And it seems to be obvious that no thought at all happened, 
because
oddness is a really easy property of a number to test. Geez, it's
not like we're expecting people to have memorized their hex and
octal digits.

But, I'd say that's not so obvious. On the simplest stuff
especially, people are not satisfied with only coming up with a
solution. They want a solution that can't be criticized. Suppose
someone was learning D, and when they couldn't remember writeln
offhand hand, they wrote something like

   foreach (char; str) {
       asm {
           // hardcoded Linux write() syscall of single character
       }
   }

Would you reaction to this code be:

a) Wow! It's great how you filled your D library gap with so much
other knowledge, to arrive at a functional solution.

b) Criticism #1: this will be obnoxiously slow.
    ...
    Criticism #40: I hate you.

If a language *does* have a valueHasProperty built-in, people want
to know so that they can use it.


More information about the Digitalmars-d mailing list