Re: Motion 46: finalise interval literals, amendments
If portable syntax of interval literals is a goal, we can achieve this in such a way.
1) Give minimal concrete syntax for
langNumLit, langNumLitMant, langNumLitExp, sp, ratNumLit .
For example:
langNumLitExp anycase("e") {sign} ? {digit}+
Every implementation shall accept this syntax in text2interval and in public2interval
and understand value of literals as described in the standard.
2) Implementation may extend
langNumLit, langNumLitMant, langNumLitExp, sp, ratNumLit
in host-language specific way, privided that input literals from (1) are parsed unambigously
in the extended syntax.
3) Hence implementation shall always accept literal 010/011 and understand it as 10/11 .
We may write a warning about this in the standard.
However, implementation may extend syntax to accept 0x10/0x11 and understand it as 16/17 .
-Dima
----- Исходное сообщение -----
От: dmitry.nadezhin@xxxxxxxxxx
Кому: stds-1788@xxxxxxxxxxxxxxxxx
Отправленные: Среда, 10 Июль 2013 г 12:34:47 GMT +04:00 Абу-Даби, Маскат
Тема: Re: Motion 46: finalise interval literals, amendments
(A) I'd like that the standard defines interval literal in unambigous and portable way.
If program P1 written in language L1 writes textual file with number literals,
then program P2 written in language L2 is able to read this file.
So I like the "restriction" variant more than "host language integer literals":
> An implementation may make language-defined restrictions on the form of
> number literal.
> [Example. Some languages treat leading zero as the start of an octal number.
> They may forbid p and q of the p/q form to start with a zero.]
Also I have doubts about using host-language langNumLit, langNumLitMat, langNumLitExp, sp,
instead of clear syntax similar to 754-2008 syntax that of hexadecimal number literals.
This is about interval literals that are used as arguments of text2interval() and as public representation.
I have nothing against extending languages and compilers by host-language specific literals.
If portable syntax of text2interval() arguments is not-a-goal then excuse me for this noise.
-Dima