Does data type derive from Progress.Lang.Object?

Posted by sderrico on 20-Mar-2014 12:45

Hello Group!

Could you please help me to understand a basis in OOABL?

I attached an example. I created two methods, one with a parameter of type Progress.Lang.Object and another with System.Object.

Curiosity 1) Is all data type derive from a base class in OOABL? If yes, which class?

Curiosity 2) In my code, why I cannot pass a value, like 4, in both method as a parameter?

Curiosity 3) In my code, why I can do o = i but I cannot use i as a parameter of the the same data type of o?

/* declaration */
DEFINE VARIABLE i AS INTEGER NO-UNDO INITIAL 4.
DEFINE VARIABLE o AS System.Object NO-UNDO.

/* initialization */
o = i.

/* Success */
TestNet(o).

/* Error: Parameter 1 for METHOD TestPro is not compatible with its definition (12905) */
TestPro(i).
TestPro(4).


/* Error: Parameter 1 for METHOD TestNet is not compatible with its definition (12905) */
TestNet(4).

/* T E S T   P R O */
METHOD STATIC PUBLIC VOID TestPro(INPUT p AS Progress.Lang.Object):
    MESSAGE p VIEW-AS ALERT-BOX.
END METHOD.

/* T E S T   N E T */
METHOD STATIC PUBLIC VOID TestNet(INPUT p AS System.Object):
    MESSAGE p VIEW-AS ALERT-BOX.
END METHOD.

 

Thank you!

Sebastien

Posted by Peter Judge on 20-Mar-2014 13:00

Curiosity 1) Is all data type derive from a base class in OOABL? If yes, which class?

No. Primitive types (INT, INT64, DECIMAL, CHAR, LONGCHAR, etc), arrays (CHAR EXTENT etc) and temp-tables/prodatasets are not OO (for historical reasons – these types predate OO in ABL).
 
All complex user-defined types (aka objects) inherit from Progress.Lang.Object. In the GUI for .Net, System.Object also inherits from Progress.Lang.Object.
 

Curiosity 3) In my code, why I can do o = i but I cannot use i as a parameter of the the same data type of o?

There is some autoboxing that happens with .NET objects. I'm not sure why this fails in one case but not the other.
 
This works:
TestNet(box(4)).
 
There's no boxing (auto or otherwise) with OOABL.
 
-- peter
 
 
 
[collapse]
From: sderrico [mailto:bounce-shapeshifter999@community.progress.com]
Sent: Thursday, 20 March, 2014 13:46
To: TU.OE.Development@community.progress.com
Subject: Does data type derive from Progress.Lang.Object?
 
Thread created by sderrico

Hello Group!

Could you please help me to understand a basis in OOABL?

I attached an example. I created two methods, one with a parameter of type Progress.Lang.Object and another with System.Object.

Curiosity 1) Is all data type derive from a base class in OOABL? If yes, which class?

Curiosity 2) In my code, why I cannot pass a value, like 4, in both method as a parameter?

Curiosity 3) In my code, why I can do o = i but I cannot use i as a parameter of the the same data type of o?

/* declaration */
DEFINE VARIABLE i AS INTEGER NO-UNDO INITIAL 4.
DEFINE VARIABLE o AS System.Object NO-UNDO.

/* initialization */
o = i.

/* Success */
TestNet(o).

/* Error: Parameter 1 for METHOD TestPro is not compatible with its definition (12905) */
TestPro(i).
TestPro(4).


/* Error: Parameter 1 for METHOD TestNet is not compatible with its definition (12905) */
TestNet(4).

/* T E S T   P R O */
METHOD STATIC PUBLIC VOID TestPro(INPUT p AS Progress.Lang.Object):
    MESSAGE p VIEW-AS ALERT-BOX.
END METHOD.

/* T E S T   N E T */
METHOD STATIC PUBLIC VOID TestNet(INPUT p AS System.Object):
    MESSAGE p VIEW-AS ALERT-BOX.
END METHOD.

 

Thank you!

Sebastien

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

All Replies

Posted by Peter Judge on 20-Mar-2014 13:00

Curiosity 1) Is all data type derive from a base class in OOABL? If yes, which class?

No. Primitive types (INT, INT64, DECIMAL, CHAR, LONGCHAR, etc), arrays (CHAR EXTENT etc) and temp-tables/prodatasets are not OO (for historical reasons – these types predate OO in ABL).
 
All complex user-defined types (aka objects) inherit from Progress.Lang.Object. In the GUI for .Net, System.Object also inherits from Progress.Lang.Object.
 

Curiosity 3) In my code, why I can do o = i but I cannot use i as a parameter of the the same data type of o?

There is some autoboxing that happens with .NET objects. I'm not sure why this fails in one case but not the other.
 
This works:
TestNet(box(4)).
 
There's no boxing (auto or otherwise) with OOABL.
 
-- peter
 
 
 
[collapse]
From: sderrico [mailto:bounce-shapeshifter999@community.progress.com]
Sent: Thursday, 20 March, 2014 13:46
To: TU.OE.Development@community.progress.com
Subject: Does data type derive from Progress.Lang.Object?
 
Thread created by sderrico

Hello Group!

Could you please help me to understand a basis in OOABL?

I attached an example. I created two methods, one with a parameter of type Progress.Lang.Object and another with System.Object.

Curiosity 1) Is all data type derive from a base class in OOABL? If yes, which class?

Curiosity 2) In my code, why I cannot pass a value, like 4, in both method as a parameter?

Curiosity 3) In my code, why I can do o = i but I cannot use i as a parameter of the the same data type of o?

/* declaration */
DEFINE VARIABLE i AS INTEGER NO-UNDO INITIAL 4.
DEFINE VARIABLE o AS System.Object NO-UNDO.

/* initialization */
o = i.

/* Success */
TestNet(o).

/* Error: Parameter 1 for METHOD TestPro is not compatible with its definition (12905) */
TestPro(i).
TestPro(4).


/* Error: Parameter 1 for METHOD TestNet is not compatible with its definition (12905) */
TestNet(4).

/* T E S T   P R O */
METHOD STATIC PUBLIC VOID TestPro(INPUT p AS Progress.Lang.Object):
    MESSAGE p VIEW-AS ALERT-BOX.
END METHOD.

/* T E S T   N E T */
METHOD STATIC PUBLIC VOID TestNet(INPUT p AS System.Object):
    MESSAGE p VIEW-AS ALERT-BOX.
END METHOD.

 

Thank you!

Sebastien

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by Thomas Mercer-Hursh on 20-Mar-2014 13:06

Class objects in ABL derive from Progress.Lang.Objects, but primitives like integer do not.  In some languages, there are two versions, e.g., String and string where the former is an object and the later is not.   ABL currently only has the latter.  It is on the wish list to have such things www.oehive.org/OOWishList

Posted by sderrico on 20-Mar-2014 13:14

@Peter: Box works perfectly, thank you!

Posted by sderrico on 20-Mar-2014 13:19

@Thomas: Nice list! This will be very good for Progress when this list will be implemented. Also with Multithreading as you suggested in another post.

Posted by Thomas Mercer-Hursh on 20-Mar-2014 13:37

Note that some of the list items have been translated to the Ideas section of this site, so you might want to go there and vote for them.

This thread is closed