Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compiler failure
#1
This simple snippet creates a C++ Compilation Error:

Code: (Select All)
T = 10
T = T Not T
Obviously NOT toggles -1 to 0 and back again but it is interesting to note.. Big Grin 

Erik.
Reply
#2
10 NOT 10...   I can see why that's an error.  There's no operators there between the first 1 and NOT.

Make that 10 * NOT 10, and all is good.
Reply
#3
(05-24-2024, 07:31 AM)SMcNeill Wrote: 10 NOT 10...   I can see why that's an error.  There's no operators there between the first 1 and NOT.

Make that 10 * NOT 10, and all is good.

T = 10
T = T * NOT T
PRINT T
PRINT
T = 10
T = T * -T
PRINT T
END

What results must be 2 "Print T"?
Hi from beautiful Greece .
Reply
#4
Code: (Select All)

T = 10
' Compute the bitwise NOT of T
' NOT 10 is -11 in QB64 (bitwise NOT flips the bits)
T = T * NOT T
' T now becomes 10 * -11 = -110
PRINT T
PRINT

T = 10
' Compute the negation of T
T = T * -T
' T now becomes 10 * -10 = -100
PRINT T
END
No comments.
Reply
#5
Code: (Select All)
t = 20
Print t _Negate t

no compile error ;-))
b = b + ...
Reply
#6
(05-24-2024, 04:40 PM)gaslouk Wrote:
Code: (Select All)

T = 10
' Compute the bitwise NOT of T
' NOT 10 is -11 in QB64 (bitwise NOT flips the bits)
T = T * NOT T
' T now becomes 10 * -11 = -110
PRINT T
PRINT

T = 10
' Compute the negation of T
T = T * -T
' T now becomes 10 * -10 = -100
PRINT T
END
No comments.
I think this is the solution I was looking for! Thanks. Erik.

It might be a workaround but still begs the question why it causes a compilation error when trying T = T NOT T
Reply
#7
T NOT T should not be allowed. NOT is unary operator, like making a number negative.

the problem is somebody could write T -3 then compiler picks it up as T - 3. so why can't NOT work the same way, programmer asks? because NOT was designed to work with one integer at a time.

programmer asks if he doesn't use the ide. try to type T -3 in ide and it puts space between minus and 3.

new _NEGATE cause more confusion. is it only supposed to be used in IF statement?

do not load compilelog.txt into ide. creates very strange characters which should be utf-8, for fancy single-quote. this is just a disgusting thing g++ does.
Reply
#8
As I wrote earlier in the topic here, the issue is a lack of operators between the number and the function.

Would any of the following make sense to anyone?

10 ABS(10)
10 SIN(10)
10 LOG(10)
10 _PRINTWIDTH("10")

If that first 10 is a line number, then.... they're all still wrong as ABS(10) does nothing by itself.  It's not assigned as a value to a variable or array.  It's not being sent into any function.  It's just doing what exactly??

Now, if that 10 is supposed to be part of some math function, exactly what is the computer supossed to do?  Automatic multiplication?  I'm afraid that's not a syntax that BASIC recognizes.  

All the above are errors, and are obvious errors which the IDE catches and flags for you.

10 NOT 10, is the exact same type of thing, but it currently slips past the built-in error catching.  It's nothing more than a glitch that simply isn't caught and flagged by the IDE, which causes the g++ compiler to point it out once it gets to it instead.

There's no mystery as to what's going on here.  It's just an error that g++ is catching instead of the qb64 IDE.
Reply
#9
Quote:There's no mystery as to what's going on here.  It's just an error that g++ is catching instead of the qb64 IDE.
Then I am declaring a official glitch in the IDE that is not being trapped before the compilation. Big Grin

Erik.
Reply




Users browsing this thread: 5 Guest(s)