-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revise scalar units #36
Conversation
In today's discussion we discovered that this rule will be awkward - even the proposed examples would fail if we always use weight: 10 Kg
height: 100 mm
width: 125 mm
throughput: 1 KiB It would have to be weight: 10.0 Kg
height: 100.0 mm
width: 125.0 mm
throughput: 1.0 KiB I understand that in some contexts there are strong feelings against automatically converting The first part of the argument is not really making a lot of sense: "This requirement is necessary for avoiding rounding errors..." You can get rounding errors if converting from float to integer, but the other way around - yes, a float is not always a precise representation of an integral number, We could chose between four options:
Three other notes:
|
Thanks Peter,
You make some good points, my responses are inline.
Paul
On 15/05/2024 17:10, Peter Michael Bruun wrote:
https://github.com/oasis-tcs/tosca-specs/blob/e7f866dc5e3081b90c27bde9c81ce113061ea122/tosca_2_0/TOSCA-v2.0.md?plain=1#L4331C1-L4335C58
A TOSCA parser /shall not/ attempt to convert a YAML !!int to a
float. This requirement is necessary for avoiding rounding errors
and ensuring portability. Users should thus add a “.0” suffix to
literal integers that must be floats. Note that this even includes
zero, i.e. users must specify “0” for a zero integer and “0.0” for
a zero float.
In today's discussion we discovered that this rule will be awkward -
even the proposed examples would fail if we always use |float| for
scalar types:
weight:10 Kg
height:100 mm
width:125 mm
throughput:1 KiB
It would have to be
weight:10.0 Kg
height:100.0 mm
width:125.0 mm
throughput:1.0 KiB
>PJ yes I agree that the examples would currently fail for that reason.
I understand that in some contexts there are strong feelings against
automatically converting |10 Kg| to |10.0 Kg|.
The first part of the argument is not really making a lot of sense:
"This requirement is necessary for avoiding rounding errors..."
You can get rounding errors if converting from float to integer, but
the other way around - yes, a float is not always a precise
representation of an integral number, |10|, but it would not become
any more precise by writing |10.0|.
We could chose between four options:
1. "A TOSCA parser MUST convert a YAML !!int to a float" - I would
vote for this
>PJ I think that is what we agreed in the meeting
1. "A TOSCA parser MAY convert a YAML !!int to a float" - This would
solve the issue, but would snag on the second part of the argument
"... ensuring portability"
2. "A TOSCA parser SHALL NOT attempt to convert a YAML !!int to a
float" - This is the current text, but we would not be allowed to
write "10 Kg"
3. "A TOSCA parser SHALL NOT attempt to convert a YAML !!int to a
float except in scalar units" - this was proposed in the language
meeting, but the exception is too irregular for my taste. In
scalar units the parser either ...
1. ... MUST convert - For portability
2. MAY convert - Looser, but compromises portability
Three other notes:
* Key words like "MUST" MUST be in all caps in our specification:
https://github.com/oasis-tcs/tosca-specs/blob/working/tosca_2_0/TOSCA-v2.0.md#key-words
That is not something I checked for in my general review of the
document. My pull request on scalars does use SHALL. Are there specific
places where my text needs revision on this point?
* The ISO prefix for multiplier 1000 "kilo" is |k|, not |K|. Writing
|10 Kg| looks very wrong - it should be |10 kg|
|>>PJ I agree. It is correct in the ISO8000 table but incorrect in the
example.|
* I can see that you are using TAB-characters in the YAML examples -
this is not valid yaml and creates a problem if someone tries to
copy-paste text from our specification into their own YAML files.
> PJ Thank you.
* Also you cannot use the '''yaml (where ' should be backquote)
annotation to get proper highlighting of YAML text
> I've done this throughput the document. Both Github and Visual
Studio Code seem to highlight as YAML correctly.
…
—
Reply to this email directly, view it on GitHub
<#36 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHOS4X6SQZTAVNUJK4T5L43ZCOCHHAVCNFSM6AAAAABHAUZ7USVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJSHE2DQOBVGU>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
--------------Z4okaglCvo3jdFFz6jOF7sCl
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Thanks Peter,</p>
<p>You make some good points, my responses are inline.</p>
<p>Paul<br>
</p>
<div class="moz-cite-prefix">On 15/05/2024 17:10, Peter Michael
Bruun wrote:<br>
</div>
<blockquote type="cite" ***@***.***">
<p dir="auto"><a href="https://github.com/oasis-tcs/tosca-specs/blob/e7f866dc5e3081b90c27bde9c81ce113061ea122/tosca_2_0/TOSCA-v2.0.md?plain=1#L4331C1-L4335C58" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/oasis-tcs/tosca-specs/blob/e7f866dc5e3081b90c27bde9c81ce113061ea122/tosca_2_0/TOSCA-v2.0.md?plain=1#L4331C1-L4335C58</a></p>
<blockquote>
<p dir="auto">A TOSCA parser <em>shall not</em> attempt to
convert a YAML !!int to a float. This requirement is necessary
for avoiding rounding errors and ensuring portability. Users
should thus add a “.0” suffix to literal integers that must be
floats. Note that this even includes zero, i.e. users must
specify “0” for a zero integer and “0.0” for a zero float.</p>
</blockquote>
<p dir="auto">In today's discussion we discovered that this rule
will be awkward - even the proposed examples would fail if we
always use <code class="notranslate">float</code> for scalar
types:</p>
<div class="highlight highlight-source-yaml" dir="auto">
<pre class="notranslate"> <span class="pl-ent">weight</span>: <span class="pl-s">10 Kg</span>
<span class="pl-ent">height</span>: <span class="pl-s">100 mm</span>
<span class="pl-ent">width</span>: <span class="pl-s">125 mm</span>
<span class="pl-ent">throughput</span>: <span class="pl-s">1 KiB</span></pre>
</div>
<p dir="auto">It would have to be</p>
<div class="highlight highlight-source-yaml" dir="auto">
<pre class="notranslate"> <span class="pl-ent">weight</span>: <span class="pl-s">10.0 Kg</span>
<span class="pl-ent">height</span>: <span class="pl-s">100.0 mm</span>
<span class="pl-ent">width</span>: <span class="pl-s">125.0 mm</span>
<span class="pl-ent">throughput</span>: <span class="pl-s">1.0 KiB</span></pre>
</div>
</blockquote>
>>PJ yes I agree that the examples would currently fail for
that reason.<br>
<blockquote type="cite" ***@***.***">
<p dir="auto">I understand that in some contexts there are strong
feelings against automatically converting <code class="notranslate">10 Kg</code> to <code class="notranslate">10.0
Kg</code>.</p>
<p dir="auto">The first part of the argument is not really making
a lot of sense: "This requirement is necessary for avoiding
rounding errors..."</p>
<p dir="auto">You can get rounding errors if converting from float
to integer, but the other way around - yes, a float is not
always a precise representation of an integral number, <code class="notranslate">10</code>, but it would not become any
more precise by writing <code class="notranslate">10.0</code>.</p>
<p dir="auto">We could chose between four options:</p>
<ol dir="auto">
<li>"A TOSCA parser MUST convert a YAML !!int to a float" - I
would vote for this</li>
</ol>
</blockquote>
>>PJ I think that is what we agreed in the meeting<br>
<blockquote type="cite" ***@***.***">
<ol dir="auto">
<li>"A TOSCA parser MAY convert a YAML !!int to a float" - This
would solve the issue, but would snag on the second part of
the argument "... ensuring portability"</li>
<li>"A TOSCA parser SHALL NOT attempt to convert a YAML !!int to
a float" - This is the current text, but we would not be
allowed to write "10 Kg"</li>
<li>"A TOSCA parser SHALL NOT attempt to convert a YAML !!int to
a float except in scalar units" - this was proposed in the
language meeting, but the exception is too irregular for my
taste. In scalar units the parser either ...
<ol dir="auto">
<li>... MUST convert - For portability</li>
<li>MAY convert - Looser, but compromises portability</li>
</ol>
</li>
</ol>
<p dir="auto">Three other notes:</p>
<ul dir="auto">
<li>Key words like "MUST" MUST be in all caps in our
specification: <a href="https://github.com/oasis-tcs/tosca-specs/blob/working/tosca_2_0/TOSCA-v2.0.md#key-words" moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/oasis-tcs/tosca-specs/blob/working/tosca_2_0/TOSCA-v2.0.md#key-words</a></li>
</ul>
</blockquote>
That is not something I checked for in my general review of the
document. My pull request on scalars does use SHALL. Are there
specific places where my text needs revision on this point?<br>
<blockquote type="cite" ***@***.***">
<ul dir="auto">
<li>The ISO prefix for multiplier 1000 "kilo" is <code class="notranslate">k</code>, not <code class="notranslate">K</code>.
Writing <code class="notranslate">10 Kg</code> looks very
wrong - it should be <code class="notranslate">10 kg</code></li>
</ul>
</blockquote>
<code>>>PJ I agree. It is correct in the ISO8000 table but
incorrect in the example.</code><br>
<blockquote type="cite" ***@***.***">
<ul dir="auto">
<li>I can see that you are using TAB-characters in the YAML
examples - this is not valid yaml and creates a problem if
someone tries to copy-paste text from our specification into
their own YAML files. </li>
</ul>
</blockquote>
>> PJ Thank you.<br>
<blockquote type="cite" ***@***.***">
<ul dir="auto">
<li>Also you cannot use the '''yaml (where ' should be
backquote) annotation to get proper highlighting of YAML text</li>
</ul>
</blockquote>
>> I've done this throughput the document. Both Github and
Visual Studio Code seem to highlight as YAML correctly.<br>
<blockquote type="cite" ***@***.***">
<ul dir="auto">
</ul>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>
Reply to this email directly, <a href="#36 (comment)" moz-do-not-send="true">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AHOS4X6SQZTAVNUJK4T5L43ZCOCHHAVCNFSM6AAAAABHAUZ7USVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJSHE2DQOBVGU" moz-do-not-send="true">unsubscribe</a>.<br>
You are receiving this because you authored the thread.<img src="https://github.com/notifications/beacon/AHOS4X5KNJJHR7TORUVAD4TZCOCHHA5CNFSM6AAAAABHAUZ7USWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTT56EFHO.gif" alt="" moz-do-not-send="true" width="1" height="1"><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message
ID: <span><oasis-tcs/tosca-specs/pull/36/c2112948855</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
***@***.***": "http://schema.org",
***@***.***": "EmailMessage",
"potentialAction": {
***@***.***": "ViewAction",
"target": "#36 (comment)",
"url": "#36 (comment)",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
***@***.***": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>
</blockquote>
<div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2"><br><table style="border-top: 1px solid #D3D4DE;"><tr><td style="width: 55px; padding-top: 13px;"><a href="http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank"><img src="https://s-install.avcdn.net/ipm/preview/icons/icon-envelope-tick-green-avg-v1.png" alt="" width="46" height="29" style="width: 46px; height: 29px;"></a></td><td style="width: 470px; padding-top: 12px; color: #41424e; font-size: 13px; font-family: Arial, Helvetica, sans-serif; line-height: 18px;">Virus-free.<a href="http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient" target="_blank" style="color: #4453ea;">www.avg.com</a></td></tr></table><a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body>
</html>
--------------Z4okaglCvo3jdFFz6jOF7sCl--
|
I see no problem in automatically converting a YAML literal integer to a float if the scalar's type is float. Actually, more specifically: I see no value in emitting an "incorrect type" error in this case. Forcing the addition ".0" to every integer does nothing except emphasize to human readers that the value is a float. But isn't that obvious to readers? The internal data storage is of the correct type (float or int) and that's what matters and should be maintained. We should definitely support both types of scalars. For TOSCA 3.0 maybe we can also support imaginary numbers. :) |
@pmjordan Thanks
Probably not your text, but my initial quote, didn't use all caps:
Should be
|
@tliron It looks like we all agree. Only thing is this:
I am with you, but in today's meeting it was concluded that float should work for all scalars, although I believe the reason was that having both integer and float added syntactic complexity to specification of new scalar types. Is that correctly understood? |
I disagree with that decision, then. Yes, there's syntactic complexity, but I think it's necessary. That's exactly the kind of loss of precision we cannot allow in storage. If we support scalars, we should do it properly. (Honestly, I would prefer support for unsigned ints, too, but these are not supported by YAML.) Can't we use a data type |
Regarding integers and floats when used with scalars: Regarding yaml rendering |
I think of this in the opposite direction -- we absolutely want to distinguish floats and integers for storage and transfer purposes in the world of node representations. It's the lack of this distinction that makes JSON such a pain in many environments. And it's not just about literal values written in YAML: remember that properties and attributes are typed data placeholders and the actual data can come from user inputs and from the environment. Why introduce the possibility for subtle, painful rounding errors and overflows? (Which in some cases can be understood as security bugs.) And if we have that distinction, then scalars should follow. (Actually, I would say that we can even introduce things like precision and endianness to number representations. But since YAML doesn't handle that, it could be handled with metadata for users and orchestrator that need it.) I hope we can reopen and revisit this. TOSCA is a very rich data modeling language for data types, I would think it should evolve over time and not remove important features. We had integer scalars (implicitly) in TOSCA 1.3, is it really so hard for us to come up with syntax to allow it in 2.0? |
We have two separate issues, I believe:
|
I've created pull #42 to implement the solution based on the current working branch, with support for both integer and float in scalar units and requiring parsers not to error when assigning a YAML int to a TOSCA property of type float. Sorry I messed up when naming that pull request. |
A new pull request to replace #36
Attempt to resolve
oasis-open/tosca-community-contributions#145
oasis-open/tosca-community-contributions#144
oasis-open/tosca-community-contributions#142
oasis-open/tosca-community-contributions#143