Hello fredvs,

you wrote on Thu, 12 Mar 2020 02:22:15 -0700 (MST):

> > BTW, I'd suggest to use the word "illegal"   
> 
> Ha, ok, in last commit I did use "none" or "nil", I will change it asap.

The name has no function, so I think it should be chosen on intended
function. If the member is used just to satisfy the syntax, "nil" or "none"
are alright. If it is used to signify a state outside the normal range or
even not normally allowable, "undefined" or even "illegal" seem appropriate
to me, because those names express the meaning "literally".

> > tabulatorkindty = (tak_illegal:= -1, tak_left, tak_right,
> > tak_centered,tak_decimal);   

From your examples of Martin's use, and the fact that he expressly used a
value outside the bounds of the enumeration, I derived the impression that,
indeed, this special value was meant to signify some illegal state. That's
why I suggested "_illegal" here.

> Like explained to Roland, in last commits I did place "tak_illegal" as
> last member of the enum.

Commonly, the placement of the members has no significance as long as
they're not used for enumeration, as in a "for" or "while" statement, where
a variable of the type is in- or decremented through some defined range.
If that is done, you have to be aware of the specific _sequence_ of the
members, and that's where their placement will be of importance.

> Take this original example:
> 
> scrollbarareaty =
> (sbbu_down,sbbu_move,sbbu_up,sba_start,sba_end,sba_clicked,sba_none)
> ...
> const
>  scrollbarclicked = ord(sba_end) + 1;
> 
> You may see that Martin did add a "extended" value for scrollbarareaty:
> scrollbarclicked.

Not exactly - he defined an _integer_ constant having the value given by
the _position_ of "tba_end" in its enumeration, plus one.

> This is not "catholic" so I did add 2 members in the enum:
> sba_clicked,sba_none and adapt the code for it:
> 
> scrollbarareaty =
> (sbbu_down,sbbu_move,sbbu_up,sba_start,sba_end,sba_clicked,sba_none);
> 
> In that case the order is important, because at a moment, this is called
> in original code:
> 
> bu1:= low(scrollbarareaty) to high(scrollbarareaty)

Yes, that's exactly the case where it is important, the enumeration is
scanned sequentially, enumerated, that is.

> So it was changed with: 
> 
> bu1:= low(scrollbarareaty) to high(scrollbarareaty)-2

You mean, it was changed _from_ this expression?
Yes, your way is the more elegant one, and regarding the constant
definition, it may well be what was really intended, but because of some
condition not immediately done cleanly.

you wrote on Thu, 12 Mar 2020 03:08:01 -0700 (MST):

...
> Of course the order of enum has no influence on bu1:= low(scrollbarareaty)
> to high(scrollbarareaty).

Not on the bounds, but on the sequence of members within, which _is_ "the
order of enum".

> But, (trust me), it was more easy if "sba_none" was placed at end than at
> begin of enum.

And it was quite correct for this purpose.

...
> Of course "sba_none" placed at begin works also, but more code is needed
> for this.

Sure, that way, you change the main property of the enumeration, its
_order_.

> But if you really prefer "sba_none" placed at first place, I will change
> it with pleasure (asap).

No, as that's not a matter of "preference" here, but a matter of _use_.
And that's clearly demonstrated by what you wrote later:

you wrote on Thu, 12 Mar 2020 10:29:20 -0700 (MST):

> > scrollbarclicked = ord(sba_end) + 1; // not a "good boy" code.   

Right.

> Imho, it is not a  "good boy" code because later there is:
> 
> ---> if kind = scrollbarareaty(scrollbarclicked) then // this gives a  
> warning with fpc 3.2.0, not fpc 3.0.4.

Yes, this triggered the "out of bounds" warning for enumeration values that
seems to have been added to the later version of fpc.

> OK, I stop before to become (stay) completely crazy.

Why could that drive someone crazy, if he thought somewhat about the
purpose and construction of enumerations? You probabely won't get crazy,
e.g., if someone tells you he wants to get to the third seat in a theater
seat row that's number from 124 to 188 - you probabely can tell him
immediately he should take seat number 126, don't you?

-- 
-- 
(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