Author Topic: LHS/RHS Compare Error  (Read 3224 times)

0 Members and 1 Guest are viewing this topic.

Mike Lobanovsky

  • Guest
LHS/RHS Compare Error
« 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... :(

.

Charles Pegge

  • Guest
Re: LHS/RHS Compare Error
« Reply #1 on: May 28, 2014, 03:37:38 AM »
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.

Aurel

  • Guest
Re: LHS/RHS Compare Error
« Reply #2 on: May 28, 2014, 03:52:17 AM »
Quote
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.... ::)

Mike Lobanovsky

  • Guest
Re: LHS/RHS Compare Error
« Reply #3 on: May 28, 2014, 05:13:41 AM »
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.
« Last Edit: May 28, 2014, 05:30:31 AM by Mike Lobanovsky »

Charles Pegge

  • Guest
Re: LHS/RHS Compare Error
« Reply #4 on: May 28, 2014, 06:23:19 AM »
This format should work:

Code: [Select]
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" :)
« Last Edit: May 28, 2014, 06:42:43 AM by Charles Pegge »

Aurel

  • Guest
Re: LHS/RHS Compare Error
« Reply #5 on: May 28, 2014, 10:05:54 AM »
Quote
which generate excessively lengthy machine code.
which means what ?
bigger exes ?

Charles Pegge

  • Guest
Re: LHS/RHS Compare Error
« Reply #6 on: May 28, 2014, 10:28:58 AM »
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")