On Mon, 19 Jan 2009, Alex Strickland wrote:

Hi Alex,

> I was calling a method called "end" on a COM object, and nothing was 
> happening. Fortunately for me the COM object supplies an equivalent 
> alternative - endTransaction(), and that worked.
> Is end() somehow reserved in our classes?

AFAIK we do not have any of such restrictions. This code works perfectly.

   #include "hbclass.ch"
   proc main
      local o:=mycls():new()
      o:end()
   return
   create class mycls
      method end
   end class
   method end
      ? ::classname, hb_methodName()
   return self

Maybe you should check some non Harbour .ch files. Some Harbour 3-rd
party libraries uses a lot of PP rules which can break valid code.
Check code generated with -p option and also .c output (-gc2) for
:end() and :endTransaction() and compare differences.
Anyhow it's not Harbour problem.

> In a similar vein, what is the difference between init() and new()?

In Class(y) code class function should return "class object" not object
of given class. This class object understands :NEW() message and create
object of given class sending to this object :INIT() message with
parameters passed to :NEW(). Neither Harbour nor xHarbour have real
class object support and class functions always return object of given
class and both NEW() and INIT() are messages of this object. The default
implementation of :NEW() inherited from HBOBJECT class simply calls :INIT()
method.
I wanted to add real class object support to Harbour but I do not know
if it's still possible. People already created a lot of code which does
not use :new() at all so it will be serious backward compatibility problem.
It's a classic example of problems created by unfinished code added to
official repository which later cannot be easy finished or fixed.
Probably now the only one way to resolve this problem is creating new
hbclass.ch and leaving the old one for backward compatibility. Maybe
I or someone else will make it in the future. Code which calls NEW()
should work with both versions.

> Are there other "special" methods?

Read Class(y) documentation about general ideas.
See source/rtl/tobject.prg for default methods inherited from
HBOBJECT class.
If you use in your code:
   #define HB_CLS_NOTOBJECT      /* do not inherit from HBObject calss */
before
   #include "hbclass.ch"
then you disable inheritance from hbobject in your classes.
Additionally each class of any type supports:
   CLASSNAME
   CLASSH
   CLASSSEL
messages implemented in core code. They always work. 1-st and 2-nd
are Clipper compatible, f.e.:
   ? NIL:className, NIL:classH
works in both compilers in all cases.
If we add full class(y) support and class function will return object
of given class then this object will support message defined in
source/rtl/tclass.prg. In such case we should also extend it and add
some additional messages Class(y) compatible.

best regards,
Przemek
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to