September 14, 2022

On Tuesday, 13 September 2022 at 20:08:02 UTC, Don Allen wrote:

>

I'm aware of those arguments. It wasn't at all clear how your terse comment related to them.

Sorry for that. I all too often assume people can read my mind.

>

Yes, if you are concerned with individual bits, then binary representation is obviously more natural than hex (or octal or decimal). But depending on your purpose, other representations may be more natural than 0b. I gave an example in a previous post and therefore won't repeat.

Yes, nobody is arguing otherwise, and we'd better go back to the point of the discussion. Walter wants to remove binary literals on these false assumptions:

  1. Nobody uses binary literals.
  2. Hex is always more readable than binary.
  3. Removing binary literals would simplify the language and compiler.

Let's stop him.

September 14, 2022
On Wednesday, 14 September 2022 at 05:58:53 UTC, Walter Bright wrote:
> On 9/13/2022 7:56 PM, Steven Schveighoffer wrote:
>> But it doesn't disprove the fact that *sometimes*, hex digits aren't as clear.
>
> Does sometimes justify a language feature, when there are other ways?
>
> People often complain that D has too many features. What features would you say are not worth it?

Classes, private, immutable, udas, attributes, contracts, dmd having optimizations(everyone who needs them will use ldc), expectations, betterc, playing with c++ and objective c
September 14, 2022

On Wednesday, 14 September 2022 at 05:58:53 UTC, Walter Bright wrote:

>

People often complain that D has too many features. What features would you say are not worth it?

Hex/binary/octal literals are perceived as a single feature. Removing some of them would actually complicate the language by introducing an inconsistency into that feature (see Timon's post).

What really simplifies a language is removal of inconsistencies and special cases, and also improvement of interactions between features. For example, we are now struggling with the impossibility to perfectly forward a variadic function call:

void bar(short a)
{
}

void foo(alias target, A...)(auto ref A args)
{
    target(forward!args);
}

void main()
{
    bar(1); // ok
    foo!bar(1); // error because args[0] is inferred as int
}

We now have to force superfluous casts on the API user, or resort to all kinds of metaprogramming hackery, or go back to Java-style monkey-coding.

September 14, 2022

On Tuesday, 13 September 2022 at 20:41:53 UTC, Ali Çehreli wrote:

>

On 9/11/22 16:00, Steven Schveighoffer wrote:

>

I'm actually quite proud of the bit shifting code, I tried to
find the
most efficient/clever mechanism to test for a straight given
a bitfield.
Once I thought of it, it was simple to implement and
understand:

https://github.com/schveiguy/poker/blob/6f70cf7ca74e19e78b470f81640a3ce34a95d0d3/source/poker/hand.d#L245-L256

That's very clever! :)

core.bitop.popcnt(check) == 4 would be simpler and most modern CPU's have an instruction for that.

September 14, 2022
On Wednesday, 14 September 2022 at 05:58:53 UTC, Walter Bright wrote:
> On 9/13/2022 7:56 PM, Steven Schveighoffer wrote:
>> But it doesn't disprove the fact that *sometimes*, hex digits aren't as clear.
>
> Does sometimes justify a language feature, when there are other ways?

Yes, definitely. Why use `foreach` sometimes when you have `for`, `while` and even `goto` to do it in another way?

>
> People often complain that D has too many features. What features would you say are not worth it?

Clumsy Phobos solutions to replace simple elegant consistent language syntax.
For complex numbers, the language complexity it involves compared to a library solution is probably justified. For the `0b` literals definitively not.


September 14, 2022

On Tuesday, 13 September 2022 at 21:05:23 UTC, IGotD- wrote:

>

I can't believe this discussion. Initial motivation was to save a few lines of code, now the discussion more or less like what color of your underwear that is the best.

I have the same feeling. We’re forced to defend something that so obviously should not need defense.

September 14, 2022

On Wednesday, 14 September 2022 at 05:58:53 UTC, Walter Bright wrote:

>

On 9/13/2022 7:56 PM, Steven Schveighoffer wrote:

>

But it doesn't disprove the fact that sometimes, hex digits aren't as clear.

Does sometimes justify a language feature, when there are other ways?

It’s change not features that must be justified. If a feature is already properly implemented and available for years, removing it must be justified.

It is trivial to justify removal of a feature that was promised by the spec, but never implemented (e.g. cent). It is easy to justify changes on a feature (including removal) that was inconsistent or never worked correctly (I’m no expert, but I remember shared being named in this context).

>

People often complain that D has too many features. What features would you say are not worth it?

Any feature that works as intended is probably used or even relied upon by someone.

I cannot give you a list, but a criterion. The ones that are worth removing are those that have not worked correctly for years. Apparently, no fix is being found and/or nobody cares enough. It makes sense removing those.

September 14, 2022
On Wednesday, 14 September 2022 at 05:58:53 UTC, Walter Bright wrote:
> On 9/13/2022 7:56 PM, Steven Schveighoffer wrote:
>> But it doesn't disprove the fact that *sometimes*, hex digits aren't as clear.
>
> Does sometimes justify a language feature, when there are other ways?
>
> People often complain that D has too many features. What features would you say are not worth it?

This is an example of what I mention at this link below (and in the thread that led to that post).
https://forum.dlang.org/post/jslyncewynqaefohloog@forum.dlang.org
You argue about compiler-complexity AND user-complexity on this topic. Sometimes one, sometimes the other. It's not always consistent and some can find it confusing.
September 14, 2022
On 9/14/22 01:43, Patrick Schluter wrote:

> `core.bitop.popcnt(check) == 4` would be simpler and most modern CPU's
> have an instruction for that.

That will give total number of bits set. Steve's function determines whether 5 neighboring bits are set consecutively, anywhere in the "register".

And that 4 is a red herring that made me think I found a bug. No, the function finds 5 consecutive bits set by 4 shifts. :)

Ali

September 14, 2022
On Tuesday, 13 September 2022 at 18:50:01 UTC, Walter Bright wrote:
> On 9/13/2022 11:07 AM, wjoe wrote:
>> Besides, I've had to use the tip of a pencil to count Fs in hex values.
>
> So have I. But I have only 1/4 as many digits to count, and don't need to if there are 6 or fewer digits.

Neither do you if you have only 8 bit especially if you group them with underscores.
Even 16 bit would be easy to read like that.

ubyte foo = 0b0010_1011;
ubyte bar = 0x2b;

Task: flip bit 3.

foo: 1. overwrite bit 3 with a 0.

bar: 1. convert 2b to binary
     2. flip the bit
     3. convert that back to hex.

foo 1 step
bar 3 steps

Checking which bits are set ?

foo - it's obvious at a glance.
bar - 2 steps: convert to binary -> read the bit

which is user friendlier ?