OOP problem

134 views
Skip to first unread message

Vlad

unread,
Feb 6, 2016, 9:43:04 AM2/6/16
to Harbour Developers
Hello guys

I'm using harbour 3.2.0dev (r1507030922) and i have problem in OOP code. See example bellow :


#include "hbclass.ch"

FUNCTION MAIN()
LOCAL c := myClass():New()

   ? c:Test()

RETURN NIL
***
CLASS myClass

   DATA test INIT NIL
  
   METHOD test()
   METHOD NEW() CONSTRUCTOR

END CLASS

METHOD NEW()

   ::test := 10
   ::test()  

RETURN Self

METHOD Test()

   ? "Inside test"
   ? ::test

RETURN Self

If i create an variable and one method (same name) the program fail.

Przemyslaw Czerpak

unread,
Feb 8, 2016, 6:53:16 PM2/8/16
to harbou...@googlegroups.com
Hi Vlad,

Neither Cl*pper nor [x]Harbour support code were variables
and methods use the same names. In both cases when you
access variable and call method the same PCODE it generated.
Just simply in Clipper:
? o:cargo
and
? o:cargo()
means the same code and for compatibility we have to make
the same. I keep in mind modification which extends Harbour
and adds support for such functionality in two modes chose
by compiler switch during PRG code compilation:
1 - suggested type of message
2 - strict type of message
The first one will try to keep Cl*pper compatibility so for
code like:
? o:cargo
it first look for instance variable then for message and for
code like:
? o:cargo
it first look for message and then instance variable.
The second one will force strict access but to introduce it
it's necessary to well document what is method and what
instance variable in existing classes and it was never clear
in Cl*pper, i.e.
:classH or :classH()
or
:className or rahter :className()
and we inherited this ambiguity with the Cl*pper compatibility.
Anyhow this modification has rather small priority on my TODO
list.

best regards,
Przemek
> --
> You received this message because you are subscribed to the Google Groups "Harbour Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to harbour-deve...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages