Walnut356@programming.devOPtoProgramming Horror@programming.dev•When your language doesn't allow arbitrary expressions in format stringsEnglish
0·
1 year agoin this case it’s about 80% function calls. They’re convenience functions for assembly instructions, so they’re of the form:
load(Reg::D, "A"),
load_const(5),
which is more useful than variables would be. I guess i could use .join or a crate like concat_string? Either way i sorely miss arbitrary expression format strings from python =(
For downsides, i’d like to add that the lack of function overloading and default parameters can be really obnoxious and lead to [stupid ugly garbage].
A funny one i found in the standard library is in
time::Duration
.Duration::as_nanos()
returns a u128,Duration::from_nanos()
only accepts a u64. That means you need to explicitly downcast and possibly lose data to make a Duration after any transformations you did.They cant change
from_nanos()
to accept u128 instead because that’s breaking since type casting upwards has to be explicit too (for some reason). The only solution then is to make afrom_nanos_u128()
which is both ugly, and leaves the 64 bit variant hanging there like a vestigial limb.