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); );