Referencing extended to Arrays

The new variable referencing facility has been extended to arrays and even array references… I’ve tested it even on function parameters and it seems to work which is awesome… exhaustive testing has not been done ‘cos, well, nobody seems to use this site much anyway let alone code as deeply as using reference variables (check out my tiny violin), but trust me, it’s pretty impressive stuff, and highly useful.

One tiny note:
You cannot reference individual array elements, because I haven’t REALLY implemented dereferencing properly, you can only reference the whole array and index it from there, e.g.

$z=\$x[0] ;
&print $z; ## expecting 5?

…wont work.
Reference the whole thing and dereference the reference as if it were an array like so:

&print $$z[0];

New! Reference Variables

Highly experimental but I now have implemented rudimentary Reference Variables and Pass-By-Reference for functions in SEL. For those who are not familiar with references in programming here’s how it is useful e.g.:

$y=\$x; ## $y is now a reference for $x
&print $$y; ## prints 5, note the DEREFERENCING with $$
&print $$y; ## prints 10 since $$y is effectively what $x is

Example of passing by reference to a function:
sub testPBR(\$x){
return 5;

&print $x; ## prints 20! This is because $x has been modified in function
&print $$y; ## also prints 20 since $$y is still a reference to $x
&print $z; ## prints 5, this means you can modify as many vars as you like by calling a function and still have the return variable free for use.

What is Beeblbrox reading?

This, and it’s absolutely everything I want so far from a gamebook, 700 references of dungeoncrawling goodness, well written, a decently thought out but simple mechanic system and beatifully presented. Mind you I am only about 20 references into exploring it – however I doubt it’s gonna go far wrong.

(No my minions, we don’t have permission to encode and publish it. One day, my adventure hungry little friends, one day…). Until then , buy your own:

Straight outta Blacksand

Skip to toolbar