Hi,

Leandro Damasio wrote:
My proposition is that singleton class support for harbour be implemented in such a way that one programmer can declare a singleton class, box it in a library and share it to other harbour users around the world, knowing for sure that nobody could instantiate it more than once per execution (even by mistake) and that there should be no need to provide any exceptional instructions, formalities, tips or tricks with the library to assure that the user will always acess the same unique instance of the class during all the execution of the program, because the class was declared as a singleton class and the machine would know how to deal with it, even if the user doesn't even know what does singleton means.

I do not see a problems here also. In both my and Teo's sample extra class is created but it i not hidden from "other users around the world" (i.e. MyClass1Real() function is public and visible). It is easy to make this function static and accessible only from same module public funcion (only from MyClass1()). This could be implemented using preprocessor and magic word SINGLETON, but I do not thing it's something special to be required to implement as a fundamental class feature.

If you'll ever look at .ppo file generated from CLASS sentence you'll be surprised that this CLASS something is actually a function, and that method definitions are only a calls to methods like :AddMethod() of some magic class HBClass() and these :AddMethod() are actually a call to __clsAddMsg(). Just see src/rtl/tclass.prg.

So, you can be sure: if Teo's preprocessor sample is not enough to make you believe you have a real singleton, be sure that you do not have any real class at all, even if you think so. You are a newbie here, so, Harbour is a little cheating on you ;)


Regards,
Mindaugas
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to