Page 1 of 1
MyProcedureWithOptionalParams(a.l = 42, *b.POINT = {8,15})
Posted: Thu Mar 16, 2006 4:47 pm
by traumatic
Now that we have optional, pre-initialized parameters it would be more
than useful to also be able to use this feature for structures IMHO:
Code: Select all
Procedure MyProcedureWithOptionalParams(a.l = 42, *b.POINT = {8,15})
; *b\x = 8, *b\y = 15
EndProcedure
Posted: Thu Mar 16, 2006 6:55 pm
by Rescator
Hmm! That looks rather messy.
Personally I'd rather have:
Code: Select all
Structure MyPoint
x.l=1
y.l=2
EndStructure
Posted: Thu Mar 16, 2006 6:56 pm
by traumatic
and then?
Posted: Thu Mar 16, 2006 7:26 pm
by Rescator
Thats it!
Your idea would mean dynamic structures.
Remember, default values are only used if there is no value.
A structure is fixed, it does not change.
Currently a structure defaults all it's variables to 0.
So my idea make sense.
Your would not work without major changes to PB's handling of structures.
Ever tried to reference a variable in a structure and the variable did not exist?
Your idea would possibly have that issue all the time.
Posted: Thu Mar 16, 2006 9:21 pm
by traumatic
Rescator wrote:Your idea would mean dynamic structures.
No, I think you misunderstood what I meant.
You can do x.l = 5 but you can't do x.POINT = {5,5} (same for arrays)
While there's a good way to fill in the values with macros now, there's
no way to use a pointer to a structure as an optional argument.