Hello fredvs,

you wrote on Fri, 13 Mar 2020 17:19:37 -0700 (MST):

> With your code I get this:
> 
> $ /home/fred/weird/weirdtest
> 
> low: we_2, value: 2; high: we_decade, value: 20
> 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 
> we_2: 2Runtime error 107 at $0000000000401293
>   $0000000000401293
>   $000000000040104F
> 
> _______________________
> 
> Would you be happy with this:?

Yes, that's the expected result.

> Would you be happy with this:?

> PROGRAM weirdtest;
...
> TYPE weird = (we_2:= 2, we_5:= 5, we_next, we_more, we_decade:= 20);
> 
> const
>      weirdorder: Array[1..5] of weird=(we_2,we_5,we_next, we_more,
> we_decade);
...
>     we:=Low(weird);
>     for we in weirdorder
...

Except from multiple non-Pascal syntax elements, this is correct.
Although the initialization of "we" before the second "FOR" loop is
superfluous, it does no harm.
The FOR loop itself uses yet another fpc extension to the Pascal syntax,
the "in" operator applied to the elements of an array. The "in" operator
was originally only defined for sets, as it does not imply any ordering,
as is the case with sets in general.
But it can be found in many programming languages for other data types as
well (even Linux's bash implements it), and regarding the fact that any
computer (memory) resident data structure has, due to the one dimensional
structure of memory addresses, a "natural" or implied order, this kind of
use commonly works as naively expected.

> Gives as result:
> 
> $ /home/fred/weird/weirdtest
> 
> low: we_2, value: 2; high: we_decade, value: 20
> 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 
> we_2: 2 we_5: 5 we_next: 6 we_more: 7 we_decade: 20
         ^       ^          ^          ^
Not quite, it does not produce the spaces marked above...

But my point - that you addressed by introducing _yet another_ data
structure, the "weirdorder" array - was that there is _no_ possibility in
fpc to access the enum members directly in order. The standard functions
"pred"(ecessor) and "succ"(essor) _DON'T WORK_, so there's no natural way
to _enumerate_ an enumeration in fpc! What a glaring omission, no?

-- 
-- 
(Weitergabe von Adressdaten, Telefonnummern u.ä. ohne Zustimmung
nicht gestattet, ebenso Zusendung von Werbung oder ähnlichem)
-----------------------------------------------------------
Mit freundlichen Grüßen, S. Schicktanz
-----------------------------------------------------------




_______________________________________________
mseide-msegui-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to