Author Topic: Class functions that return user-defined-type objects.  (Read 161 times)

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

  • Full Member
  • ***
  • Posts: 153
    • PluriBASIC
Class functions that return user-defined-type objects.
« on: November 25, 2018, 09:34:56 PM »

 Now that the array system is nearly completed, i noticed that i need to also create arrays
of UDT members. I have a number of tricks to try, but i would like to know if Oxygen already
can do this.

 basically what i would like is to have a class with a function that returns a user-defined-type
"variable" and use it like this:

Code: [Select]
MyClassObject.functionthatreturnsaUDT(dimension1, dimension2, dimension3).UdtMemberOfTypeLong = 12345
 Is this already doable with Oxigen as it is? Thanks.

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3909
    • Oxygen Basic
Re: Class functions that return user-defined-type objects.
« Reply #1 on: November 26, 2018, 10:22:03 PM »
This is very interesting, and feasible with some extra work on o2. It is a two-part operation: first to return an object reference, then to get the required member.

Brian Alvarez

  • Full Member
  • ***
  • Posts: 153
    • PluriBASIC
Re: Class functions that return user-defined-type objects.
« Reply #2 on: November 26, 2018, 10:28:40 PM »
 This can also be done on my side, but i would like to focus on writing more stock functions...
What do you think? Are you up to it? :)

I'm almost done with ARRAY SCAN, then ARRAY SORT... after that, it will be a matter of getting
the above functionality to get PluriBASIC compiled for 64 bit...

Here is a sample of the complexity i need to compile:

Code: [Select]
IF SD(Part).Keyword = %DATA_VARIABLE THEN
    IF VAR_DATA(SD(Part).Index).Dimensions THEN
        MOD_DATA(Module).Param(Param).Dimensions = VAR_DATA(SD(Part).Index).Dimensions
        VAR_DATA(SD(MOD_DATA(Module).Param(Param).SDIndex).Index).Dimensions = VAR_DATA(SD(Part).Index).Dimensions                                   
        VAR_DATA(MOD_DATA(Module).Param(Param).VIndex).Dimensions = VAR_DATA(SD(Part).Index).Dimensions
        INCR MOD_DATA(Module).ArrSet                                                                       
        IF MOD_DATA(Module).Arrays = MOD_DATA(Module).ArrSet THEN
            decr Incomplete
        END IF
    END IF
END IF

Brian Alvarez

  • Full Member
  • ***
  • Posts: 153
    • PluriBASIC
Re: Class functions that return user-defined-type objects.
« Reply #3 on: November 26, 2018, 10:38:28 PM »
...It is a two-part operation...

Even for nested UDT members?

Charles Pegge

  • Admin Support Member
  • *****
  • Posts: 3909
    • Oxygen Basic
Re: Class functions that return user-defined-type objects.
« Reply #4 on: November 27, 2018, 06:15:28 AM »
Yes, at the translator level, all these nestings must be decomposed into simple expressions and resolved in the correct sequence (innermost first).

for example:
a=b+c*fun()
--->
a=b+(c*fun())
--->
tmp1=fun()   
--->
tmp2=c*tmp1
--->
a=b+tmp2


Accessing a member via a method might look like this:


a=v.meth(...).memb
--->
typeof(v) *temp
@temp=v.meth(...)
a=temp.memb
« Last Edit: November 27, 2018, 06:28:07 AM by Charles Pegge »