Firstly, apologies for the length of these posts.
I realize that in order to adopt my way of thinking about this, a clarification/correction is required to the post above.
The Clarification:
If we are to think of unit specifications in terms of SCOPE as I suggest, then we need to be consistent in terms of what is meant by prefix/postfix.
If we're talking about VALUE-scope (option 1), then nothing changes: prefix units appear
before the values, postfix units appear
after the values,...
...however when talking about PROPERTY-scope (option 2), then to be consistent about the notion of prefix/postfix form, it's necessary to think of it as being "tied to" the Property Name, rather than to the the values: prefix units appear
before the Property Name, postfix units appear
after the Property Name.
So the 4 possibilities are:
VALUE-scope, postfix
Code: Select all
LongLat [ 20<deg> 220<deg> 500<m> ]
VALUE-scope, prefix
Code: Select all
LongLat [ <deg>20 <deg>220 <m>500 ]
PROPERTY-scope, postfix
PROPERTY-scope, prefix
So whereas (in the old sense) I said that I prefer
Prefix,... in the new way of thinking, this should actually be referred to as:
(PROPERTY-scope, postfix) ... the 3rd option above.
ie. in order to state a preference, you need to state both the SCOPE
and the FORM.
Clear as mud??
If so then state your preference from the 4 choices above !
-----------------------------------------------------------
It's also worth noting that if unit-specifications are associated with a scope as I suggest, then there's no reason why multiple scopes couldn't be implemented just as easily as a single option (the scope would be determined by
where the unit is specified) -- with narrower scopes overriding wider scopes. (in this sense, VALUE-scope is conceptually no different to PROPERTY-scope -- it would be simply a narrower scope which would override the PROPERTY-scope).
I'm sure that the parser already handles scope for it's usual duties, so in large-part this scheme would probably plug in quite nicely, allowing scenarios such as the following...
In the following example the Height and MieScaleHeight units are <km> -- determined by virtue of the fact they're within the Atmosphere scope, whereas the CloudHeight units are in <m>. (And take a look at the Sunset units
)
This is probably not a very realistic example, but is merely used to demonstrate the idea of using multiple levels of scope to specify custom units at various levels of detail.
Code: Select all
"Earth" "Sol"
{
Texture "earth.*"
NightTexture "earthnight.*"
# SpecularTexture "earth-spec.*"
Color [ 0.85 0.85 1.0 ]
SpecularColor [ 0.8 0.8 0.85 ]
SpecularPower 25.0
HazeColor [ 1 1 1 ]
HazeDensity 0.3
Radius 6378.140 # equatorial
# Oblateness 0.0034
Atmosphere <km> {
Height 60
Lower [ 0.43 0.52 0.65 ]
Upper [ 0.26 0.47 0.84 ]
Sky [ 0.40 0.6 1.0 ]
Sunset <rgb> [ 255 153 51 ]
CloudHeight <m> 7000
CloudSpeed 65
CloudMap "earth-clouds.*"
CloudShadowDepth 1.0
Mie 0.001
MieAsymmetry -0.25
Rayleigh [ 0.001 0.0025 0.006 ]
MieScaleHeight 12
}
The tricky part with this scheme is determining which sub-properties inherit which units of the parent. ie. Imagine the implications of the following:
This may be a show-stopper for the idea of unit-inheritance, because it will require prior knowledge of the valid
value-domains of each of the sub-properties. ie. Some are distances (km, m, etc), others are colors (rgb or ratio), yet others relate to degree of absorption/reflectance.
It's possibly getting all just a bit too complicated.
CC
PS. Whether the parser requires 'spaces" and/or "<>" to separate the units from the rest of the code is up to Andrew.