I think just support for what the original poster asked for would be fine, all that other stuff is largely unnecessary.
Slightly off-topic here but this alias is marginally faster than yours plus it can take letters (and it doesn't use a nasty goto).
my_rand {
if ($+($1,$2) !isnum) return $rand($1,$2)
if ($rand($1,$calc($2 + 1)) <= $2) return $ifmatch
return $1
}