On Sat, 13 Feb 2010, Daniel Gonçalves wrote:

Hi,

> Does any body knows about "class method" support in Harbour 2.1.0dev?
> I was migrating from xHarbour 0.99 to Harbour 2.1.0dev and my
> application breaks, apparently caused by attempt to access a class
> method.

Neither Harbour nor xHarbour support CLASS METHODs.
In xHarbour they are translated to normal method and in Harbour
they are ignored.
If you want to replicate xHarbour behavior using Harbour add this
PP rule to your code:

   #xcommand CLASS METHOD <*params*>  => METHOD <params>

> The error message is "MESSAGE NOT FOUND: FOO:BAR" where BAR is the
> class method of class FOO. The example class is:
> CREATE CLASS Foo
>    EXPORT:
>       CLASS METHOD initClass
>       CLASS METHOD bar
>    END CLASS
> 
> METHOD initClass() CLASS Foo
>    RETURN ( self )
> 
> METHOD bar() CLASS Foo
>    RETURN ( "Hello" )
> And in another source file, I'm accessing bar method like this:
> ? Foo():bar()
> 
> Note that this same code works in xHarbour 0.99.

All xHarbour versions translated CLASS METHOD to METHOD.
Just simply there is not support for class objects and class
function returns normal objects.
We plan to add support for real class methods and class objects
in Harbour in the future and it's the reason why we haven't
added such translation.

> Looking at the PPO, I realize that the declaration of method bar() turns to:
> static FUNCTION Foo_bar() ...
> The "static" confused me. If the procedure/function is static that one
> can't access that procedure or function from outside module. Isn't?

Yes this is correct. Class method cannot be called directly as functions/
procedures.

best regards,
Przemek
_______________________________________________
Harbour-users mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour-users

Reply via email to