Re: [MSEide-MSEgui-talk] About Warnings with mseide + fpc 3.0.4 / 3.2.0
Hello fredvs, you wrote on Wed, 11 Mar 2020 02:22:07 -0700 (MST): > Here a example maybe more clear: Let's see... > msedrawtext.pas(1115,48) Warning: range check error while evaluating > constants (-1 must be between 0 and 3) > > This warning point to: > > ---> if (kind <> tabulatorkindty(-1)) > > and tabulatorkindty is declared as: > > ---> tabulatorkindty = (tak_left,tak_right,tak_centered,tak_decimal); So the type of the cast is an enumeration type, an ordinal value, that, basically, will not be negative usually. It might even be regarded as not having a value in the first place, but just specifying an arbitrary ordering (hence the name "ordinal"). > So, if I understand ok, with new feature of fpc, "-1" is no more permitted > as default. This is not a "new feature", but a design principle. It might be seen as a "new feature" that the use of an out-of-bounds value for an enumeration mamber is flagged as a warning. (If it's not appearing simply because in this specific code area the pertinent warning is for some reason no longer disabled.) > What do you think, must a new constant be added in the array, this for the > default value, something like: > > ---> tabulatorkindty = (tak_left,tak_right,tak_centered,tak_decimal, > tak_none); There's a simple way to resolve this: You got to throw good Pascal design principles over bord and introduce mainly, let's say, type indifferent C usage. In this case, you ought to apply the "assigned enumeration" type "extension" of fpc, which allows you to _define_ enumeration menmber's values explicitely instead of enumerating them sequentially. (fpc reference manual, Types - Base types - Ordinal types - Enumeration types.) > ? Yes, that is plain type ignorant C style. > And then initialize it with: > > ---> if (kind <> tabulatorkindty(tak_none) ? Maybe, the name of this queer member ist unimportant, you may use this name, if only you _assign_ it the value you want it to represent. I.e. you had to define the extended enumeration like this: tabulatorkindty = (tak_none:= -1, tak_left{:= 0, but that's so anyway}, tak_right, tak_centered,tak_decimal); That way, everything keeps its well known order and value, and the new value is added as a _legal_ member of the sequence, even with the "illegally" added extraneous value used in the statement causing the warning. This can even be written without the cast then, because it now references a _legal_ member of the type: if (kind <> tak_none) ... > If so, maybe **lot of** work because Martin did use "-1" in many case. He seems not having been aware of this extension to the enumeration type, then. (It's part of fpc's definition since at least version 2.1!) Doing it this way, the amount of required work should not be so enormous. Only the type definitions where such constructs are used need to be fixed. (You might even decide to keep the casts from -1 to save on modifications.) BTW, I'd suggest to use the word "illegal" (or maybe "undefined") as the base name for these extraneous additional enumeration members, like, for the example above: tabulatorkindty = (tak_illegal:= -1, tak_left, tak_right, tak_centered,tak_decimal); resulting in if (kind <> tak_illegal) ... for the example use, which might even better represent its intention, too. -- -- (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 mseide-msegui-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Re: [MSEide-MSEgui-talk] About Warnings with mseide + fpc 3.0.4 / 3.2.0
Hello Roland. > but I am sure that"tabulatorkindty(tak_nil)" can be replaced with > "tak_nil". ;-) OK, done in last commit b7be824. Fre;D -- Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/ ___ mseide-msegui-talk mailing list mseide-msegui-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Re: [MSEide-MSEgui-talk] About Warnings with mseide + fpc 3.0.4 / 3.2.0
Hello Fred! Thank you for your answer, and for the schmilblick. I don't know which order is better, but I am sure that "tabulatorkindty(tak_nil)" can be replaced with "tak_nil". Regards. Roland -- Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/ ___ mseide-msegui-talk mailing list mseide-msegui-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Re: [MSEide-MSEgui-talk] About Warnings with mseide + fpc 3.0.4 / 3.2.0
Hello Roland. Sorry, I did commit some change following the advises of fpc-mailing list: https://github.com/mse-org/mseide-msegui/commit/ Of course it can be changed but is is to make advance the "schmilblick". It takes the same idea as yours, the only thing changed is that tak_nil is placed at end of the enum. This because sometime ord() is used and so the order of each enum is maintained. And in place to use "-1" "tak_nil" is used: kind := tabulatorkindty(tak_nil); // this to initialize if kind = tabulatorkindty(tak_nil) then // this in code And this for mainly all warnings. I left, for the sport, 2 warnings, feel free the fix it ! Fre;D -- Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/ ___ mseide-msegui-talk mailing list mseide-msegui-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Re: [MSEide-MSEgui-talk] About Warnings with mseide + fpc 3.0.4 / 3.2.0
For me, I don't understand "tabulatorkindty(-1)". I don't understand why FPC 3.0.4 accept it without even a warning. With FPC 3.0.4, the following code compiles without warning and works: type tabulatorkindty = (ak_left, tak_right, tak_centered, tak_decimal); var kind: tabulatorkindty; begin kind := tabulatorkindty(-1); if kind = tabulatorkindty(-1) then WriteLn('hello'); end. Maybe we could make the following modification? type tabulatorkindty = (tak_nil = -1, tak_left, tak_right, tak_centered, tak_decimal); -- Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/ ___ mseide-msegui-talk mailing list mseide-msegui-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Re: [MSEide-MSEgui-talk] About Warnings with mseide + fpc 3.0.4 / 3.2.0
Hello Code DZ and all others. > so i think this list should be extended Maybe. But after the conversation in: http://free-pascal-general.1045716.n5.nabble.com/New-Warnings-with-fpc-gt-3-2-0-td5734996.html Maybe also some code should be fixed with the "good boy" way. So the question is: Should we add some {$warn xxx off} or fix original mse code with the "good boy" way? Fre;D -- Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/ ___ mseide-msegui-talk mailing list mseide-msegui-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Re: [MSEide-MSEgui-talk] About Warnings with mseide + fpc 3.0.4 / 3.2.0
Hi fred i don't know why martin has disable some warnings while ago and not fixing it you may have seen this in every msegui unit : {$if fpc_fullversion >= 030100} {$warn 5089 off} {$warn 5090 off} {$warn 5093 off} {$warn 6058 off} {$endif} so i think this list should be extended ___ mseide-msegui-talk mailing list mseide-msegui-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Re: [MSEide-MSEgui-talk] Procedure List add-on for MSEide
Hello Graeme. I did fix for the warnings in commit 5aa6640. Fre;D -- Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/ ___ mseide-msegui-talk mailing list mseide-msegui-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Re: [MSEide-MSEgui-talk] About Warnings with mseide + fpc 3.0.4 / 3.2.0
Hello. I did create a new topic about this in fpc mailing-list: http://free-pascal-general.1045716.n5.nabble.com/New-Warnings-with-fpc-gt-3-2-0-td5734996.html Maybe some light from there... Fre;D -- Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/ ___ mseide-msegui-talk mailing list mseide-msegui-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk
Re: [MSEide-MSEgui-talk] About Warnings with mseide + fpc 3.0.4 / 3.2.0
Hello Seighard. Here a example maybe more clear: msedrawtext.pas(1115,48) Warning: range check error while evaluating constants (-1 must be between 0 and 3) This warning point to: ---> if (kind <> tabulatorkindty(-1)) and tabulatorkindty is declared as: ---> tabulatorkindty = (tak_left,tak_right,tak_centered,tak_decimal); So, if I understand ok, with new feature of fpc, "-1" is no more permitted as default. What do you think, must a new constant be added in the array, this for the default value, something like: ---> tabulatorkindty = (tak_left,tak_right,tak_centered,tak_decimal, tak_none); ? And then initialize it with: ---> if (kind <> tabulatorkindty(tak_none) ? If so, maybe **lot of** work because Martin did use "-1" in many case. Fre;D -- Sent from: http://mseide-msegui-talk.13964.n8.nabble.com/ ___ mseide-msegui-talk mailing list mseide-msegui-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk