May 20, 2022
On Friday, 20 May 2022 at 03:06:37 UTC, Walter Bright wrote:
> On 5/19/2022 3:20 PM, deadalnix wrote:
>> That doesn't strike me as very convincing, because the compiler will sometime do the opposite too,
>
> I know this is technically possible, but have you ever seen this?

Yes, when you have a bunch of ternaries based on the same condition for instance.
May 20, 2022
On Friday, 20 May 2022 at 04:34:28 UTC, max haughton wrote:
> Despite this I do think it's still a huge failure of programming as an industry that it's a site like Compiler Explorer, or a flag like -vasm, actually needs to exist. This should be something much more deeply ingrained into our workflows, programming lags behind more serious forms of engineering when it comes to the correlation of what we think things do versus what they actually do.
>

$ watch gcc -S -O test.c -o -

;)
May 20, 2022
On Friday, 20 May 2022 at 09:16:24 UTC, Patrick Schluter wrote:
> On Friday, 20 May 2022 at 03:45:23 UTC, Walter Bright wrote:
>> On 5/19/2022 3:04 PM, deadalnix wrote:
>>> Tell me you are American without telling me you are American.
>>
>> I didn't know the Aussies and Brits used umlauts.
>
> The Brits Charlotte Brontë, Emily Brontë (and other members of the Brontë family), Noël Coward, Zoë Wanamaker, Zoë Ball, Emeli Sandé, John le Carré
>
> might want to have a word with you ;-)

The Brontë was originally Brunty, the father changed it to honour Nelson when he won some battle.

Zoë Wanamaker's is American. Or least was born in the US.

Emeli Sandé dad was from Zambia i think

John Le Carre is a pen name, his real name is David John Moore Cornwell

So often the source of the umluts in "british" names is not as straight forward as it may appear.

May 20, 2022

On Friday, 20 May 2022 at 04:34:28 UTC, max haughton wrote:

>

You still have "vector speed" in a sense. The emulated SIMD is still good it's just not optimal, as I was saying previously there are targets where even though you have (say) 256 bit registers, you actually might want to use 128 bit ones in some places because newer instructions tend to be emulated (in a sense) so might not actually be worth the port pressure inside the processor.

Yes, it is always better to allow for gradual optimization, going from generic target to increasingly specific as you need it. Case in point, WASM doesn't support SIMD, but the WASM engines (at least one of them) recognizes the output from LLVM builtin simd and reconstruct SIMD for the CPU from sequences of regular WASM instructions. So even if the target does not support SIMD you can get SIMD performance by using "generic" SIMD in the optimizer…

Things are getting much more complicated now for non-real time, just look at the Intel compiler that compiles to a mix of CPU/SIMD/GPU… That's where batch programming is heading…

May 20, 2022
On Friday, 20 May 2022 at 03:45:23 UTC, Walter Bright wrote:
> On 5/19/2022 3:04 PM, deadalnix wrote:
>> Tell me you are American without telling me you are American.
>
> I didn't know the Aussies and Brits used umlauts.

C'mon, even the NY times (?, used to) spells it "cöperate", and other repeated vowels contractions to single umlaut.
May 20, 2022
On Friday, 20 May 2022 at 11:54:47 UTC, Nicholas Wilson wrote:
> On Friday, 20 May 2022 at 03:45:23 UTC, Walter Bright wrote:
>>
>> I didn't know the Aussies and Brits used umlauts.
>
> C'mon, even the NY times (?, used to) spells it "cöperate", and other repeated vowels contractions to single umlaut.

