[racket] Numbers with dimensions

From: Norman Gray (norman at astro.gla.ac.uk)
Date: Mon Oct 28 07:49:08 EDT 2013

Greetings.

On 2013 Oct 28, at 11:05, Laurent <laurent.orseau at gmail.com> wrote:

> So I've redesigned it somewhat, and now there are 2 calculation "modes":
> - The normal mode is pretty much like Frink (probably the one you want),
> which converts everything to base SI units. Conversion back to non base
> units can be done afterwards.
> - The "quoted" mode prevents a unit from being converted to SI base units.
> It's useful if you want to add miles without having to convert back to
> miles after the addition. It is also useful to read values from text files.
> Such quoted units can still be converted to base units.

I'd like to just chip in here, at a slight tangent.

I've recently been doing some work on pinning down a standardisable syntax for unit strings in the context of astronomy (this isn't the only such effort, but that's a longer story)

Quoth <http://www.ivoa.net/documents/VOUnits/>:

> This document describes a recommended syntax for writing the string representation of unit labels (‘VOUnits’). In addition, it describes a set of recognised and deprecated units, which is as far as possible consistent with other relevant standards (BIPM, ISO/IEC and the IAU). The intention is that units written to conform to this specification will likely also be parsable by other well-known parsers. To this end, we include machine-readable grammars for other units syntaxes

It's still a bit drafty, but is now moving towards some sort of consensus.  It also briefly discusses the surprising amount of variation in this domain.

Linked to that is a set of explicit grammars for unit strings in four well-known specifications (or, at least, well-known in astronomy).  See <http://www.astro.gla.ac.uk/users/norman/ivoa/unity/> and <https://bitbucket.org/nxg/unity>; the latter includes grammars and a fairly large set of test cases, plus two sample libraries implementing the parsers.

It might be of interest if anyone's looking at dimensions and units, though note that it attempts only to parse unit strings and to support validation of them, and not to do anything higher-level such as converting them.

All the best,

Norman


-- 
Norman Gray  :  http://nxg.me.uk
SUPA School of Physics and Astronomy, University of Glasgow, UK



Posted on the users mailing list.