Oxygen Basic
Programming => Bugs & Feature Requests => Topic started by: Mike Lobanovsky on May 28, 2014, 01:27:05 AM
-
Charles,
This generates an error:
dim as string ch = "a"
print asc(ch) >= asc("0") and asc(ch) <= asc("9")
Frankly, I'm starting to get a little nervous with this Toy interpreter port... :(
.
-
Mike,
I suggest assigning the boolean to an integer first
dim as string ch = "a"
sys a= (asc(ch) >= asc("0") and asc(ch) <= asc("9"))
print a
Oxygen does not resolve asc("0"), or other functions into a constant, so the code it generates in this kind of expression is rather cumbersome.
-
Frankly, I'm starting to get a little nervous with this Toy interpreter port...
Heh ...me to
By the way Mike...
you convert FBSL version to Oxygen...right?
I am coverting FreeBasic vesions.... ::)
-
Hi Aurel,
From the standpoint of conventional BASIC, the FB and FBSL versions are almost identical barring very very minor differences in a couple keywords and array syntax. OTOH Oxygen behaves in an unexpected way only too often compared to the other two languages.
Charles,
Implied apologies acknowledged at the bottom of my language developer heart but they are hardly acceptable by my language user ego. :D
IMHO these glitches should be fought against even if it isn't very convenient programmatically. I can't figure out how an imaginary language add-on might be able to suppress them if they are generated at such a low level in the core. Such an add-on would require at least an additional va_arg parser and evaluator.
And BTW, print is here only for demo purposes. It doesn't work even with a simple if in the Toy interpreter code.
-
This format should work:
dim as string ch = "a"
if asc(ch) >= asc("0") and asc(ch) <= asc("9")
print 1
else
print 0
end if
I am tempted to create a new error trap for expression like this, which generate excessively lengthy machine code. "Err: Plonking expression overload" :)
-
which generate excessively lengthy machine code.
which means what ?
bigger exes ?
-
Hi Aurel,
Size is not really the problem its execution speed / efficiency / CPU load. You can readily see how much code is produced for any line by using #show:
#show if asc(ch) >= asc("0") and asc(ch) <= asc("9")