Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 23 |
Nodes: | 6 (0 / 6) |
Uptime: | 54:28:31 |
Calls: | 583 |
Files: | 1,139 |
D/L today: |
179 files (27,921K bytes) |
Messages: | 111,799 |
On 23/08/2025 16:49, Janis Papanagnou wrote:
[...]
FTAOD,
I too [and virtually the whole of RightPondia] would
write "0.5" rather than ".5", But ".5" is legal, and is shorter.
A68You're explaining Algol 68 mechanics. Right? - I got it; as it had
resolves this in favour of the third, you want it resolved in favour
of the second.
been defined in Algol 68 it's impossible to achieve directly. Right?
Right.
But, finding it difficult to resist a puzzle, I produced
$ genie -x 'OP F = (REAL x) STRING: ( x < 0 | "-" + F -x
| fixed (x, ( x < 2 | -3 | 0 ), 1)),
F = (INT x) STRING: F REAL (x);
printf (( $ "v=" g " m/s" l $, F .45, F 12.35, F 1, F -0.45 ))'
v=0.5 m/s
v=12.3 m/s
v=1.0 m/s
v=-0.5 m/s
which I hope is not too much string handling for your purposes.
There
are still a couple of edge cases which may or may not be to your taste;
left for your investigation.
On Sun, 24 Aug 2025 00:27:33 +0100, Andy Walker wrote:
We could get 95% of the power with no new syntax at all by
moving to a [formatting] model more like C.
The drawback of the C printf model is its notorious type-unsafeness.
On 23/08/2025 18:28, Janis Papanagnou wrote:
[...]
Agreed completely. But the way transput is done in the
Revised Report is a botch.
"FORMAT" adds around 50% to the A68
syntax charts [eg from one page (the Watt-Peck-Sintzoff chart) to
a page and a half]. We could get 95% of the power with no new
syntax at all by moving to a model more like C.
[...]
[...]
I've tended to go the other way of declaring some new
operators in my code to get better formatting.
FORMATs don't
mix well with ordinary string-handling code IMHO. I know how
to use FORMATs, I just don't like them.
FTAOD,(Sorry, I'm not familiar with the non-very-trivial "TLA"s or "FLA"s.)
I have a problem with a language/library/software design that didn't
cover a common application case. And where the solution is to work
around the problem (like you did with your hack). When I'm actually
better off writing my own [more consistent] I/O framework.
Concerning I/O Algol 68 wanted to avoid the mistake of Algol 60. Yet
there's IMO the upthread mentioned oversight?
"FORMAT" adds around 50% to the A68>> syntax charts [eg from one page (the Watt-Peck-Sintzoff chart) toWell, C's model is very primitive compared to Algol 68's.
a page and a half]. We could get 95% of the power with no new
syntax at all by moving to a model more like C.
There's really interesting things you can do with that
FORMAT "sub-language".
On 25/08/2025 01:14, Janis Papanagnou wrote:
[I wrote:]
"FORMAT" adds around 50% to the A68>> syntax charts [eg from one pageWell, C's model is very primitive compared to Algol 68's.
(the Watt-Peck-Sintzoff chart) to
a page and a half]. We could get 95% of the power with no new
syntax at all by moving to a model more like C.
There's really interesting things you can do with that
FORMAT "sub-language".
Yes, but you could do ~95% of them without having a mode [type]
"FORMAT" that has a special syntax.
There are a very few things that
would become somewhat harder, but virtually nothing that becomes really difficult.
[...]
C shows how you can do the simple things by using a perfectly
normal string as a formatting parameter to "printf" and its friends.
By contrast, even lexing a FORMAT denotation is a right mess -- you
can't simply go from "$" to a closing "$" because the denotation may
include nested formats that may include arbitrary amounts of A68 code, including nested strings, comments and formats [that may include ...,
to arbitrary depth]. It's not impossible [obviously!], just a lot
harder than it ought to be.
On 27.08.2025 01:58, Andy Walker wrote:[...]>>> Well, C's model is very primitive compared to Algol 68's.
On 25/08/2025 01:14, Janis Papanagnou wrote:
Well, having the FORMAT (effectively a sub-language) being an ownThere's really interesting things you can do with thatYes, but you could do ~95% of them without having a mode [type]
FORMAT "sub-language".
"FORMAT" that has a special syntax.
first-class element fits quite well into the language paradigm.
I've yet more such examples where ordinary "C" formatting would not
help.
What you explain as a burden is what I consider its expressive power (compared to, say, "C").
On 27/08/2025 07:23, Janis Papanagnou wrote:[...]
That is, in essence, the primary mission statement for the language
[after only "Completeness and clarity of description"]. There is a
reason why "FORMAT"s were commonly omitted from early compilers!
[...]
I've yet more such examples where ordinary "C" formatting would not
help.
I wasn't suggesting that "ordinary" C formatting replace A68's
"FORMAT"s; rather that the formatting routines should be implemented
by using strings and structures rather than by using "$ ... $". Eg,
your example
printf (($ n(UPB pattern_array)(2x g) l $, match (...) ))
might look more like
printf ((" n (2x g) l ", UPB pattern_array), match (...) )
[where the parameter to "n" is the next item in a structure rather
than inside the format string].
[...]
What you explain as a burden is what I consider its expressive power
(compared to, say, "C").
You don't need to compare with C, but rather with what A68 would
look like if formatting had been controlled in other ways than "$....$".
The burden is not so much what you, the user, have to learn, but what
the implementer has to do. Functions, strings, structures and so on
have to be provided anyway; formats are a serious added burden esp in
the lexing [for which standard tools such as Lex and Yacc are suitable
onlu with some difficulty]. [Note that the actual code for "printf"
and friends is largely given in A68 in the RR -- the difficulty is not
in providing much the same functionality, but in the parsing.]
Algol 68 is already a comparably complex language.
FORMAT is yet
another complex sub-language. It's quite obvious to me why this
feature might not have been implemented at first. OTOH, I thought
this would have been a basic inherent component of the standard,
so how could that have been omitted. (Unless you spoke about the
very early time, ~1968 vs. ~1976?)
On 28/08/2025 06:35, Janis Papanagnou wrote:
Algol 68 is already a comparably complex language.
It's a comparatively simple language [simpler than its main
competitors] that was badly mis-marketed.
No-one wrote an "Easy
Guide to A68", so for several years the only way to learn it was
to read the Report [and later the Revised Report], 200-ish pages
of largely impenetrable two-level grammar. Even the first textbooks
were either full of mistakes or had a level of "cleverness" and
abstraction that was completely unsuitable for student use.
The
size of the language was widely mocked, until it became clear that
formal descriptions of other languages were bigger [look at the
latest C standard and weep!], despite not being sufficiently formal
to describe the language properly [look again at C and weep!]. [I
could (and sometimes do) go on about this; sorry.]
[...]
On 25/08/2025 01:14, Janis Papanagnou wrote:
[I wrote:]
"FORMAT" adds around 50% to the A68>> syntax charts [eg from one pageWell, C's model is very primitive compared to Algol 68's.
(the Watt-Peck-Sintzoff chart) to
a page and a half]. We could get 95% of the power with no new
syntax at all by moving to a model more like C.
There's really interesting things you can do with that
FORMAT "sub-language".
Yes, but you could do ~95% of them without having a mode [type]
"FORMAT" that has a special syntax. There are a very few things that
would become somewhat harder, but virtually nothing that becomes really difficult.
To be clear, I'm not opposed to formatted transput [though
I don't personally make much use of it], nor to having a pre-defined
library of formatting commands; only to the invention of a special
type "FORMAT" to implement it. Also to be clear, I'm not advocating completely unstructured transput -- A68 provides conversion routines
for parametrised conversions from numbers to strings.
C shows how you can do the simple things by using a perfectly
normal string as a formatting parameter to "printf" and its friends.
By contrast, even lexing a FORMAT denotation is a right mess -- you
can't simply go from "$" to a closing "$" because the denotation may
include nested formats that may include arbitrary amounts of A68 code, including nested strings, comments and formats [that may include ...,
to arbitrary depth]. It's not impossible [obviously!], just a lot
harder than it ought to be.
Hmm.., well. I commonly only heared about it's been considered
huge and hard to (fully?) understand, sort of; IOW, "complex".
[...] I already find the texts that heavily use and rely on standards-specific language problematic. (Concerning Algol 68
Genie, BTW, these parts of its documentation I consider the
most repelling aspects of the otherwise fine manual.)
I wouldn't think, though, that languages like Pascal would have
more complex definitions.
I want to take up that sub-thread for another approach of my argument.
In the past I may have spread bits and pieces and hoped to trigger the associations that were sprouting in my mind. I hope this example below
shows why I think (most of all) that the FORMAT concept adds to A68's orthogonality and coherence, and (as a secondary issue and spin-off)
why some parts of the syntax were rightly chosen the way they are.
The example(s) use(s) "controlled" formatting and nested formats...[... equivalent C or unformatted A68 snipped ...]
For output I'm using, e.g.
FORMAT fmt = $ "Diagnosis " b("positive", "negative") l $;
printf ((fmt, act_state));
Now I'd wonder how I'd read in such formats. - To make it short; we'd
need the programmer write a generally complex, bulky, thus error-prone parser.
(And nesting of '$' symbols is also unnecessary, BTW.)
[...] imagine a "C" scanf that would be required to read and
differentiate string variants in input (here for example "positive", "negative", in the bool-controlled example; it's just not possible
I'd say, so an overly complex user defined parsing will be required).
On 30/08/2025 04:40, Janis Papanagnou wrote:
[...]Cf
Pascal, where there were decent texts from the start, compilers
from the start, and clever marketing -- it was described as a
"teaching" language [whatever that meant], and students had access
to full source.
Cf also Unix, which was free to universities and
came with source. So guess what universities taught CS students.
[...]
perforce, to do much the same.]
I wouldn't think, though, that languages like Pascal would have
more complex definitions.
Pascal is usually described by 6-12 pages of "railway track"
syntax charts or by several pages of BNF. The Watt-Peck-Sintzoff
syntax chart for A68 is one side [admittedly crammed in a bit], and
the BNF for A68-R is a page-and-a-half. Go figure. Of course, the
syntax charts aren't the only measure of complexity.
What, apart
from "FORMAT", do /you/ find "complex" in A68, and in what way is
equivalent Pascal simple?
As above, if the facility is sufficiently useful, it will be
provided as a library routine. You seem again to be assuming that the
whole concept of formatted transput would be zapped, and/or reduced
to what C provides. Not so. But in accordance with RR0.1.2, there's
little if any need for the [specific] "$ ... $" formats; much the
same functionality can be provided [more flexibly] by format strings,
and [therefore] with no new syntax.
On 30/08/2025 05:54, Janis Papanagnou wrote:
The example(s) use(s) "controlled" formatting and nested formats...[... equivalent C or unformatted A68 snipped ...]
For output I'm using, e.g.
FORMAT fmt = $ "Diagnosis " b("positive", "negative") l $;
printf ((fmt, act_state));
Now I'd wonder how I'd read in such formats. - To make it short; we'd
need the programmer write a generally complex, bulky, thus error-prone
parser.
(a) If you replace formats by strings, then there would be the
equivalent "parser" in the standard library. [...]
[...]
(And nesting of '$' symbols is also unnecessary, BTW.)
May be "unnecessary", but the language allows it, so a lexer has
to work around that.
[...] imagine a "C" scanf that would be required to read and
differentiate string variants in input (here for example "positive",
"negative", in the bool-controlled example; it's just not possible
I'd say, so an overly complex user defined parsing will be required).
As above, if the facility is sufficiently useful, it will be
provided as a library routine. You seem again to be assuming that the
whole concept of formatted transput would be zapped, and/or reduced
to what C provides.
Not so. But in accordance with RR0.1.2, there's
little if any need for the [specific] "$ ... $" formats; much the
same functionality can be provided [more flexibly] by format strings,
and [therefore] with no new syntax.
On Sun, 31 Aug 2025 00:44:09 +0100, Andy Walker wrote:
As above, if the facility is sufficiently useful, it will be
provided as a library routine. You seem again to be assuming that the
whole concept of formatted transput would be zapped, and/or reduced
to what C provides. Not so. But in accordance with RR0.1.2, there's
little if any need for the [specific] "$ ... $" formats; much the
same functionality can be provided [more flexibly] by format strings,
and [therefore] with no new syntax.
How would you ensure type-safeness? That is a notorious lack in the C-
style printf.
On Sun, 31 Aug 2025 00:44:09 +0100, Andy Walker wrote:
As above, if the facility is sufficiently useful, it will beHow would you ensure type-safeness?
provided as a library routine. You seem again to be assuming that the
whole concept of formatted transput would be zapped, and/or reduced
to what C provides. Not so. But in accordance with RR0.1.2, there's
little if any need for the [specific] "$ ... $" formats; much the
same functionality can be provided [more flexibly] by format strings,
and [therefore] with no new syntax.
That is a notorious lack in the C-C, OTOH, /does/ have C-style type punning.
style printf.
On 31/08/2025 09:12, Lawrence DrCOOliveiro wrote:
How would you ensure type-safeness?
A68 is type-safe by design.