[M3devel] Strange behavior in recent CM3-compiled code...

Mika Nystrom mika at async.caltech.edu
Tue Jun 16 09:01:18 CEST 2009


Hello everyone,

I'm trying to update to the latest CM3 again, so that I can get my
Mac working, and push my project of migrating a largish codebase
from PM3 to CM3 a little further.

I updated CM3 today from CVS, on both my Mac and on a FreeBSD system,
and ... my Scheme interpreter broke.  Here's what the code looks like,
with annotations:

     49     Debug.Out("t.rest = NIL? " & Fmt.Bool(t.rest=NIL));
     50     Debug.Out("ISTYPE(t.rest,T)? " & Fmt.Bool(ISTYPE(t.rest,T)));
     51     Debug.Out("Rest(t.rest) = NIL? " & Fmt.Bool(Rest(t.rest)=NIL));
     52
     53     IF t.rest # NIL AND ISTYPE(t.rest,T) AND Rest(t.rest) = NIL THEN
     54       Debug.Out("in IF clause...");
     55
     56       IF    SymEq(t.first, "quote") THEN             special := "'"
     57       ELSIF SymEq(t.first, "quasiquote") THEN        special := "`"
     58       ELSIF SymEq(t.first, "unquote") THEN           special := ","
     59       ELSIF SymEq(t.first, "unquote-splicing") THEN  special := ",@"
     60       END
     61     ELSE
     62       Debug.Out("in ELSE clause...")
     63     END;

all you need to know is that Debug.Out prints out debugging information
to the terminal.  What I see is...

t.rest = NIL? FALSE
ISTYPE(t.rest,T)? TRUE
Rest(t.rest) = NIL? TRUE
in ELSE clause...

What gives!?

Note this behavior occurs on both the Mac and on FreeBSD4 with a
compiler and runtime bootstrapped today from some previous CM3.
My old CM3 compiler was timestamped... April 30, I believe, and the
code behaved properly under that one.

I believe I have also tried it both with and without compiler
optimizations.

I find it baffling that so much stuff (mentor!) can work if "AND" isn't
working right.  This is the only if statement in many, many source files
that seems to be working wrong.

Is it possible I'm missing something??  No I don't think so... here's a more
explicit version:

    Debug.Out("t.rest # NIL? " & Fmt.Bool(t.rest#NIL));
    Debug.Out("ISTYPE(t.rest,T)? " & Fmt.Bool(ISTYPE(t.rest,T)));
    Debug.Out("Rest(t.rest) = NIL? " & Fmt.Bool(Rest(t.rest)=NIL));
    Debug.Out("conjunction? " & Fmt.Bool(
       t.rest # NIL AND ISTYPE(t.rest,T) AND Rest(t.rest) = NIL ));
    IF t.rest # NIL AND ISTYPE(t.rest,T) AND Rest(t.rest) = NIL THEN
   ...

output is:

t.rest # NIL? TRUE
ISTYPE(t.rest,T)? TRUE
Rest(t.rest) = NIL? TRUE
conjunction? FALSE
in ELSE clause...

TRUE AND TRUE AND TRUE is FALSE??

Note that:   

  VAR q, w, e := TRUE;

    Debug.Out("conjunction? " & Fmt.Bool(
       q AND w AND e));

results in TRUE (as it should).


    Mika




More information about the M3devel mailing list