[fpc-pascal] Adding method dynamically to a class

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Wed Jun 20 09:20:02 CEST 2012



On Wed, 20 Jun 2012, ik wrote:

> On Wed, Jun 20, 2012 at 8:33 AM, LacaK <lacak at zoznam.sk> wrote:
>
>> **
>> Class helpers would not help ?
>>
>> http://wiki.freepascal.org/Helper_types
>>
>
>
> They can, but there is a protocol that I'm trying to create that provides
> me information what to execute (out of white list). The thing is, that the
> first request maps the methods to be used, and there could be 2 or 200. To
> implement 200 methods that might be used is not a good idea imho, but
> adding the proper method to the instance/class will work much better.

I don't understand this argument. The available methods must have an 
implementation somewhere anyway. That means your code does not get 
smaller by adding them dynamically.  Somewhere you must choose which 
method to execute, and whether it is allowed or not, so this logic 
must be present also. None of this requires dynamically adding methods as
far as I can see, or is made easier by dynamically adding methods.

So finally, what is gained by adding them dynamically ? 
Or what forces you to even consider this path ?

Michael



More information about the fpc-pascal mailing list