Code: Select all
Type MyUDT
as integer X,Y
end type
function RegularReturn() as integer
RegularReturn = 10
function = 10
return 10 'all fine
end function
function UDTReturn() as MyUDT
UDTReturn = type<MyUDT>(10,20) 'fine
'function.x = 10 'illegal inside functions find function
'UDTReturn.x = 10 'calls the function recursively infinitely :D because () is optional for sub/functions 'MEH
'with function 'expected identifier, found 'function' in 'with function
'with UDTReturn 'calls the function recursively infinitely :D because () is optional for sub/functions 'MEH
return type<MyUDT>(10,20) 'fine
end function
sub UDTReturn2( byref RetUDT as MyUDT )
RetUDT.x = 10 : RetUDT.y = 20 'fine
end sub
dim as MyUDT T
T = UDTReturn()
UDTReturn2( T )
and the method using the template requires to fill the whole type at once, and as far i know that creates a temp... that is then copied to the return that is then copied to the T (probabily gen gcc would optimize that but still)
the syntax is incosistent when an UDT is returned... this was discussed before? i couldnt find a bug filled about that, after all it isnt what i would an actual bug. (and i never noticed before because i never return UDT, just pointers)
so what you guys think?