References

Monkey Forums/Monkey Programming/References

TMK(Posted 2011) [#1]
As far as I understand, Monkey does not support pointers. But is it possible to send arguments by reference?

For example, is it possible to port the following BlitzMax code to Monkey?

Function ReturnMultiplevalues(a:Int Var,b:Int Var,c:Int Var)
    a=10
    b=20
    c=30
    Return
End Function

Function PrintNumbers()
    Local x:Int, y:Int, z:Int

    ReturnMultipleValues(x,y,z)

    Print "x="+x '10
    Print "y="+y '20
    Print "z="+z '30
End Function



Xaron(Posted 2011) [#2]
No, it's not possible.


ziggy(Posted 2011) [#3]
But you can box values. So not really a "serious" issue.


MikeHart(Posted 2011) [#4]
Hi ziggy,

what is this "box values" thingymijingy?


TMK(Posted 2011) [#5]
Ah, cool! Thanks a lot!

@MikeHart

You can use arrays. Here's how I did it:

Function ReturnMultiplevalues(a:int[])
	a[0] = 10
	a[1] = 20
	a[2] = 30
End

Function PrintNumbers()
	Local arr:int[3]
	ReturnMultiplevalues(arr)
	Print arr[0] + ", " + arr[1] + ", " + arr[2]
End



ziggy(Posted 2011) [#6]
Using arrays is a way of boxing. The other whould be using a class that acts like an Int container. That's boxing.


MikeHart(Posted 2011) [#7]
Thanks for the valuable info. Much appreciated.