...just 3 wishes
Posted: Thu Jun 24, 2004 12:13 am
...1) Arrays as Parameters for Procedures.
At the moment we can overgive an array to a procedure as a pointer to it's data:
But then we have to peek and poke around, or use structurepointers and increase the pointers in SizeOf(Arraytype)-Byte-Steps, and all this stuff. It would be nice to refer to the array's content via:
...2) same as 1) but for lists. So we could write e.g.:
In both cases of 1) and 2) the array/list overgiven as a parameter should refer to the global data, so all changes are made inside the global array/list including the effects of ResetList(), etc.
..3) Overloading. Of course because of PB's auto-type-casting this could run into trouble. But if it would give e.g. (b) (w) (l) (s) (typename) prefix for signaling typecasting we could easily differ between (and use simultan in our code):
Atm we can only use StructureUnions and an implemented or extern flag for these puposes, e.g. :
Perhaps overloading could be implemented in PB 5.0 ? 
At the moment we can overgive an array to a procedure as a pointer to it's data:
Code: Select all
Dim Arrayname.l(202)
Procedure test(*arrData.l)
; some code with Peek/Poke or Structure-Pointers, etc...
EndProcedure
test(Arrayname()) ; or with a @
Code: Select all
Dim Arrayname.l(202)
Procedure test(myArr.l()) ; protected name for array, the type, and '()' as identifier for an array
myArr(2) + 1
; etc...
EndProcedure
test(Arrayname())
...2) same as 1) but for lists. So we could write e.g.:
Code: Select all
NewList myGlobalList.l()
Procedure test(list.l(LL)) ; protected name for list, type of it's elements, followed by e.g. '(LL)' as identifier for a list
ForEach list() ; etc...
Next
EndProcedure
test(myGlobalList())
..3) Overloading. Of course because of PB's auto-type-casting this could run into trouble. But if it would give e.g. (b) (w) (l) (s) (typename) prefix for signaling typecasting we could easily differ between (and use simultan in our code):
Code: Select all
Procedure.l test(p1.l, p2.l)
EndProcedure
Procedure.f test(p1.l, p2.f)
EndProcedure
Procedure.s test(p1.l, p2.s)
EndProcedure
Procedure.l test(p1.l, p2.s)
EndProcedure
...
debug (l) test(1234, 1234) ; calls the 1st - you might leave out the leading (l)
debug test(1234, (f) 1234) ; calls the 2nd
debug test(1234, "Peter") ; gives a 'overloading error: two possiblilities of return type'
debug (s) test(1234, "Peter") ; calls the 3rd
debug (l) test(1234, "Peter") ; calls the 4th
debug test(1234, (l) myVar) ; calls the 1st
...
Code: Select all
Structure AllType
StructureUnion
b.b
w.w
l.l
f.f
s.s
EndStructureUnion
typeflag.l
EndStructure
