Closed nushio3 closed 10 years ago
Dear @goldfirere , I'd wait your opinion rather than directly merging this.
I think adding support for dimensionless annotations is a good idea, but I think a different syntax is better: use 1
to indicate dimensionless. This would also allow things like [si| 1/s |]
instead of [si| s^-1 |]
. (Currently, the former fails to parse.) It also conforms to F#'s syntax, which was my inspiration for the syntax in the current parser. (The key not-totally-obvious thing from F# is that *
and /
have the same precedence, while juxtaposition binds tighter than either.)
I like the idea of using 1
for dimensionless unit, especially I like how it allows reciprocal units! We can also save [si| <spaces> |]
as alternative form of dimensionless unit, too. Allowing both expression will contribute to decrease the surprise, when different people try to express units in different ways. And as far as I can foresee there will be no ambiguity raised by allowing both.
I'd like our unit TH to be able to parse dimensionless units. And I think dimensionless unit should allow spaces like
[si| |]
, since the behavior is consistent with allowing extra spaces among unit symbol and numbers.