Dotted postfix match or non-dotted postfix match, in Rust and Scala - /g/ (#105933435) [Archived: 233 hours ago]

Anonymous
7/17/2025, 7:44:05 AM No.105933435
dot
dot
md5: f3f114e3fc83a6d3b9424daab3f70c36🔍
Rust proposal
https://github.com/rust-lang/rfcs/pull/3295

foo.bar().baz.match {
_ => {}
}


Scala optional dot
https://docs.scala-lang.org/scala3/book/control-structures.html#match-expressions-support-many-different-types-of-patterns

i match
case odd: Int if odd % 2 == 1 => "odd"
case even: Int if even % 2 == 0 => "even"
case _ => "not an integer"
match
case "even" => true
case _ => false


List(1, 2, 3)
.map(_ * 2)
.headOption
.match
case Some(value) => println(s"The head is: $value")
case None => println("The list is empty")


What is best, with or without dot?
Replies: >>105933519 >>105933687 >>105933917 >>105933974 >>105935178 >>105935937
Anonymous
7/17/2025, 7:46:58 AM No.105933451
canonicalwtf
canonicalwtf
md5: 70b2b50d417fb223085087ea6d96d7d8🔍
Why are Rustaceans like this?
Anonymous
7/17/2025, 7:58:00 AM No.105933519
>>105933435 (OP)
even as a UFCS enjoyer, i hate the idea.
It's going to facilitate unmaintainable jungles.
Anonymous
7/17/2025, 8:32:43 AM No.105933687
>>105933435 (OP)
Ehhh its kinda ok... ig

Feels more like a slop update that C# has been getting recently
Anonymous
7/17/2025, 8:46:35 AM No.105933785
>sytax sugar
>shuffling the words around and removing one single character
I get the feeling that these anti-features only exist to make people who keep up with brand new features feel smarter than people who just prefer to use a simpler approach. Like features are voted on based on how they make you feel, not how useful they actually are.
Replies: >>105933986 >>105936138
Anonymous
7/17/2025, 9:08:06 AM No.105933907
Just add the pipe operator already
Anonymous
7/17/2025, 9:10:33 AM No.105933917
>>105933435 (OP)
nice good for nothing make work retardation
Anonymous
7/17/2025, 9:22:54 AM No.105933974
>>105933435 (OP)
i saw that when it dropped (or maybe earlier, since it feels like it's been longer than 3 years).
it's a part of the larger "postfix keyword" pattern, with "await" serving as a floodgate opener (as mentioned in prior art).
it kind of makes sense. but then, if you do the same with "if", having the conditional before "if" is very awkward from a linguistical flow PoV, if you may.
but really, i'm getting old enough not to bother with syntax bikesheds anymore. i leave that to kids to endlessly debate.
Replies: >>105934154
Anonymous
7/17/2025, 9:25:28 AM No.105933986
tats
tats
md5: 64fc0743ccd6f92be05f8be63a8ea7e9🔍
>>105933785
Anything to get your name in the papers.
Replies: >>105934579
Anonymous
7/17/2025, 9:56:25 AM No.105934154
>>105933974
An if-expression in Rust is in reality a ternary operator when the else-branch is included.

if (condition) { (branch1) } [else { (branch2) } ]


Three operands (condition, branch1, branch2). Two operator tokens ignoring parenthesis ('if', 'else'). 'if' is prefix, 'else' is infix.

Making 'if' infix would look strange.

A popular opinion in the discussion is that if Rust had started out with only dotted postfix for 'match', it would be good. But, having both prefix and postfix (and one of them dotted) 'match', is somewhat bloated and not worth it, according to that opinion.

Also, Scala calls its syntax for 'match' infix instead of postfix. And Scala is right. How did Rustaceans confuse infix for postfix?
Anonymous
7/17/2025, 11:22:29 AM No.105934579
>>105933986
Is that why a lot of Rust language development discussion moved to Zulip, and some heavily debated issues on Github were kept open but locked for new comments?

Who moderates the Rust Zulip forums?
Anonymous
7/17/2025, 12:44:29 PM No.105935056
https://materialize.com/blog/rust-concurrency-bug-unbounded-channels/
https://media.defense.gov/2022/Nov/10/2003112742/-1/-1/0/CSI_SOFTWARE_MEMORY_SAFETY.PDF
https://bpb-us-e1.wpmucdn.com/sites.gatech.edu/dist/a/2878/files/2022/10/OSSI-Final-Report-3.pdf
https://archive.ph/uLiWX
https://archive.ph/rESxe
https://lkml.org/lkml/2025/2/6/1292
Replies: >>105935101
Anonymous
7/17/2025, 12:45:55 PM No.105935063
Literally every rust coder has agp
Anonymous
7/17/2025, 12:51:05 PM No.105935101
>>105935056
If rust is safe why is there a double free?
Replies: >>105935122
Anonymous
7/17/2025, 12:54:37 PM No.105935122
>>105935101
Our findings underscore the critical importance of exhaustive CI, robust diagnostic tooling (e.g., ASAN, Valgrind, Miri), and adversarial stress testing.

In other words use C++ and trannyrust
Anonymous
7/17/2025, 12:59:01 PM No.105935156
in C# this is just
foo.bar().baz switch {
_ => default
}
Anonymous
7/17/2025, 1:03:14 PM No.105935178
>>105933435 (OP)
this is the stupidest shit i've seen all day it's literally the exact same amount of characters and the bottom one is objectively more readable
Anonymous
7/17/2025, 2:45:02 PM No.105935937
>>105933435 (OP)
I don't know, I think I don't like this.

However, it would be interesting to have a language designed all around such postfix notation.
Anonymous
7/17/2025, 3:15:44 PM No.105936138
>>105933785
>>shuffling the words around and removing one single character
You forgot that they are also adding one character. All it does is remove the necessity of the spacebar for the same amount of characters.
Anonymous
7/17/2025, 5:16:11 PM No.105937162
How is that more readable?
Replies: >>105937268
Anonymous
7/17/2025, 5:27:19 PM No.105937268
>>105937162
It makes more sense in context of long dot chains that are frequent in Rust.
So instead of
let temp1 = await foo.bar().baz();
let temp2 = temp1.bar();
let temp3 = match temp2 {
0..8 => foo2
x => x.bak()
}
let result = await temp3.bat()

You could do
let result =
foo
.bar()
.baz()
.await
.bar()
.match {
0..8 => foo2
x => x.bak()
}
.bat()
.await;