News for hackers. Stuff that matters.
Re:Stages of Denial by turbinerneiter on Tuesday August 10, 2021 @02:15AM (#28125626)
I recently started using rust-analyzer with vscode.

One common sight is this:

thing

  .stuff()  

  .other()  

  .whatevs()

Each of the calls returns a different type. Rust-analyzer displays the return type of each call to the right of it.

I imagine something similar could reconcile the benefits of terseness with readability and discoverabilty.

The blog post already has the prototype:

+ / ! 100

plus reduce range 100

Imagine the second line being added in by your ide in a light gray.

Re:Stages of Denial by still_grokking on Tuesday August 10, 2021 @05:24AM (#28126720)
But why not just write

  (0 to 99).sum
That's not much longer, and quite readable even for the uninitiated. (It's a Scala expression, so not made up).
Re:Stages of Denial by nextaccountic on Tuesday August 10, 2021 @06:30AM (#28127112)
in rust you would write (0 .. 99).sum() for range not including 99

or (0 ..= 99).sum() for range including the 99

which makes me think that i don't know how to read (0 to 99) unless i learn whether it's exclusive or inclusive (but at least it's googlable, unlike a random looking operator)

Re:Stages of Denial by still_grokking on Tuesday August 10, 2021 @09:04AM (#28128298)
The "to" method on an Int creates an inclusive Range.

There is also an "until" method which would create the noninclusive Range (which would be actually closer to the original code as it would be "0 until 100").

The Rust syntax is not better. Maybe you could come up what means what if you see it in comparison (this would also work maybe for the Scala code).

The K example has even two implicit assumptions: It's an noninclusive range starting at zero. (They write on the Wikipedia page where I looked this up, as I don't know K, that the range is over "nonnegative integers" lower than the given one. But "nonnegative integers" means usually, but not always, the natural numbers, so zero not included; this makes it even more inconclusive than the Rust or Scala code snippet, imho. I had to look on examples to find out whether zero is included or not in "!").

Re:Stages of Denial by nickray on Tuesday August 10, 2021 @09:24AM (#28128516)
Nonnegative always includes zero, unless the author had muddled thinking themselves. Since positive is >0 and negative is <0, their negations are nonpositive for <=0 and nonnegative for >=0.
Re:Stages of Denial by still_grokking on Tuesday August 10, 2021 @09:44AM (#28128747)
OH! That's of course right.

I wasn't precise enough. The Wikipedia page talks actually about "positive" integers, and I transformed this in my head to what should be written there.

Original quote:

> !x enumerate the positive integers less than x.

Re:Stages of Denial by goto11 on Tuesday August 10, 2021 @03:26AM (#28126020)
> Imagine the second line being added in by your ide in a light gray.

So what would be the benefit compared to just writing `plus reduce range 100`?

Re:Stages of Denial by Firadeoclus on Tuesday August 10, 2021 @01:40PM (#28131823)
The benefit would be it being optional. You only need it while learning the language, whereas once you're familiar with the notation the terseness becomes a feature.

Of course once you've come up with clear names for each symbol you could do the opposite, let the IDE turn `plus reduce range 100` into `+/!100`. But as long as IDEs are still glorified text editors and devs care about the representation that gets stored on disk I would argue making the terse notation the default is the right choice.

Re:Stages of Denial by turbinerneiter on Tuesday August 10, 2021 @01:29PM (#28131705)
I'm not sure, but imagine once you learned it you parse the sentence like a word. Like some of the Asian alphabets?
Re:Stages of Denial by DanielR31D on Tuesday August 10, 2021 @04:22AM (#28126361)
less keystrokes
Re:Stages of Denial by gjulianm on Tuesday August 10, 2021 @09:03AM (#28128290)
It's a very weak benefit. I don't know about you but most of my time programming is spent thinking about the program, not writing it. In fact, this would only increase the time I need to think about how to write things (what was the symbol for reduce again?)
Re:Stages of Denial by leprechaun1066 on Tuesday August 10, 2021 @05:08AM (#28126634)
And easier to spot patterns in the source files. Whether someone finds that beneficial or not is subjective I guess, but I think it's useful to be able to immediately recognise what something like +/! is doing whenever you see it in source after using it once or twice.