I love coding in Rust so far, but did they really have to use this for macros?
This is not a thread about criticizing the current syntax, but what would have been better for you?
Post your alternatives you would have used in your own Rust version!
Regrettably, I think these all would be breaking changes, except maybe the last one.
Which letter-like characters aren't valid as the start of an identifier?
@v1yd0r67gk30, can you add an option for println!()?
Your poll suffers from a logical fallacy called "begging the question" - basically, it assumes that people don't like the println!() syntax so it only contains options that support that assumption.
Therefore, anyone reading the results will come to the conclusion that "the majority of Rust programmers would prefer @println() for macros"[1], when actually the vast majority of Rust programmers might think all proposed alternatives are worse than the status quo... but we don't know that because those people never get the option.
or println|() or :println(): or whatever other syntax wins. ↩︎
We have the remainder operator a % b! But ~ isn't used indeed. AFAIK it used to be some pointer type ~T in old pre-1.0 versions. I'm not certain whether that was the Box-like or the Arc-like one.
In Ruby, an exclamation mark at the end of a method name indicates a dangerous method, see documentation on method names in Ruby. Often, this means that a method modifies its receiver.
In Rust we always know when something can get modified because it requires a mutable reference (except for inner mutability).
Nonetheless, anything with an exclamation mark might be considered "dangerous" in Rust because it (i.e. macros) can change syntax unexpectedly or do things which normal calls couldn't do (e.g. return from a function).
What I want to know is why programming languages chose & for reference like things when & when represents the conjunction "and". How daft is that? It's always niggled me.
Then. we have the misuse of @in programming languages. Also a niggle.
I'm sort of happy with ! for macros. As in i_am_not_a_function!().
That's perfectly valid C++ function (and all modern compilers agree). And yes, num here is reference to int.
Thankfully Rust haven't picked up that particular peculiarity of C++ (and all senior developers I personally know had no idea that it's valid C++ till I showed that to them and explained how it works).
I'm fine with ! for macros but I wish Rust used Python's not, and, and or to avoid having !matches!(a, A) and similar overload with references/AND and closures/OR.