Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 23 |
Nodes: | 6 (0 / 6) |
Uptime: | 54:25:57 |
Calls: | 583 |
Files: | 1,139 |
D/L today: |
179 files (27,921K bytes) |
Messages: | 111,776 |
One thing that bothered me, though, was that for PROC split
I needed a two-pass process. The reason for that is that it's
(to my knowledge) not possible to simply append to a 'FLEX'
array,
so that (to declare the result array; see # <<<<<< # )[...]
I first needed a separate pass to determine the number of its
elements.
Any suggestions how to (sensibly) avoid a two-pass process?
On 26/08/2025 05:47, Janis Papanagnou wrote:
[...]
One thing that bothered me, though, was that for PROC split
I needed a two-pass process. The reason for that is that it's
(to my knowledge) not possible to simply append to a 'FLEX'
array,
Correct. "FLEX" does not mean "do anything you like to this
array"!
so that (to declare the result array; see # <<<<<< # )[...]
I first needed a separate pass to determine the number of its
elements.
Any suggestions how to (sensibly) avoid a two-pass process?
(a) You could declare the "result" array before the first pass,
giving it as many rows as the maximum possible [apart from edge effects, that's the length of "str" divided by the minimum length of the pattern matched]. Then you can fill in rows of "result" as you find them, and
for the final result return the slice "result [ : count ]".
(b) You could construct a list of the strings found [eg,
"MODE STRINGLIST = STRUCT (REF STRING element, REF STRINGLIST next);",
and add a new element to the list whenever you find a match. Then the
result is constructed by traversing the list. I've used a "REF STRING" rather than a "STRING" to avoid copying each string twice.
[...]
BTW; WRT your list suggestion. I implemented a list for some other
Algol 68 application. Of course with my OO background I wanted some
generic form that could be used (without reimplementation for other applications) in many contexts. It seems nearly impossible without
genericity and inheritance in Algol 68. (A similar attempt I tried
for a flexible hashmap for a 'map' type.) I saw that solutions on
the Internet are also type/application specific. - How do you model
such things in Algol 68?
On 28/08/2025 06:51, Janis Papanagnou wrote:
BTW; WRT your list suggestion. I implemented a list for some other
Algol 68 application. Of course with my OO background I wanted some
generic form that could be used (without reimplementation for other
applications) in many contexts. It seems nearly impossible without
genericity and inheritance in Algol 68. (A similar attempt I tried
for a flexible hashmap for a 'map' type.) I saw that solutions on
the Internet are also type/application specific. - How do you model
such things in Algol 68?
With difficulty! Sorry.
There was a proposal to add modals
[variable modes] to A68 [...snip link...] which would have enabled
generic list processing and the like, but as far as I know it has
never been implemented in A68.
I mentioned it
to Marcel as a possible extension to A68G, but he didn't bite. On the
other hand, the immediately preceding paper in AB 37 [same URL but with
42 instead of 43] was about partial parametrisation, which Marcel /did/
add to A68G. So perhaps if you ask nicely ....
I'd like to discuss with you some of these requests (maybe another
day); I'd be interested to hear your opinions...
On 30/08/2025 04:54, Janis Papanagnou wrote:
[...]
I'd like to discuss with you some of these requests (maybe another
day); I'd be interested to hear your opinions...
So would I. [:-)]