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,