<div dir="ltr"><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, 19 Mar 2025 at 16:41, Meta via Digitalmars-d <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wednesday, 19 March 2025 at 06:05:24 UTC, Manu wrote:<br>
> On Wed, 19 Mar 2025 at 11:36, Meta via Digitalmars-d < <br>
> <a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>> wrote:<br>
>><br>
>> "This language is garbage collected, and they're _fucking <br>
>> ashamed_ of that!"<br>
>><br>
>> This guy is surprisingly perceptive and 100% accurate with his <br>
>> cutting observations hahaha.<br>
>><br>
><br>
> Why didn't his operator overloading experiment work?<br>
><br>
> struct S {<br>
>     int x;<br>
> }<br>
><br>
> // non-member opBinary<br>
> S opBinary(string s : "+")(S lh, S rh) {<br>
>     return S(lh.x + rh.x);<br>
> }<br>
><br>
> void main()<br>
> {<br>
>     S a, b;<br>
>     S s1 = a.opBinary!"+"(b); // <- UFCS works, as expected<br>
>     S s2 = a + b; // ERROR: doesn't work! why not? the rewrite <br>
> should work<br>
> via UFCS as above...<br>
> }<br>
<br>
I don't know the specific compiler details, but you make a good <br>
point that this _should_ work via UFCS. Probably the compiler <br>
first checks that it's a member function or something.<br>
<br>
> I can't imagine any good reason his experiment should have <br>
> failed. I would want this too when extern to a C lib; it hasn't <br>
> come up for me before, but if it did, I would log a bug <br>
> instantly.<br>
<br>
Yeah, I've always wanted free-standing operator overload <br>
functions in D, and I think the case for them has only gotten <br>
stronger with better C and C++ integration, and _especially_ with <br>
ImportC.<br>
<br>
His other main gripe was that the compiler rejects .h files, even <br>
though when he changed the extension to .c, it compiled and ran <br>
just fine. In the footnote section he actually downloads the <br>
source code and modifies it to compile .h files, and it's a <br>
surprisingly simple change. I wonder if there's a specific reason <br>
Walter didn't allow it.<br>
</blockquote><div><br></div><div>Literally every single person that has ever tried to use ImportC instantly complained that it doesn't import .h files. There's no reason not to merge his patch.</div><div></div><div>There's been lots of discussion about this, and it seems that Walter just has some arbitrary opinion that it shouldn't work.</div><div>What Walter wants you to do is write a one-line .c file somewhere in your source tree, with `#include "the_header.h"`; completely pointless exercise, and as this guy points out, it breaks the cool tech-demo and instantly converts every person that touches this from "WOW!" to "WTF?!"... def should fix this.</div></div></div>