Forum > LCL

[SOLVED] Component name

<< < (2/2)

howardpc:

--- Quote from: Thaddy on January 14, 2022, 01:45:03 pm ---Well, the constructor can be done to some extend, but OP should mind that FPC is not a scripting language.
It is unusual to use such constructs.
The technique to use is to use {$if declared(variableName)} in combination with RTTI to get a class reference from which you can create an instance. Highly NOT recommended, but that would work, I guess.

--- End quote ---
"the technique to use ... highly NOT recommended" seems like a self-contradiction.
RTTI is currently only available via FPC for published properties of classes and a few other limited cases.
What is so unusual about passing data as parameter(s) in a constructor? You make it sound as if such a technique were unsound or hackish. It is a perfectly acceptable way to pass data that you don't want exposed globally.

Pe3s:
Thank you. greetings

PascalDragon:

--- Quote from: howardpc on January 14, 2022, 02:45:54 pm ---
--- Quote from: Thaddy on January 14, 2022, 01:45:03 pm ---Well, the constructor can be done to some extend, but OP should mind that FPC is not a scripting language.
It is unusual to use such constructs.
The technique to use is to use {$if declared(variableName)} in combination with RTTI to get a class reference from which you can create an instance. Highly NOT recommended, but that would work, I guess.

--- End quote ---
"the technique to use ... highly NOT recommended" seems like a self-contradiction.
RTTI is currently only available via FPC for published properties of classes and a few other limited cases.
What is so unusual about passing data as parameter(s) in a constructor? You make it sound as if such a technique were unsound or hackish. It is a perfectly acceptable way to pass data that you don't want exposed globally.

--- End quote ---

I think the “highly NOT recommended” is related to Thaddy's idea of using {$if declared(variableName)}. The idea of using RTTI would of course be alright if the extended RTTI would already be integrated. ;)

Akira1364:
Can you give an example of what you're actually trying to do?

Navigation

[0] Message Index

[*] Previous page

Go to full version