[added support for an error function which terminates the program with a user-supplied error message mail@stefanwehr.de**20051001130733] { hunk ./Phrac/Interpreter.hs 34 -import Phrac.UniqIdents ( builtinDataId, isMain ) +import Phrac.UniqIdents ( builtinDataId, isMain, isError, mkValId ) hunk ./Phrac/Interpreter.hs 148 - let v = lookupEnv x env - return v + if isError x + then let arg = mkValId "__ error argument __" (-1) + in return $ ClosVal $ Closure emptyEnv [PVar arg] (UserError arg) + else let v = lookupEnv x env + in return v hunk ./Phrac/Interpreter.hs 308 + +eval env (UserError x) = + do val <- evalStrict env (Var x) + let s = printStringList val + panic ("User error: " ++ s) hunk ./Phrac/ParseSyntax.hs 416 - + | UserError ValId -- used to implement the `error' function. + -- the ValId is the identifier to which to + -- error message is bound. hunk ./Phrac/UniqIdents.hs 28 - isMain, + isMain, isError, hunk ./Phrac/UniqIdents.hs 124 +isError (ValId (Id _ s)) = s == "error" hunk ./PhracPrelude.phc 70 +error :: List Char -> __a; +error = error; + hunk ./PhracPrelude.phc 74 -undefined = undefined; +undefined = error "undefined"; }