Regarding the proposed Binray Literals Deprecation

Steven Schveighoffer schveiguy at gmail.com
Thu Sep 15 00:15:03 UTC 2022


On 9/14/22 3:34 PM, Walter Bright wrote:
> On 9/12/2022 7:48 AM, jmh530 wrote:
>> I don't recall anyone mentioning the removal of complex/imaginary 
>> numbers, but the issues are the same.

Not even close. Complex numbers were a set of 6 *types*. Binary literals 
are not even a type, but just another way to specify an integer. 
Removing complex numbers means you have to change the type of anything 
you were using it for to the library Complex type.

Removing binary literals would just mean you had to change literals to 
either hex, or some std.conv function. So in terms of burden, the 
complex number removal is far greater (for those who used it) than 
removing binary literals would be.

But in terms of language complexity, the *benefits* of removing complex 
numbers as a builtin are much much greater -- removing a slew of code 
generation, removing 6 types and the accompanying TypeInfo classes, 
(possibly) removing keywords, etc. The library also gets more 
complicated, because now it must replace that functionality. But with 
that cost, now you have a template that can be used with other things 
(like half-float).

Removing binary literals means removing 5 lines of code in the lexer. 
That's it. And you could add a std.conv.binary function (but probably 
not necessary).

Which is why it's so confusing that we are even having this debate. It's 
neither a monumental achievement, nor a monumental burden, it's just... 
annoying.

It would be like removing a dedicated clock in a car dashboard, because 
you could see the time in the touch-screen system corner. For saving a 
few pennies you piss off all the customers who *liked* that clock feature.

> I was surprised at the pretty much non-existent pushback on removing 
> them, even though it did carry with it the loss of the convenient syntax 
> for them.

I've never used complex numbers in code. Not even while playing around.

I've used binary literals, not a ton, but I have used them. And when I 
do use them, it's not because I like binary literals more than hex 
literals, or decimals, it's because for that specific case, they were a 
tad clearer.

I suspect many are in the same boat.

-Steve


More information about the Digitalmars-d mailing list