Coöperate. (It's known as a diaeresis in English):
"The diaeresis diacritic indicates that two adjoining letters that would normally form a digraph and be pronounced as one sound, are instead to be read as separate vowels in two syllables. For example, in the spelling 'coöperate', the diaeresis reminds the reader that the word has four syllables co-op-er-ate, not three, '*coop-er-ate'. In British English this usage has been considered obsolete for many years, and in US English, although it persisted for longer, it is now considered archaic as well.[5] Nevertheless, it is still used by the US magazine The New Yorker.[6] In English language texts it is perhaps most familiar in the spellings 'naïve', 'Noël', and 'Chloë'"
Wikipedia
May 20, 2022

On 5/19/22 11:27 PM, Walter Bright wrote:

>

On 5/19/2022 5:06 PM, Steven Schveighoffer wrote:

>

I'd happily write that in exchange for not having this happen:

enum A : int { a }

Json j = A.a;
writeln(j); // false

I presume Json is a bool.

No, it's not. It's a JSON container. It can accept any type on opAssign that is a valid Json type (long, bool, string, double, or another Json).

It's actually this one.

>

And the bool is written as false.

The Json is written as false, because calling the overloaded opAssign turns into a bool, because bool is an integer, and the enum integer value fits in there. It's the compiler picking the bool overload that is surprising.

>

It implies all implicit conversions should be removed.

No, not at all. bool can implicitly convert to int, char is probably fine also (thinking about the OP of this thread, I'm actually coming around to realize, it's not that bad). I don't like integers converting to bool or char (or dchar, etc). That would stop this problem from happening. bool being treated as an integral type is suspect.

However, I'm also OK with bool not converting to int implicitly if that is necessary for the type system to be sane. Using the trivial b ? 1 : 0 conversion is not bad, and the compiler should recognize this pattern easily. I don't hold out hope for this to convince you though.

>

While that is a reasonable point of view, I used a language that did that (Wirth's Pascal) and found it annoying and unpleasant.

I actually am fine with, even happy with, implicit conversions that D has, except the bool and char implicit conversions from integers. I've used Swift where implicit conversions are verboten, and it's non-stop pain.

>

It's clear to me that there is no set of rules that will please everyone and is objectively better than the others. At some point it ceases to be useful to continue to debate it, as no resolution will satisfy everyone.

Of course. There's always a tradeoff. It comes down to, when does the language surprise you with a weird thing (like an overloaded function that takes bool accepting an int enum because it can fit)? If the choice is between those surprises and cast-inconvenience, what is worth more? There is no right answer.

-Steve

May 20, 2022

On Friday, 20 May 2022 at 16:02:15 UTC, Steven Schveighoffer wrote:

> >

It implies all implicit conversions should be removed.

No, not at all. bool can implicitly convert to int, char is probably fine also (thinking about the OP of this thread, I'm actually coming around to realize, it's not that bad). I don't like integers converting to bool or char (or dchar, etc). That would stop this problem from happening. bool being treated as an integral type is suspect.

In fact, it doesn't even require implicit conversion to be removed at all. Matching bool in this case really doesn't make sense, and even by the letter of the spec I'm not sure this is right.

Indeed, one of the constructor in an exact match, while the other is an implicit conversion match.

May 20, 2022

On Friday, 20 May 2022 at 16:56:50 UTC, deadalnix wrote:

>

On Friday, 20 May 2022 at 16:02:15 UTC, Steven Schveighoffer wrote:

> >

It implies all implicit conversions should be removed.

No, not at all. bool can implicitly convert to int, char is probably fine also (thinking about the OP of this thread, I'm actually coming around to realize, it's not that bad). I don't like integers converting to bool or char (or dchar, etc). That would stop this problem from happening. bool being treated as an integral type is suspect.

In fact, it doesn't even require implicit conversion to be removed at all. Matching bool in this case really doesn't make sense, and even by the letter of the spec I'm not sure this is right.

Indeed, one of the constructor in an exact match, while the other is an implicit conversion match.

In this example, both int and bool are implicit conversions, because the type of E.a is E, not int. So partial ordering is used to disambiguate, and the compiler (correctly) determines that the bool overload is more specialized than the int overload, because you can pass a bool argument to an int parameter but not the other way around.

As soon as you allow the E -> bool implicit conversion (via VRP), everything else follows.

May 20, 2022

On Friday, 20 May 2022 at 17:15:07 UTC, Paul Backus wrote:

>

In this example, both int and bool are implicit conversions, because the type of E.a is E, not int. So partial ordering is used to disambiguate, and the compiler (correctly) determines that the bool overload is more specialized than the int overload, because you can pass a bool argument to an int parameter but not the other way around.

As soon as you allow the E -> bool implicit conversion (via VRP), everything else follows.

Fair enough, because of the enum. You probably don't want to cast do bool via VRP.

But it also happens with integer literals, so clearly there is a problem.

The way I solved it on my end is to make all the opAssign templates and use specialization, in which case it doesn't go from int to bool.