Discussion:
Number Literal Syntax
(too old to reply)
Lawrence D'Oliveiro
2024-02-24 05:52:01 UTC
Permalink
I see that Fortran uses the underscore in integer and real literals as a
special suffix delimiter, followed by a code number or name to indicate
the type of the literal. Pity they didn’t follow the convention in some
other languages, where this is ignored so it can be used as a grouping
delimiter, just for readability, to avoid the “drowning in digits” effect.
E.g. in Python this is a valid integer literal

18_446_744_073_709_551_615

and this is a valid real literal:

3.141_592_653_589_793
m_b_metcalf
2024-02-24 09:17:51 UTC
Permalink
Post by Lawrence D'Oliveiro
I see that Fortran uses the underscore in integer and real literals as a
special suffix delimiter, followed by a code number or name to indicate
the type of the literal. Pity they didn’t follow the convention in some
other languages, where this is ignored so it can be used as a grouping
delimiter, just for readability, to avoid the “drowning in digits” effect.
E.g. in Python this is a valid integer literal
18_446_744_073_709_551_615
3.141_592_653_589_793
Well, whatever the merits of this may be, I don't believe that, back in
the mid-1980s when Fortran 90 was more-or-less defined, there was any
'convention' to follow. Python, for instance, was released only in 1991.

Regards,

Mike
Lawrence D'Oliveiro
2024-02-24 21:13:53 UTC
Permalink
Post by m_b_metcalf
Well, whatever the merits of this may be, I don't believe that, back in
the mid-1980s when Fortran 90 was more-or-less defined, there was any
'convention' to follow.
Ada was probably the language that pioneered it.
Gary Scott
2024-02-24 18:40:37 UTC
Permalink
Post by Lawrence D'Oliveiro
I see that Fortran uses the underscore in integer and real literals as a
special suffix delimiter, followed by a code number or name to indicate
the type of the literal. Pity they didn’t follow the convention in some
other languages, where this is ignored so it can be used as a grouping
delimiter, just for readability, to avoid the “drowning in digits” effect.
E.g. in Python this is a valid integer literal
18_446_744_073_709_551_615
3.141_592_653_589_793
In fixed form, probably 3.141 592 653 589 793

might have worked

I don't find this "drowning" problem to be a problem. In any case, the
common symbol for grouping numbers is the comma, although not typically
after the decimal point.

Sorry for the direct email sent to MM. Thunderbird changed the menu
such that the first option (reply (meaning reply to sender, not reply))
goes to email and the second option "followup" goes to group. I think
that's dumb, but you'd think I could remember it from one post to the
next :(
Thomas Koenig
2024-02-25 18:57:13 UTC
Permalink
Post by Lawrence D'Oliveiro
I see that Fortran uses the underscore in integer and real literals as a
special suffix delimiter, followed by a code number or name to indicate
the type of the literal. Pity they didn’t follow the convention in some
other languages,
That would, I belive, have required a time machine. The other
languages could have followed Fortran: Fortran still has such a
method: Blanks are not significant in fixed form, so

a = 123.456 789

is perfectly legal. It would be possible to introduce that into free
form without too much hassle.

So, I think we should ask latecomers like Python to change.
Lawrence D'Oliveiro
2024-02-25 20:21:27 UTC
Permalink
Post by Thomas Koenig
So, I think we should ask latecomers like Python to change.
Python could. It already has implicit concatenation of string literals; it
could do the same for numerics.

Loading...