[] literals again, what if..

Operator overloading usually requires you to name the operator you're overloading.

If I want 'a few T's alongside each other in memory' , I can use a tuple.

Why not a struct? Why do arrays even exist, if a struct looks exactly the same in memory? Surely there's a reason for this.

But you're looking at the wrong things anyway; the precedent here is not set by what Python or Haskell do; it is set by what Rust currently does. And Rust currently provides very different capabilities to tuples and arrays, and you're leaving "make up the difference" to what? I certainly don't use tuples when I want a [T; 100].

And the syntax isn't even the problem here: the problem is that you're wanting the language to provide you a nameless macro for the sole purpose of overwriting it to do whatever you like. That doesn't actually solve any problem! It's no better than asking for macros to exist. (They already do.) And they have names so you can refer to them them unambiguously.

That said, there already exist macros to do list comprehensions and generate sequences. The fact that you have to call them by name is not a downside. It's a necessary feature of pedagogy. Nobody wants to read code and try to guess what the stuff in square brackets do just because the language reserved it as a special DSL area (in addition to providing it multiple builtin meanings.)

"Oh, a square bracket! I wonder what it means? It could mean anything... And the good news is there's nothing to grep for except macro_rules. Oh, there's 12 different square bracket macros? Let me just learn macro_rules syntax and try to guess which one is being used here. Then maybe I'll be able to compile my Hello World and be a Rust master."

/r/rust Thread Parent