With procedures I may do
PROC cw = (INT pos) INT : (pos MOD 3) + 1;
PROC ccw = (INT pos) INT : ((pos+1) MOD 3) + 1;
PROC (INT) INT next := ( ODD n | ccw | cw );
where the assignment would evaluate the conditional (once) but
every call of 'next' would just call the assigned function.
But with operators that seems not possible...?
OP CW = (INT pos) INT : (pos MOD 3) + 1;
OP CCW = (INT pos) INT : ((pos+1) MOD 3) + 1;
OP (INT) INT CONT := ( ODD n | CCW | CW );
On 13/09/2025 19:07, Janis Papanagnou wrote:
[...]
With procedures I may do
PROC cw = (INT pos) INT : (pos MOD 3) + 1;
PROC ccw = (INT pos) INT : ((pos+1) MOD 3) + 1;
PROC (INT) INT next := ( ODD n | ccw | cw );
where the assignment would evaluate the conditional (once) but
every call of 'next' would just call the assigned function.
But with operators that seems not possible...?
Well, not in A68, nor currently in A68G.
Good luck in
persuading Marcel that it's an important enough omission to be
added to some future version! ...
OP CW = (INT pos) INT : (pos MOD 3) + 1;
OP CCW = (INT pos) INT : ((pos+1) MOD 3) + 1;
OP (INT) INT CONT := ( ODD n | CCW | CW );
... You have two syntax errors.
(a) There are no operator
variables, so "OP ... CONT := whatever" is illegal. You need
"OP ... CONT = whatever". (b) In "( foo | goo | hoo )", "goo" and
"hoo" are serial clauses. An expression is a perfectly good serial
clause, so "ccw" [eg] in your working version is fine, but "CCW" is
not an expression [nor, for example, is "-"].
[...]
Good luck inErm.. - do you consider it important?
persuading Marcel that it's an important enough omission to be
added to some future version! ...
(And an omission in Algol 68?)
To be honest; I didn't intend to ask for something that wasn't even
part of the Algol 68 definition (if that's actually the case).
(a) There are no operatorWell, on that level of explanation, 'ccw' is also incomplete without
variables, so "OP ... CONT := whatever" is illegal. You need
"OP ... CONT = whatever". (b) In "( foo | goo | hoo )", "goo" and
"hoo" are serial clauses. An expression is a perfectly good serial
clause, so "ccw" [eg] in your working version is fine, but "CCW" is
not an expression [nor, for example, is "-"].
its arguments; the point was that it's not used as a call but as a
sort of reference to the PROC.
I've just tried to make use of such a
definition also with OPs.
On 14/09/2025 18:02, Janis Papanagnou wrote:
[...] The real point in
the present context is that the compiler knows, from its declaration,
what its mode [type] is, and therefore knows how to compile the clause
of which it is part. Whereas ...
I've just tried to make use of such a
definition also with OPs.
... operators in general have different priorities and may have
multiple definitions [think "-" or "ABS" or "PLUSAB"], so are impossible
to parse absent the operands.
It would probably be possible to parse
some instances, but writing out a reliable description of which cases
can be parsed at compile time and which would be ambiguous [and thereby illegal] is non-trivial [and perhaps undecidable?]. [...]
On 15.09.2025 15:56, Andy Walker wrote:
It would probably be possible to parse
some instances, but writing out a reliable description of which cases
can be parsed at compile time and which would be ambiguous [and thereby
illegal] is non-trivial [and perhaps undecidable?]. [...]
Yes, the non-overloading of OPs is a (the?) hindrance here [Algol 68]. (Unlike C++ where differentiations _based on argument types_ are
possible for both, functions and operators - but based on a simpler
grammar approach.)
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,070 |
Nodes: | 10 (0 / 10) |
Uptime: | 171:05:17 |
Calls: | 13,735 |
Calls today: | 1 |
Files: | 186,967 |
D/L today: |
184 files (54,870K bytes) |
Messages: | 2,419,004 |