Pointer syntax in ARM BASIC?
Alex Farlie (3076) 16 posts |
There was a post over on Stardot https://stardot.org.uk/forums/viewtopic.php?f=63&t=20182 concerning adding fucntionality into BBC BASIC for SDL, to allow a “built-in way of assigning a memory address to a structure” (BBC BASIC for SDL supports a structure syntax) This got me wondering if other than indirection operators there was ever a pointer syntax considered for ARM BASIC? |
Steve Drain (222) 1620 posts |
Considered, yes, implemented, no. Basalt has the
Basalt implements structures in a different way to BB4W and Richard’s ongoing versions. It has always allowed a structure to be applied to an existing block of memory, eg: prototype=DEF(STRUCT OF integer%,string$,float|) structure=NEW(prototype TO block%) This can be used to access a window block, so you could have: Window=DEF(STRUCT OF handle%,visible{Rectangle},scroll{Vector},behind%,window#(31), colours?(7),workarea{Rectangle},title#(31),button%,sprites%,minimum%, title$[11],icons%,icon(20){Icon}) SYS "Wimp_GetWindowInfo",,window% window=NEW(Window TO window%) PRINT \window.icon(3).text$ Edit: This does expect the structures |
Alex Farlie (3076) 16 posts |
The approach in “BBC BASIC for SDL” is noted here:- https://stardot.org.uk/forums/viewtopic.php?f=63&t=19798&start=120#p287985 (Also- https://groups.io/g/bb4w/topic/76065935#23449) Is there a mechanism for suggesting ARM BASIC in Risc OS Open adopts an equivalent approach? Having a “pointer” syntax in ARM BASIC alongside the current indirection operators would aid code readability. |
Steve Drain (222) 1620 posts |
Any changes are constrained in much the same way Richard is constrained with BB4W. He has a free-er hand with the SDL versions, I think.
Yes, which is why Basalt has
I entirely agree. In my example above you would pass a window block to a SWI as PTR!(window), that is if it is a new structure. ;-) |
Alex Farlie (3076) 16 posts |
I seem to recall some SWI’s accept a pointer as R0 or R1, as opposed to having to setup an entire sequence of registers? |
Rick Murray (539) 13840 posts |
Many SWIs accept/return pointers – window manipulation, poll blocks, reading the time, listing what files are in a directory…… |