Fortran (in free-form mode) is now the third language I’ve come across
that allows semicolons to terminate statements, but makes them
optional (letting a newline do the job instead).
The other two are JavaScript and Python. JavaScript has the most complex-seeming rule, but once you understand how it works, being able
to write something like
f(a, b, c)
as
f
(
a,
b,
c
)
(where a, b and c might be quite complex expressions) is quite useful.
Python has I think the most straightforward rule: you need to end a
line with “\” to do explicit continuation, but continuation can be implicit if there is an unpaired opening parenthesis, bracket or
brace. So complex expressions can be written with minimal clutter:
section_verts = \
[
start + vec(0, - rail_width / 2, 0),
start + vec(0, rail_width / 2, 0),
start + vec(0, - rail_width / 2, rail_thickness * slope_adjust),
start + vec(0, rail_width / 2, rail_thickness * slope_adjust),
]
Free-form Fortran, on the other hand, requires an explicit “&” to continue a line in all cases:
character(len = 9), dimension(3, 4), parameter :: month_names = &
reshape &
( &
(/ ' January ', ' February', ' March ', ' April ', &
' May ', ' June ', ' July ', ' August ', &
'September', ' October ', ' November', ' December' /), &
(/3, 4/) &
)
Wouldn’t it be useful if it had a smarter, Python-style rule?
Fortran (in free-form mode) is now the third language I’ve come across
that allows semicolons to terminate statements, but makes them
optional (letting a newline do the job instead).
Free-form Fortran, on the other hand, requires an explicit “&” to continue a line in all cases:
character(len = 9), dimension(3, 4), parameter :: month_names = &
reshape &
( &
(/ ' January ', ' February', ' March ', ' April ', &
' May ', ' June ', ' July ', ' August ', &
'September', ' October ', ' November', ' December' /), &
(/3, 4/) &
)
Wouldn’t it be useful if it had a smarter, Python-style rule?
Fortran (in free-form mode) is now the third language I’ve come across
that allows semicolons to terminate statements, but makes them
optional (letting a newline do the job instead).
Python has I think the most straightforward rule: you need to end a
line with “\” to do explicit continuation, but continuation can be implicit if there is an unpaired opening parenthesis, bracket or
brace.
So complex expressions can be written with minimal clutter:
section_verts = \
[
start + vec(0, - rail_width / 2, 0),
start + vec(0, rail_width / 2, 0),
start + vec(0, - rail_width / 2, rail_thickness * slope_adjust),
start + vec(0, rail_width / 2, rail_thickness * slope_adjust),
]
Free-form Fortran, on the other hand, requires an explicit “&” to continue a line in all cases:
character(len = 9), dimension(3, 4), parameter :: month_names = &
reshape &
( &
(/ ' January ', ' February', ' March ', ' April ', &
' May ', ' June ', ' July ', ' August ', &
'September', ' October ', ' November', ' December' /), &
(/3, 4/) &
)
Wouldn’t it be useful if it had a smarter, Python-style rule?
So I'd probably use longer lengths than below ...
Lawrence D'Oliveiro <ldo@nz.invalid> schrieb:
Python has I think the most straightforward rule: you need to end a
line with “\” to do explicit continuation, but continuation can be
implicit if there is an unpaired opening parenthesis, bracket or brace.
That sounds like a recipe for errors, if you ask me.
Looking at the JavaScript example. One pair of () brackets is easy to
keep track of, multiple nested brackets (complex expressions) can lead
to mismatched brackets and very confusing / entertaining syntax errors.
And the chances of the committee changing that now, 33 years after
free-form Fortran came out, infinitesimal.
On Tue, 6 Feb 2024 10:58:20 -0600, Gary Scott wrote:Not really, its a quite long limit. And a warning at compile time is
So I'd probably use longer lengths than below ...
In the only one of the three languages that imposes line-length limits?
Now *that’s* living dangerously ...
On 2/6/2024 1:56 PM, Lawrence D'Oliveiro wrote:
On Tue, 6 Feb 2024 10:58:20 -0600, Gary Scott wrote:Not really, its a quite long limit. And a warning at compile time is
So I'd probably use longer lengths than below ...
In the only one of the three languages that imposes line-length limits?
Now *that’s* living dangerously ...
issued if by some weird chance I hit the limit in the standard (132)
(and most compilers have a much longer limit still (Intel 2048)).
On Tue, 06 Feb 2024 15:34:25 -0600, Gary Scott wrote:
On 2/6/2024 1:56 PM, Lawrence D'Oliveiro wrote:
On Tue, 6 Feb 2024 10:58:20 -0600, Gary Scott wrote:Not really, its a quite long limit. And a warning at compile time is
So I'd probably use longer lengths than below ...
In the only one of the three languages that imposes line-length limits?
Now *that’s* living dangerously ...
issued if by some weird chance I hit the limit in the standard (132)
(and most compilers have a much longer limit still (Intel 2048)).
The Fortran 2023 standard has increased the limit.
6.3.2.1 Free form line length
...
A line shall contain at most ten thousand characters.
And the chances of the committee changing that now, 33 years after
free-form Fortran came out, infinitesimal.
Python has I think the most straightforward rule: you need to end a
line with “\” to do explicit continuation, but continuation can be implicit if there is an unpaired opening parenthesis, bracket or
brace. So complex expressions can be written with minimal clutter:
section_verts = \
[
start + vec(0, - rail_width / 2, 0),
start + vec(0, rail_width / 2, 0),
start + vec(0, - rail_width / 2, rail_thickness * slope_adjust),
start + vec(0, rail_width / 2, rail_thickness * slope_adjust),
]
Free-form Fortran, on the other hand, requires an explicit “&” to continue a line in all cases:
character(len = 9), dimension(3, 4), parameter :: month_names = &
reshape &
( &
(/ ' January ', ' February', ' March ', ' April ', &
' May ', ' June ', ' July ', ' August ', &
'September', ' October ', ' November', ' December' /), &
(/3, 4/) &
)
Wouldn’t it be useful if it had a smarter, Python-style rule?
Fortran (in free-form mode) is now the third language I’ve come across[...]
that allows semicolons to terminate statements, but makes them
optional (letting a newline do the job instead).
Pascal and Algol demand semicolons at the end of statements.
On Fri, 9 Feb 2024 15:49:37 +0100, db wrote:They're also statement separators in Fortran.
Pascal and Algol demand semicolons at the end of statements.
No they don’t. In those languages, semicolons are statement separators,
not statement terminators.
Pascal requires them at the end of declarations, of everything except the main program, which ends with a full stop.
They're also statement separators in Fortran.
On Fri, 9 Feb 2024 21:00:48 -0600, Gary Scott wrote:It terminates the statement, not the line. It is common to place
They're also statement separators in Fortran.
Section 6.3.2.5 of the Fortran 2018 spec, second paragraph:
A statement may alternatively be terminated by a “;” character
that appears other than in a character context or in a comment.
The “;” is not part of the statement. After a “;” terminator,
another statement may appear on the same line, or begin on that
line and be continued. A sequence consisting only of zero or more
blanks and one or more “;” terminators, in any order, is
equivalent to a single “;” terminator.
Note it says “terminator”, not “separator”.
On 2/9/2024 10:51 PM, Lawrence D'Oliveiro wrote:
On Fri, 9 Feb 2024 21:00:48 -0600, Gary Scott wrote:
They're also statement separators in Fortran.
Section 6.3.2.5 of the Fortran 2018 spec, second paragraph:
A statement may alternatively be terminated by a “;” character
that appears other than in a character context or in a comment.
The “;” is not part of the statement. After a “;” terminator, >> another statement may appear on the same line, or begin on that
line and be continued. A sequence consisting only of zero or more
blanks and one or more “;” terminators, in any order, is
equivalent to a single “;” terminator.
Note it says “terminator”, not “separator”.
It terminates the statement ...
On Sat, 10 Feb 2024 08:17:04 -0600, Gary Scott wrote:
On 2/9/2024 10:51 PM, Lawrence D'Oliveiro wrote:
On Fri, 9 Feb 2024 21:00:48 -0600, Gary Scott wrote:
They're also statement separators in Fortran.
Section 6.3.2.5 of the Fortran 2018 spec, second paragraph:
A statement may alternatively be terminated by a “;” character
that appears other than in a character context or in a comment.
The “;” is not part of the statement. After a “;” terminator, >>> another statement may appear on the same line, or begin on that
line and be continued. A sequence consisting only of zero or more
blanks and one or more “;” terminators, in any order, is
equivalent to a single “;” terminator.
Note it says “terminator”, not “separator”.
It terminates the statement ...
Well, you did say “separators” of statements, not “terminators”, did you
not?
On Sat, 10 Feb 2024 04:51:38 -0000 (UTC), Lawrence D'Oliveiro wrote:line
On Fri, 9 Feb 2024 21:00:48 -0600, Gary Scott wrote:
They're also statement separators in Fortran.
Section 6.3.2.5 of the Fortran 2018 spec, second paragraph:
A statement may alternatively be terminated by a “;” character that >> appears other than in a character context or in a comment.
The “;” is not part of the statement. After a “;” terminator,
another statement may appear on the same line, or begin on that
and be continued. A sequence consisting only of zero or more blanks
and one or more “;” terminators, in any order, is equivalent to a
single “;” terminator.
Note it says “terminator”, not “separator”.
Well, the Fortran 2023 standard also contains
4.1.4 Syntax conventions and characteristics
Any syntactic class name ending in "-stmt" follows the source form
statement rules: it shall be delimited by end-of-line or semicolon,
...
so, I suppose one could call it a delimiter.
On Sat, 10 Feb 2024 08:17:04 -0600, Gary Scott wrote:Yes, it does serve that purpose. It is proper use of english. The clarification is that it does not terminate the line. Some of the
On 2/9/2024 10:51 PM, Lawrence D'Oliveiro wrote:
On Fri, 9 Feb 2024 21:00:48 -0600, Gary Scott wrote:
They're also statement separators in Fortran.
Section 6.3.2.5 of the Fortran 2018 spec, second paragraph:
A statement may alternatively be terminated by a “;” character >>> that appears other than in a character context or in a comment.
The “;” is not part of the statement. After a “;” terminator, >>> another statement may appear on the same line, or begin on that
line and be continued. A sequence consisting only of zero or more
blanks and one or more “;” terminators, in any order, is
equivalent to a single “;” terminator.
Note it says “terminator”, not “separator”.
It terminates the statement ...
Well, you did say “separators” of statements, not “terminators”, did you
not?
Some of the discussion appeared to have potentially confused termination
of a statement from termination of a line.
On Sat, 10 Feb 2024 19:31:02 -0600, Gary Scott wrote:Exactly
Some of the discussion appeared to have potentially confused termination
of a statement from termination of a line.
Really? Where? (Hint: look at the subject line.)
On 2/10/2024 7:43 PM, Lawrence D'Oliveiro wrote:
On Sat, 10 Feb 2024 19:31:02 -0600, Gary Scott wrote:
Some of the discussion appeared to have potentially confused
termination of a statement from termination of a line.
Really? Where? (Hint: look at the subject line.)
Exactly
called as long as one knows how to use it?
Given the volume of your posts in c.l.c and c.l.f, I doubt you care.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 991 |
Nodes: | 10 (0 / 10) |
Uptime: | 119:58:41 |
Calls: | 12,958 |
Files: | 186,574 |
Messages: | 3,265,641 |