Code: Select all
Procedure.i test (in$, x.i, *refStr.C:haracter, *outY.Integer, *outStr.String)
; procedure code
*outY\I = 42
*outStr\s = in$ + ": " + x + " : " Str(*refStr\c)
EndProcedure
;This works.
test(s$, m.i, @example.s, @newY.i, @newString.String)
;Problems can occur with literals or unstructured string variables (of type .s or $ because
; pointer to structure instead of string contents is needed so string can be modified).
;test(s$, m.i, @"still OK", @600613, @notChangeable.s)
The main issue that remains is getting the pointer to the string structure that is used for a string variable declared as either type .s or $. This begs for a new operator, keyword or compiler function. Some such as mk-soft have tried to come up with solutions or suggestions to fix this.
Here are some examples:
Code: Select all
;new operator
*ptrStringStructure = @@some.s ;@@ is the suggested operator
;new keyword
;RefTo is my suggested keyword, I just made this up so I'm sure there are better choices ;)
;it would possibly be limited to being used in a parameter list.
;Other keywords suggested are ByRef or Out.
*ptrStringStructure = RefTo some.s
;or
Procedure.i test (in$, x.i, *refStr.Character, *outY.Integer, RefTo *outStr.String): EndProcedure
;test(s$, m.i, @"still OK", @600613, @wasNotChangeable.s)
;or
Procedure.i test (in$, x.i, *refStr.Character, *outY.Integer, *outStr.String):EndProcedure
;test(s$, m.i, @"still OK", @600613, RefTo wasNotChangeable.s)
;new compiler function RefTo()
*ptrStringStructure = RefTo(some.s)
;or
Procedure.i test (in$, x.i, *refStr.Character, *outY.Integer, *outStr.String):EndProcedure
;test(s$, m.i, @"still OK", @600613, RefTo(nowChangeable.s))
I don't think it would break anything. I personally favor a new compiler function so it is obvious what is happening and to show it is expressly wanted when passing a parameter.