3 ms·
> I feel like a smarter compiler could have a friendlier asm syntax, similar to the one used by FreeBASIC[1]. Feel free to propose a better syntax, then. This
by zozbot234 6y ago
> I feel like a smarter compiler could have a friendlier asm syntax, similar to the one used by FreeBASIC[1].
Feel free to propose a better syntax, then. This feature is not yet part of Stable Rust, so syntax improvements are very much possible.
The FreeBASIC syntax seems problematic though, since it would require architecture-specific smarts in the compiler and make it hard to port it to different architectures or add support for newer asm features. It might be better to have these additional features as separate tooling or crates, that might even wrap the asm! syntax itself via proc macros.
- livre 6y agoSadly I think Rust's way is the best one in the long term even if it's not very user friendly. There are a lot of problems with the FreeBASIC syntax, my comment was mostly wishful thinking. As other user has said in a reply to my comment, you can't beat the level of control Rust's syntax provides and that's what most people writing assembly would want. You are also right that a proper asm parser would be difficult to maintain due to the amount of architectures Rust has to support.
- fluffything 6y agoNotice that you can quite easily implement a Rust proc macro that takes whatever DSL you want to use for inline assembly, and generates an `asm!` expression from it. So better syntaxes are possible, as long as they can be built on top of the proposed inline-assembly feature. They can, however, just be implemented as normal Rust libraries, and do not need to be part of the compiler.
- dathinab 6y agoYes, I mean we shouldn't forget that asm today is a last resort escape hatch which should be avoided if possible. EDIT: Just to be clear it's still important. But it's mainly used for a view "very high control" use cases.