toptr improvements

toptr will return NULL (a new constant)if the variable doesn’t exist. == and != now support comparing pointers.

This is the new toptr.boo example which checks if the function exists before calling:

number f
file_open f "word.txt" "r"
string s
file_read f s
file_close f
pointer p
= p (toptr s)
if (!= p NULL) go nope
	call `p
:go
	print "NOPE!\n"
:nope
function foo
{
	print "foo!\n"
}
function bar
{
	print "bar!\n"
}
function baz
{
	print "baz!"
}

Comments

2 responses to “toptr improvements”

  1. tremblin Avatar
    tremblin

    By The way, this supports BOOBOO functions only, it won’t work to call “print” or something builtin.

  2. tremblin Avatar
    tremblin

    By The way, you could check if it’s a function first using typeof.

Leave a Reply

Your email address will not be published. Required fields are marked *