Re: [fpc-pascal] case statement

2023-12-25 Thread Steve Litt via fpc-pascal
Gerhard Scholz via fpc-pascal said on Sat, 16 Dec 2023 20:07:45 +0100 >I never had the problem because before the else I always inserted a ";" I know it's 50+ years too late for me to submit ideas for the Pascal language, but in my perfect world you could put a semicolon at the end of anything,

Re: [fpc-pascal] case statement

2023-12-17 Thread Bernd Oppolzer via fpc-pascal
Am 17.12.2023 um 16:36 schrieb Adriaan van Os via fpc-pascal: As the otherwise-clause is not in ISO-7185 Pascal, it seems more plausible that Borland invented the else-clause (without semicolon) independently. All other Pascals I have looked at, use an otherwise-clause (with an obligatory sem

Re: [fpc-pascal] case statement

2023-12-17 Thread Adriaan van Os via fpc-pascal
Tony Whyman via fpc-pascal wrote: Back in the early eighties, I worked at ICL and we made extensive use of the Prospero Pascal compiler building embedded systems based on the Z80 microprocessor. I still have a 1988 edition of the language specification, and this uses EBNF to define the case st

Re: [fpc-pascal] case statement

2023-12-17 Thread Bernd Oppolzer via fpc-pascal
Am 17.12.2023 um 06:12 schrieb Adriaan van Os via fpc-pascal: Anyway, the innocent looking case-statement does have some interesting aspects. Indeed. My Stanford compiler tries to be portable across platforms; due to its IBM mainframe heritage even on platforms that have "strange" charact

Re: [fpc-pascal] case statement

2023-12-16 Thread Adriaan van Os via fpc-pascal
I find the idea of a "closest containing value" rather weird. For me, programming is strict logic, not finding something "closest". What I wrote here, is nonsense. "Closest containing" is rather a grammatical concept, that I misunderstood. Regards, Adriaan van Os __

Re: [fpc-pascal] case statement

2023-12-16 Thread Adriaan van Os via fpc-pascal
Tony Whyman via fpc-pascal wrote: Prospero Pascal was close to ISO Pascal (although I have lost my original copy of ISO Pascal) and I would guess that the above is copied from ISO Pascal. You can find the ISO-7185 document on the internet, just search for "iso7185.pdf". A less known aspect

Re: [fpc-pascal] case statement

2023-12-16 Thread Tony Whyman via fpc-pascal
On 16/12/2023 19:07, Gerhard Scholz via fpc-pascal wrote: ELSE/OTHERWISE I assume that came historically; the first implementation of a PASCAL compiler I have seen had no else or otherwise in the case startement. Some ater dialects introduced ELSE, other dialect(s) used OTHERWISE, FPC then a

Re: [fpc-pascal] case statement

2023-12-16 Thread Gerhard Scholz via fpc-pascal
the problem because before the else I always inserted a ";" ----- Original Message - From: "Adriaan van Os via fpc-pascal" To: "FPC-Pascal users discussions" Cc: "Adriaan van Os" Sent: Thursday, December 14, 2023 4:53 PM Subject: [fpc-pascal] ca

Re: [fpc-pascal] case statement

2023-12-16 Thread Michael Van Canneyt via fpc-pascal
On Fri, 15 Dec 2023, Adriaan van Os wrote: Michael Van Canneyt via fpc-pascal wrote: The fact that the semicolon before the else is optional ? I don't see a semicolon in the formal syntax. This works: OK, than an optional semicolon must be added to the rule exceptionhandlers = [ ex

Re: [fpc-pascal] case statement

2023-12-15 Thread Adriaan van Os via fpc-pascal
Jean SUZINEAU via fpc-pascal wrote: Le 15/12/2023 à 10:39, Adriaan van Os via fpc-pascal a écrit : I don't see a semicolon in the formal syntax. May be included in the ' "DO" statement ' ? No, have a look at the syntax diagrams, statements never end with a semicolon. Regards, Adriaan van Os

Re: [fpc-pascal] case statement

2023-12-15 Thread Adriaan van Os via fpc-pascal
Michael Van Canneyt via fpc-pascal wrote: The fact that the semicolon before the else is optional ? I don't see a semicolon in the formal syntax. This works: OK, than an optional semicolon must be added to the rule exceptionhandlers = [ exception-handler { ";" exception-handler } [ ";"

Re: [fpc-pascal] case statement

2023-12-15 Thread Jean SUZINEAU via fpc-pascal
Le 15/12/2023 à 10:39, Adriaan van Os via fpc-pascal a écrit : I don't see a semicolon in the formal syntax. May be included in the ' "DO" statement ' ? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/ma

Re: [fpc-pascal] case statement

2023-12-15 Thread Michael Van Canneyt via fpc-pascal
On Fri, 15 Dec 2023, Adriaan van Os via fpc-pascal wrote: Michael Van Canneyt via fpc-pascal wrote: On Fri, 15 Dec 2023, Adriaan van Os via fpc-pascal wrote: Note that the same ambiguity exists in the syntax (and this is less well known) exceptionhandlers = [ exception-handler { ";"

Re: [fpc-pascal] case statement

2023-12-15 Thread Adriaan van Os via fpc-pascal
Michael Van Canneyt via fpc-pascal wrote: On Fri, 15 Dec 2023, Adriaan van Os via fpc-pascal wrote: Note that the same ambiguity exists in the syntax (and this is less well known) exceptionhandlers = [ exception-handler { ";" exception-handler } [ "ELSE" statement-list ] | statement-list

Re: [fpc-pascal] case statement

2023-12-15 Thread Michael Van Canneyt via fpc-pascal
On Fri, 15 Dec 2023, Adriaan van Os via fpc-pascal wrote: Note that the same ambiguity exists in the syntax (and this is less well known) exceptionhandlers = [ exception-handler { ";" exception-handler } [ "ELSE" statement-list ] | statement-list ] . exception-handler = "ON" [ identifier

Re: [fpc-pascal] case statement

2023-12-15 Thread Adriaan van Os via fpc-pascal
Note that the same ambiguity exists in the syntax (and this is less well known) exceptionhandlers = [ exception-handler { ";" exception-handler } [ "ELSE" statement-list ] | statement-list ] . exception-handler = "ON" [ identifier ":" ] class-type-identifier "DO" statement . as ends with

Re: [fpc-pascal] case statement

2023-12-14 Thread James Richters via fpc-pascal
ber 14, 2023 3:16 PM To: fpc-pascal@lists.freepascal.org Cc: Martin Wynne Subject: Re: [fpc-pascal] case statement I've been using ELSE in IF statements and in CASE statements for 25 years without realising there was a problem. What a dim-wit I have been. Martin. __

Re: [fpc-pascal] case statement

2023-12-14 Thread Martin Wynne via fpc-pascal
I've been using ELSE in IF statements and in CASE statements for 25 years without realising there was a problem. What a dim-wit I have been. Martin. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailma

Re: [fpc-pascal] case statement

2023-12-14 Thread Adriaan van Os via fpc-pascal
James Richters via fpc-pascal wrote: I didn’t know there was such a thing as OTHERWISE. Is there any functional difference between OTHERWISE and ELSE? No. It is just that OTHERWISE doesn't have the IF-THEN-ELSE ambiguity. Macintosh Pascal compilers had OTHERWISE but not ELSE. Maybe, OTHERWIS

Re: [fpc-pascal] case statement

2023-12-14 Thread Sven Barth via fpc-pascal
James Richters via fpc-pascal schrieb am Do., 14. Dez. 2023, 20:13: > I didn’t know there was such a thing as OTHERWISE. Is there any > functional difference between OTHERWISE and ELSE? > "otherwise" is what had been defined by ISO Extended Pascal for the cause-statement. Aside from not having

Re: [fpc-pascal] case statement

2023-12-14 Thread James Richters via fpc-pascal
I didn’t know there was such a thing as OTHERWISE. Is there any functional difference between OTHERWISE and ELSE? James ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] case statement

2023-12-14 Thread Adriaan van Os via fpc-pascal
Michael Van Canneyt via fpc-pascal wrote: On Thu, 14 Dec 2023, Adriaan van Os via fpc-pascal wrote: I am looking in detail at the syntax diagrams in the Freepascal Language Reference (version 3.2.0) Section 13.2.2 discusses the case-statement. Translated to EBNF (WSN) the syntax is cas

Re: [fpc-pascal] case statement

2023-12-14 Thread Michael Van Canneyt via fpc-pascal
On Thu, 14 Dec 2023, Adriaan van Os via fpc-pascal wrote: I am looking in detail at the syntax diagrams in the Freepascal Language Reference (version 3.2.0) Section 13.2.2 discusses the case-statement. Translated to EBNF (WSN) the syntax is case-statement = "CASE" expression "OF" case

Re: [fpc-pascal] case statement

2023-12-14 Thread Bart via fpc-pascal
On Thu, Dec 14, 2023 at 5:01 PM Adriaan van Os via fpc-pascal wrote: > I always use "OTHERWISE instead of ELSE, but that's my personal > preference. +1 Seeing OTHERWISE in source code just makes me smile. -- Bart ___ fpc-pascal maillist - fpc-pasc

[fpc-pascal] case statement

2023-12-14 Thread Adriaan van Os via fpc-pascal
I am looking in detail at the syntax diagrams in the Freepascal Language Reference (version 3.2.0) Section 13.2.2 discusses the case-statement. Translated to EBNF (WSN) the syntax is case-statement = "CASE" expression "OF" case { ";" case } [ else-part ] [ ";" ] . case = constant [ ".." con

Re: [fpc-pascal] Case statement for class introspection

2022-01-20 Thread Ryan Joseph via fpc-pascal
> On Jan 20, 2022, at 8:10 PM, Ryan Joseph wrote: > > I just check at https://gitlab.com/freepascal.org/fpc/source/-/merge_requests > and I don't see my merge request appeared. If it were GitHub I would expect > to see it there. What did I do wrong? So what I did was created a merge request

Re: [fpc-pascal] Case statement for class introspection

2022-01-20 Thread Ryan Joseph via fpc-pascal
> On Jan 20, 2022, at 9:11 AM, Ryan Joseph wrote: > > The problem was my remote for the branch got lost after rebasing but I think > I fixed it by re-pulling. > > It looks like some unrelated commits are included in my merge request but > maybe that happened because I rebased the repo after

Re: [fpc-pascal] Case statement for class introspection

2022-01-19 Thread Ryan Joseph via fpc-pascal
> On Jan 19, 2022, at 8:14 PM, Ryan Joseph wrote: > > Ok I got this almost done (mirroring is great I didn't know I could do that) > and did the rebase which shows the linear history now. > > First a question, do I need to do the "rebase main" again before I push to > remote or does it stay

Re: [fpc-pascal] Case statement for class introspection

2022-01-19 Thread Ryan Joseph via fpc-pascal
Ok I got this almost done (mirroring is great I didn't know I could do that) and did the rebase which shows the linear history now. First a question, do I need to do the "rebase main" again before I push to remote or does it stay this way now? Problem is I go to push the changes to the my remo

Re: [fpc-pascal] Case statement for class introspection

2022-01-19 Thread Michael Van Canneyt via fpc-pascal
On Wed, 19 Jan 2022, Ryan Joseph via fpc-pascal wrote: On Jan 19, 2022, at 4:19 PM, Ryan Joseph wrote: Still not following this. Do you need me to do a pull-rebase from main and then make my pull request? I used git at work everyday but I'm still a newbie in many ways. Reading this no

Re: [fpc-pascal] Case statement for class introspection

2022-01-19 Thread Ryan Joseph via fpc-pascal
> On Jan 19, 2022, at 4:19 PM, Ryan Joseph wrote: > > Still not following this. Do you need me to do a pull-rebase from main and > then make my pull request? I used git at work everyday but I'm still a newbie in many ways. Reading this now but I'm confused because it seems too late. Please p

Re: [fpc-pascal] Case statement for class introspection

2022-01-19 Thread Ryan Joseph via fpc-pascal
> On Jan 19, 2022, at 4:15 PM, Michael Van Canneyt > wrote: > > It's explained in the page that Sven referred to ? > > It's only when you merge into your feature branch from the main branch that > you will see an effect. Still not following this. Do you need me to do a pull-rebase from main

Re: [fpc-pascal] Case statement for class introspection

2022-01-19 Thread Michael Van Canneyt via fpc-pascal
On Wed, 19 Jan 2022, Ryan Joseph via fpc-pascal wrote: On Jan 19, 2022, at 1:26 PM, Sven Barth wrote: We also take merge requests. If you have a fork anyway, then a merge request is probably easier. Though you need to have your repository set up to use rebasing instead of merging, see h

Re: [fpc-pascal] Case statement for class introspection

2022-01-18 Thread Ryan Joseph via fpc-pascal
> On Jan 19, 2022, at 1:26 PM, Sven Barth wrote: > > We also take merge requests. If you have a fork anyway, then a merge request > is probably easier. Though you need to have your repository set up to use > rebasing instead of merging, see here: > https://wiki.freepascal.org/FPC_git#Update

Re: [fpc-pascal] Case statement for class introspection

2022-01-18 Thread Sven Barth via fpc-pascal
Am 19.01.2022 um 02:48 schrieb Ryan Joseph via fpc-pascal: On Jan 18, 2022, at 5:28 AM, Sven Barth wrote: The values will have the same differences between each other upon each start so ideally this would work anyway, but if one also throws dynamic packages into the mix things would get mes

Re: [fpc-pascal] Case statement for class introspection

2022-01-18 Thread Ryan Joseph via fpc-pascal
> On Jan 18, 2022, at 5:28 AM, Sven Barth wrote: > > The values will have the same differences between each other upon each start > so ideally this would work anyway, but if one also throws dynamic packages > into the mix things would get messed up. So better stay with the if-clauses. Here's

Re: [fpc-pascal] Case statement for class introspection

2022-01-17 Thread Sven Barth via fpc-pascal
Am 17.01.2022 um 13:58 schrieb Ryan Joseph via fpc-pascal: On Jan 17, 2022, at 5:09 PM, Sven Barth wrote: The VMT writer already does that, cause the VMT pointer is required for each constructor call. The pointer to the VMT table is just PVmt(self) right? If I make a program and do: writ

Re: [fpc-pascal] Case statement for class introspection

2022-01-17 Thread Ryan Joseph via fpc-pascal
> On Jan 17, 2022, at 5:09 PM, Sven Barth wrote: > > The VMT writer already does that, cause the VMT pointer is required for each > constructor call. > The pointer to the VMT table is just PVmt(self) right? If I make a program and do: writeln(PtrUInt(TObject.ClassType)); the address chan

Re: [fpc-pascal] Case statement for class introspection

2022-01-17 Thread Sven Barth via fpc-pascal
Ryan Joseph via fpc-pascal schrieb am Mo., 17. Jan. 2022, 08:53: > > > > On Jan 17, 2022, at 1:55 PM, Sven Barth > wrote: > > > > Question then is how you get the VMT address as a constant at compile > time. > > > > I'll need to get back to you with that. > > > > I didn't test yet but I think wh

Re: [fpc-pascal] Case statement for class introspection

2022-01-16 Thread Ryan Joseph via fpc-pascal
> On Jan 17, 2022, at 1:55 PM, Sven Barth wrote: > > Question then is how you get the VMT address as a constant at compile time. > > I'll need to get back to you with that. > I didn't test yet but I think what you're saying is that VMT writer would need to have generated this address in ad

Re: [fpc-pascal] Case statement for class introspection

2022-01-16 Thread Sven Barth via fpc-pascal
Ryan Joseph via fpc-pascal schrieb am Mo., 17. Jan. 2022, 02:38: > > > > On Jan 16, 2022, at 11:15 PM, Sven Barth > wrote: > > > > The class type already is a unique "ID" for each class type when doing > an equal comparison. You can essentially take the address of the VMT as the > constant value

Re: [fpc-pascal] Case statement for class introspection

2022-01-16 Thread Ryan Joseph via fpc-pascal
> On Jan 16, 2022, at 11:15 PM, Sven Barth wrote: > > The class type already is a unique "ID" for each class type when doing an > equal comparison. You can essentially take the address of the VMT as the > constant values that the loaded value is compared against. Does that look something lik

Re: [fpc-pascal] Case statement for class introspection

2022-01-16 Thread Sven Barth via fpc-pascal
Am 16.01.2022 um 15:25 schrieb Ryan Joseph via fpc-pascal: On Jan 16, 2022, at 9:01 PM, Ryan Joseph wrote: case PtrUInt(o.ClassType) of 4500656856: writeln('TObject'); end; I may have spoken too soon and without thinking the through clearly (it's getting late here!). For this to wor

Re: [fpc-pascal] Case statement for class introspection

2022-01-16 Thread Ryan Joseph via fpc-pascal
> On Jan 16, 2022, at 9:01 PM, Ryan Joseph wrote: > > case PtrUInt(o.ClassType) of >4500656856: writeln('TObject'); > end; I may have spoken too soon and without thinking the through clearly (it's getting late here!). For this to work we would need a unique ID in the RTTI, right? I don

Re: [fpc-pascal] Case statement for class introspection

2022-01-16 Thread Ryan Joseph via fpc-pascal
> On Jan 16, 2022, at 8:18 PM, Ryan Joseph wrote: > > https://gitlab.com/genericptr/free-pascal/-/commits/case_label_classref I just realized too late that the way I implemented this may be not the best idea. If the class type had an ordinal representation then you could use a normal case st

Re: [fpc-pascal] Case statement for class introspection

2022-01-16 Thread Ryan Joseph via fpc-pascal
> On Jan 16, 2022, at 8:38 PM, Marco van de Voort via fpc-pascal > wrote: > > What does it print in this case? I mean tobject matches, and > tinterfacedobject too. > > The most logic solution would be to only run the most specialized case? It would print the name of the class if it didn't e

Re: [fpc-pascal] Case statement for class introspection

2022-01-16 Thread Marco van de Voort via fpc-pascal
On 16-1-2022 14:18, Ryan Joseph via fpc-pascal wrote: I had some fun today on my day off and managed to actually implement this based on the if-statement based string case labels. Is the compiler team interested in this feature? I think it's a clearly useful addition to OOP and an appropriate

Re: [fpc-pascal] Case statement for class introspection

2022-01-16 Thread Ryan Joseph via fpc-pascal
I had some fun today on my day off and managed to actually implement this based on the if-statement based string case labels. Is the compiler team interested in this feature? I think it's a clearly useful addition to OOP and an appropriate new use of the case statement. https://gitlab.com/gener

Re: [fpc-pascal] Case statement for class introspection

2022-01-16 Thread Ryan Joseph via fpc-pascal
> On Jan 16, 2022, at 2:35 PM, Michael Van Canneyt via fpc-pascal > wrote: > > > They are. > > No "is", because then the order of the label will start to matter, and that > runs contrary > to the case statement's intent. oh of course they are, I don't know why I forgot that. :P Regards,

Re: [fpc-pascal] Case statement for class introspection

2022-01-15 Thread Michael Van Canneyt via fpc-pascal
On Sun, 16 Jan 2022, Ryan Joseph via fpc-pascal wrote: On Jan 16, 2022, at 9:21 AM, Ryan Joseph wrote: There is a possibility for using "as" operator also though oops I mean "is" operator. Not sure if these are technically different from ClassType = ClassType though... They are.

Re: [fpc-pascal] Case statement for class introspection

2022-01-15 Thread Ryan Joseph via fpc-pascal
> On Jan 16, 2022, at 9:21 AM, Ryan Joseph wrote: > > There is a possibility for using "as" operator also though oops I mean "is" operator. Not sure if these are technically different from ClassType = ClassType though... Regards, Ryan Joseph _

Re: [fpc-pascal] Case statement for class introspection

2022-01-15 Thread Ryan Joseph via fpc-pascal
> On Jan 15, 2022, at 3:24 PM, Michael Van Canneyt via fpc-pascal > wrote: > > I don't see how an inline variable helps with the casting mess. You'll > always need a cast. > > What I do is Var > MyInstance : TObject; > MyNeededClass : TMyNeededClass absolute myInstance: Yes that's the best

Re: [fpc-pascal] Case statement for class introspection

2022-01-15 Thread Michael Van Canneyt via fpc-pascal
On Sat, 15 Jan 2022, Ryan Joseph via fpc-pascal wrote: On Jan 15, 2022, at 8:30 AM, Michael Van Canneyt via fpc-pascal wrote: I saw a new syntax in Swift which I thought was clever and fits a pattern I've seen before. Basically it's a case statement for class types which lets you branc

Re: [fpc-pascal] Case statement for class introspection

2022-01-14 Thread Ryan Joseph via fpc-pascal
> On Jan 15, 2022, at 8:30 AM, Michael Van Canneyt via fpc-pascal > wrote: > >> I saw a new syntax in Swift which I thought was clever and fits a pattern >> I've seen before. Basically it's a case statement for class types which >> lets you branch depending on which class type the class insta

Re: [fpc-pascal] Case statement for class introspection

2022-01-14 Thread Michael Van Canneyt via fpc-pascal
On Sat, 15 Jan 2022, Ryan Joseph via fpc-pascal wrote: I saw a new syntax in Swift which I thought was clever and fits a pattern I've seen before. Basically it's a case statement for class types which lets you branch depending on which class type the class instance is at run time. I think S

[fpc-pascal] Case statement for class introspection

2022-01-14 Thread Ryan Joseph via fpc-pascal
I saw a new syntax in Swift which I thought was clever and fits a pattern I've seen before. Basically it's a case statement for class types which lets you branch depending on which class type the class instance is at run time. I wonder if this could be implemented in FPC? The syntax would be kin

Re: [fpc-pascal] Case statements without constants?

2018-10-29 Thread Marco van de Voort
In our previous episode, Ryan Joseph said: > > > > I think it is important to differentiate between a language feature > > and its common implementation. Perhaps case statements with variables > > make sense? Of course, that doesn't mean anyone is going to add them. > > I?ve been programming Pasc

Re: [fpc-pascal] Case statements without constants?

2018-10-29 Thread Ryan Joseph
> On Oct 29, 2018, at 5:24 PM, R0b0t1 wrote: > > I think it is important to differentiate between a language feature > and its common implementation. Perhaps case statements with variables > make sense? Of course, that doesn't mean anyone is going to add them. I’ve been programming Pascal sinc

Re: [fpc-pascal] Case statements without constants?

2018-10-29 Thread Martin
On 29/10/2018 11:24, R0b0t1 wrote: I think it is important to differentiate between a language feature and its common implementation. Perhaps case statements with variables make sense? Of course, that doesn't mean anyone is going to add them. "case" also includes a compile time check, that case

Re: [fpc-pascal] Case statements without constants?

2018-10-29 Thread R0b0t1
On Mon, Oct 29, 2018 at 11:20 AM Michael Van Canneyt wrote: > > > I tried today to make a case that used variables instead of constants and > > was surprised to get an error. I’m sure this been true since the 80’s but > > why don’t cases allow variables??? I thought a case statement was just a > >

Re: [fpc-pascal] Case statements without constants?

2018-10-29 Thread Michael Van Canneyt
> I tried today to make a case that used variables instead of constants and > was surprised to get an error. I’m sure this been true since the 80’s but > why don’t cases allow variables??? I thought a case statement was just a > group of if..else blocks in succession. Case has never allowed variab

Re: [fpc-pascal] Case statements without constants?

2018-10-29 Thread Sven Barth via fpc-pascal
Ryan Joseph schrieb am Mo., 29. Okt. 2018, 10:41: > I tried today to make a case that used variables instead of constants and > was surprised to get an error. I’m sure this been true since the 80’s but > why don’t cases allow variables??? I thought a case statement was just a > group of if..else

[fpc-pascal] Case statements without constants?

2018-10-29 Thread Ryan Joseph
I tried today to make a case that used variables instead of constants and was surprised to get an error. I’m sure this been true since the 80’s but why don’t cases allow variables??? I thought a case statement was just a group of if..else blocks in succession. Regards, Ryan Joseph

Re: [fpc-pascal] Case based on type

2013-03-01 Thread Mark Morgan Lloyd
Marco van de Voort wrote: In our previous episode, Sven Barth said: === example end === Alternatively if you don't need to check the hierarchy, but can live with an exact match you can do this: === example begin === procedure checkLibrariesAndConnect(db: TSQLConnection); begin case Lower

Re: [fpc-pascal] Case based on type

2013-03-01 Thread waldo kitty
On 3/1/2013 17:57, Sven Barth wrote: [...] Alternatively if you don't need to check the hierarchy, but can live with an exact match you can do this: === example begin === procedure checkLibrariesAndConnect(db: TSQLConnection); begin case LowerCase(db.ClassName) of // Note: .ClassName won't work

Re: [fpc-pascal] Case based on type

2013-03-01 Thread Marco van de Voort
In our previous episode, Sven Barth said: > === example end === > > Alternatively if you don't need to check the hierarchy, but can live > with an exact match you can do this: > > === example begin === > > procedure checkLibrariesAndConnect(db: TSQLConnection); > begin >case LowerCase(db.Cl

Re: [fpc-pascal] Case based on type

2013-03-01 Thread Mark Morgan Lloyd
Sven Barth wrote: On 01.03.2013 23:35, Mark Morgan Lloyd wrote: Given a procedure definition like procedure checkLibrariesAndConnect(db: TSQLConnection); is there a more elegant way of performing type-specific actions than begin if db is TPQConnection then begin end; if db is TIBConn

Re: [fpc-pascal] Case based on type

2013-03-01 Thread Sven Barth
On 01.03.2013 23:35, Mark Morgan Lloyd wrote: Given a procedure definition like procedure checkLibrariesAndConnect(db: TSQLConnection); is there a more elegant way of performing type-specific actions than begin if db is TPQConnection then begin end; if db is TIBConnection then begin

[fpc-pascal] Case based on type

2013-03-01 Thread Mark Morgan Lloyd
Given a procedure definition like procedure checkLibrariesAndConnect(db: TSQLConnection); is there a more elegant way of performing type-specific actions than begin if db is TPQConnection then begin end; if db is TIBConnection then begin end end { checkLibrariesAndConnect } ; i.e. some

Re: [fpc-pascal] "Case of" documentation

2012-11-24 Thread Michael Van Canneyt
On Sat, 24 Nov 2012, Howard Page-Clark wrote: Describing the Case statement The FPLanguageReference.pdf 10.2.2 says: The constants appearing in the various case parts must be known at compile-time, and can be of the following types : enumeration types, Ordinal types (except boolean), and ch

[fpc-pascal] "Case of" documentation

2012-11-24 Thread Howard Page-Clark
Describing the Case statement The FPLanguageReference.pdf 10.2.2 says: The constants appearing in the various case parts must be known at compile-time, and can be of the following types : enumeration types, Ordinal types (except boolean), and chars. Why the "except boolean"? I find the compil

Re: [fpc-pascal] Case in Record

2009-10-09 Thread Jerry
On Oct 8, 2009, at 9:12 AM, Jürgen Hestermann wrote: And I don't know any other Pascal Compiler who does any checks in this direction. Do some? I don't know, but ADA reportedly does. I don't know the differences to Pascal. Does it have the same syntax for variant records? FWIW, here

Re: [fpc-pascal] Case in Record

2009-10-08 Thread Vinzent Höfler
"Jürgen Hestermann" : > >> And I don't know any other Pascal Compiler who does any checks in > >> this direction. Do some? > > I don't know, but ADA reportedly does. Yes, but the semantics of discriminants is slightly different than in PASCAL. > I don't know the differences to Pascal. Does it ha

Re: [fpc-pascal] Case in Record

2009-10-08 Thread Jürgen Hestermann
And I don't know any other Pascal Compiler who does any checks in this direction. Do some? I don't know, but ADA reportedly does. I don't know the differences to Pascal. Does it have the same syntax for variant records? Such a feature definitely seems useful to me. Of course it would b

Re: [fpc-pascal] Case in Record

2009-10-08 Thread Jürgen Hestermann
Given that the OP was asking about learning, maybe it would be worth mentioning that the way we normally have "data structures which hold different data" these days is by polymorphism in objects or classes. Instead of having an array of variant records, each of which might hold a description of

Re: [fpc-pascal] Case in Record

2009-10-08 Thread Frank Peelo
On 07/10/2009 16:39, Jürgen Hestermann wrote: IIRC, there is a difference. With the second declaration the compiler can add a run-time check that the correct memebrs are accessed based on the value of X. Unfortunately, I cannot find the compiler switch. FPC has no support for this. And I d

Re: [fpc-pascal] Case in Record

2009-10-08 Thread Florian Klaempfl
Jonas Maebe schrieb: > > On 07 Oct 2009, at 17:39, Jürgen Hestermann wrote: > >> And I don't know any other Pascal Compiler who does any checks in this >> direction. Do some? > > I don't know, but ADA reportedly does. Such a feature definitely seems > useful to me. Afaik GPC does as well? _

Re: [fpc-pascal] Case in Record

2009-10-08 Thread Jonas Maebe
On 07 Oct 2009, at 17:39, Jürgen Hestermann wrote: And I don't know any other Pascal Compiler who does any checks in this direction. Do some? I don't know, but ADA reportedly does. Such a feature definitely seems useful to me. Jonas___ fpc-pas

Re: [fpc-pascal] Case in Record

2009-10-07 Thread Jürgen Hestermann
IIRC, there is a difference. With the second declaration the compiler can add a run-time check that the correct memebrs are accessed based on the value of X. Unfortunately, I cannot find the compiler switch. FPC has no support for this. And I don't know any other Pascal Compiler who does any

Re: [fpc-pascal] Case in Record

2009-10-07 Thread Jonas Maebe
On 07 Oct 2009, at 10:18, Florian Klaempfl wrote: Vincent Snijders schrieb: Jonas Maebe schreef: On 07 Oct 2009, at 09:19, Vincent Snijders wrote: IIRC, there is a difference. With the second declaration the compiler can add a run-time check that the correct memebrs are accessed based

Re: [fpc-pascal] Case in Record

2009-10-07 Thread Florian Klaempfl
Vincent Snijders schrieb: > Jonas Maebe schreef: >> >> On 07 Oct 2009, at 09:19, Vincent Snijders wrote: >> >>> IIRC, there is a difference. With the second declaration the compiler >>> can add a run-time check that the correct memebrs are accessed based >>> on the value of X. >>> >>> Unfortunately

Re: [fpc-pascal] Case in Record

2009-10-07 Thread Vincent Snijders
Jonas Maebe schreef: On 07 Oct 2009, at 09:19, Vincent Snijders wrote: IIRC, there is a difference. With the second declaration the compiler can add a run-time check that the correct memebrs are accessed based on the value of X. Unfortunately, I cannot find the compiler switch. FPC has no

Re: [fpc-pascal] Case in Record

2009-10-07 Thread Jonas Maebe
On 07 Oct 2009, at 09:19, Vincent Snijders wrote: IIRC, there is a difference. With the second declaration the compiler can add a run-time check that the correct memebrs are accessed based on the value of X. Unfortunately, I cannot find the compiler switch. FPC has no support for this.

Re: [fpc-pascal] Case in Record

2009-10-07 Thread Vincent Snijders
Jürgen Hestermann schreef: Therefore, there is absolutly no difference between TFigure = record X : TShapeList; case TShapeList of Rectangle: (Height, Width: Real); Triangle: (Side1, Side2, Angle: Real); Circle: (Radius: Real);

Re: [fpc-pascal] Case in Record

2009-10-06 Thread Nikolay Nikolov
On 10/06/2009 06:31 PM, Frank Peelo wrote: Any new concepts that were introduced, like properties, were applied only to the new classes and objects were left in a corner, like the embarrassing relative that you wish you could get rid of, but can't. However, AFAIK Free Pascal supports properties

Re: [fpc-pascal] Case in Record

2009-10-06 Thread Anton Tichawa
On Wed, 2009-10-07 at 07:22 +0200, Jürgen Hestermann wrote: > Therefore, there is absolutly no difference between > > TFigure = record >X : TShapeList; >case TShapeList of > Rectangle: (Height, Width: Real); > Triangle: (Side1, Side2, Angle: R

Re: [fpc-pascal] Case in Record

2009-10-06 Thread Jürgen Hestermann
AFAIK there has to be some fixed part before the variant, e. g. TFigure = record name: string; case TShapeList of Rectangle: (Height, Width: Real); Triangle: (Side1, Side2, Angle: Real); Circle: (Radius: Real); Ellipse, Other: (); end; The program could then dete

Re: [fpc-pascal] Case in Record

2009-10-06 Thread 章宏九
I see. That means if no tag name is given, I should make sure my code is correct by myself. Thank you. 2009/10/7 Anton Tichawa : > On Tue, 2009-10-06 at 23:37 +0800, 章宏九 wrote: >> Thank you. I saw all the examples you gave, but I still cannot master >> how to use a variant record without a specif

Re: [fpc-pascal] Case in Record

2009-10-06 Thread Anton Tichawa
On Tue, 2009-10-06 at 23:37 +0800, 章宏九 wrote: > Thank you. I saw all the examples you gave, but I still cannot master > how to use a variant record without a specified tag. > > For example: > type > TShapeList = (Rectangle, Triangle, Circle, Ellipse, Other); > TFigure = record > case TShap

Re: [fpc-pascal] Case in Record

2009-10-06 Thread Jürgen Hestermann
Thank you. I saw all the examples you gave, but I still cannot master how to use a variant record without a specified tag. If you use a specific tag as in type TFigure = record case ShapeName : TShapeList of Rectangle: (Height, Width: Real); Tr

Re: [fpc-pascal] Case in Record

2009-10-06 Thread Henry Vermaak
2009/10/6 章宏九 : > Thank you. I saw all the examples you gave, but I still cannot master > how to use a variant record without a specified tag. > > For example: > type >  TShapeList = (Rectangle, Triangle, Circle, Ellipse, Other); >  TFigure = record >    case TShapeList of >      Rectangle: (Height

Re: [fpc-pascal] Case in Record

2009-10-06 Thread 章宏九
Thank you. I saw all the examples you gave, but I still cannot master how to use a variant record without a specified tag. For example: type TShapeList = (Rectangle, Triangle, Circle, Ellipse, Other); TFigure = record case TShapeList of Rectangle: (Height, Width: Real); Triangl

Re: [fpc-pascal] Case in Record

2009-10-06 Thread Frank Peelo
On 06/10/2009 15:00, Felipe Monteiro de Carvalho wrote: On Tue, Oct 6, 2009 at 10:13 AM, 章宏九 wrote: Type MyRec = Record X : Longint; Case byte of 2 : (Y : Longint; case byte of 3 : (Z : Longint); ); end; I think

Re: [fpc-pascal] Case in Record

2009-10-06 Thread Henry Vermaak
2009/10/6 Henry Vermaak : > > I can't really comment on the scary details, since I'm rubbish at > object oriented programming :) And objects aren't deprecated, since the compiler uses them (afaik). Henry ___ fpc-pascal maillist - fpc-pascal@lists.free

Re: [fpc-pascal] Case in Record

2009-10-06 Thread Felipe Monteiro de Carvalho
On Tue, Oct 6, 2009 at 10:13 AM, 章宏九 wrote: > Type >  MyRec = Record >          X : Longint; >          Case byte of >            2 : (Y : Longint; >                 case byte of >                 3 : (Z : Longint); >                 ); >          end; I think the cases are useless here. AFAIK th

Re: [fpc-pascal] Case in Record

2009-10-06 Thread Henry Vermaak
2009/10/6 章宏九 : > In the document > (http://www.freepascal.org/docs-html/ref/refsu15.html#x38-450003.3.2) > I read the code below: > > Type >  MyRec = Record >          X : Longint; >          Case byte of >            2 : (Y : Longint; >                 case byte of >                 3 : (Z : Long

[fpc-pascal] Case in Record

2009-10-06 Thread 章宏九
In the document (http://www.freepascal.org/docs-html/ref/refsu15.html#x38-450003.3.2) I read the code below: Type MyRec = Record X : Longint; Case byte of 2 : (Y : Longint; case byte of 3 : (Z : Longint); );

Re: [fpc-pascal] Case insensitive comparison of strings with non-ascii characters

2009-07-26 Thread theo
I had uploaded the sources to zshare server with the link: Thanks, I'll have a look at it. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re[3]: [fpc-pascal] Case insensitive comparison of strings with non-ascii characters

2009-07-26 Thread JoshyFun
Hello FPC-Pascal, Sunday, July 26, 2009, 9:43:06 AM, you wrote: >> The code is not optimized but if somebody wants to use them please ask t> Yes please! I had uploaded the sources to zshare server with the link: http://www.zshare.net/download/63185150b6099e5d/ The code is not an example of how

Re[3]: [fpc-pascal] Case insensitive comparison of strings with non-ascii characters

2009-07-26 Thread JoshyFun
Hello FPC-Pascal, Sunday, July 26, 2009, 9:43:06 AM, you wrote: t> In your strict sense, AnsiCompareText didn't work either. Yes, Ansi does not work fine also for some usual languages. But we are used to "simulate" a comparetext using lowercase(a)=lowercase(b) where the same character could have

  1   2   >