Here is a table of dimensions used by Arturo, expressed as a table in the Nim language:
arturo/src/vm/values/custom/quantities/definitions.nim at master · arturo-lang/arturo · GitHub
It's a pretty impressive compendium. And there's also some "heavily macro-driven" Nim code that implements conversion operations:
@drkameleon cites Frink as the main inspiration for this, though assembling the table and conversion code was original work on the order of months.
Why Not Use Arturo For The Table...?
The table is Nim code...and as such, beholden to having a lot of repetition and commas.
So of course my first question was "why not express it as Arturo, and then spit out the Nim table as part of the build process"?
Instead of:
#-----------------------------------------------------------------------
# Length units (base: m)
#-----------------------------------------------------------------------
# name symbol prefix? definition aliases
#-----------------------------------------------------------------------
defUnit "in", "in", false, "127:5000 m", "inch", "inches"
defUnit "ang", "Å", false, "1:10000000000 m", "angstrom", "angstroms"
defUnit "px", "px", true, "1:96 in", "pixel", "pixels"
It could be reduced down to something more like this:
=== LENGTH (base: m) ===
in [127:5000 m] inch inches
ang [1:10000000000 m] angstrom angstroms ("Å")
*/px [1:96 in] pixel pixels
The meaning of "prefix?" is actually "prefixable?" that a type can have a prefix. e.g. pixels is prefixable because you can say Mpx
for "megapixels". So I think some prefixing decoration on the type is a nice way to convey this. I just threw in */px
as an example--though I gather that in Arturo that would be *\px
Though when I first saw some isolated instance of the colon notation I didn't realize it was a ratio. Ren-C could do this as a CHAIN! or as a PATH!. I think my first instinct would have been path:
in [127/5000 m] inch inches
ang [1/10000000000 m] angstrom angstroms ("Å")
*.px [1/96 in] pixel pixels
But it actually looks a bit better with the colons I think.
Some notation would be nice for the pluralization. It's one of the places where the FUSED! proposal might come in handy:
in [127:5000 m] inch{es}
ang [1:10000000000 m] angstrom{s} ("Å")
*/px [1:96 in] pixel{s}
You can use tuples or paths, but it's not quite as neat...although the paths aren't terrible:
in [127:5000 m] inch.es
ang [1:10000000000 m] angstrom.s ("Å")
*/px [1:96 in] pixel.s
in [127:5000 m] inch/es
ang [1:10000000000 m] angstrom/s ("Å")
*/px [1:96 in] pixel/s