archives

Depends on what "is" is

Sounds like B. Clinton's evasive (but syntactically correct) answer to some deposition. But it's just a little lesson in associativity.

We want "is" to be synonymous with "=". That sounds reasonable, right? We could do this at the lowest level, at the lexer, and really make things simple.

But here comes "not". It's already an operator, and you want it to be so. And in (my) typeless world, "not" operates on integers just as happily as it does on booleans. There are two reasonable implementations for "not" on integers: multiplying by -1 or the function y = 1 - x. The first is sort of intuitive, the second makes not(1) equal to 0 and not(0) equal to 1.

Either way, you lose. Choose the first, so

"not x" => -1 * x

and examine the expression

0 is not 0

You'd want this to be a false statement, but unfortunately, it might parse like this:

0 is (not 0)
0 is (-0)
0 is 0
true

Yikes!

Tell me that this is just an LL(2) thing and if I look ahead one more token I'll be OK.

What I mean by that is: is my hack a canonical hack? When I see "is" I just greedily look ahead to see if the next token is "not".

LISP and parentheses

I'm just now learning Lisp. It is really sort of fun, but I am thinking that the parentheses issue is probably going to end up being the thing that keeps biting me on the butt. It seems to me that they really shouldn't be much different than managing braces in C, say. Indenting helps. But even if I try to keep that all in order, I get fouled up when I revise or insert code, and waste a lot of time checking the parens and looking for their matches and whatnot.

Has anyone some suggestions on how to approach this issue with Lisp? A good IDE that looks after us poor devils, for example? Or some good habits to get into?

Budsy