jrincayc / ucblogo-code

Berkeley Logo interpreter
https://people.eecs.berkeley.edu/~bh/logo.html
GNU General Public License v3.0
187 stars 34 forks source link

and True False returns True #124

Closed stoverc closed 2 years ago

stoverc commented 2 years ago

and True False when it should return False.

Screen Shot 2022-01-30 at 7 31 42 PM
stoverc commented 2 years ago

Similarly, (and true false false) returns true.

jrincayc commented 2 years ago

We can get the expected behavior if we do:

make "true (1 = 1)
make "false (1 = 0)

Then:

? and true false
You don't say what to do with false
? (and true false false)
You don't say what to do with false
jrincayc commented 2 years ago

I didn't see anywhere in the documentation saying that we define true and false. @brianharvey Any opinion on if we should add true and false to the initial environment?

stoverc commented 2 years ago

It doesn't say they're defined, per se, but it does say they're "special":

Screen Shot 2022-01-30 at 8 22 33 PM

Clearly not a definitive thing, but it is somewhat suggestive.

brianharvey commented 2 years ago

On 1/30/22 5:16 PM, Joshua Cogliati wrote:

I didn't see anywhere in the documentation saying that we define true and false. @brianharvey Any opinion on if we should add true and false to the initial environment?

I don't have a strong opinion either way, but those examples would have worked if the words were quoted (like any other situation in which you want a literal word as an input): AND "TRUE "FALSE and so on.

stoverc commented 2 years ago

Ahhhh, this makes sense. I apologize for my ignorance; I'm new to Logo (just got it a couple days ago to expose my son to some programming stuff) so I'm pretty unsure about a lot of things like this.

Thanks for entertaining my situation, and I'm sorry for wasting everyone's time.

jrincayc commented 2 years ago

Hm, maybe we should add some examples in the logical operations section of the manual with "true and "false.

stoverc commented 2 years ago

That definitely wouldn't hurt. 👍