Boolean Lisp<->Javascript conversion
[jscl.git] / src / prelude.js
index 162058e..9f78f4a 100644 (file)
@@ -2,8 +2,12 @@
 // contain runtime code that jscl assumes to exist.
 
 var window = this;
+
+var t;
 var nil;
 
+var lisp = {};
+
 globalEval = eval;  // Just an indirect eval
 
 function pv (x) { return x==undefined? nil: x; }
@@ -59,7 +63,7 @@ function codepoints(string) {
 // Create and return a lisp string for the Javascript string STRING.
 function make_lisp_string (string){
     var array = codepoints(string);
-    array.type = 'character'
+    array.stringp = 1
     return array;
 }
 
@@ -112,8 +116,12 @@ function Symbol(name, package_name){
 }
 
 function lisp_to_js (x) {
-    if (typeof x == 'object' && 'length' in x && x.type == 'character')
+    if (typeof x == 'object' && 'length' in x && x.stringp == 1)
         return xstring(x);
+    else if (x === t)
+      return true;
+    else if (x === nil)
+      return false;
     else if (typeof x == 'function'){
         // Trampoline calling the Lisp function
         return (function(){
@@ -129,6 +137,10 @@ function lisp_to_js (x) {
 function js_to_lisp (x) {
     if (typeof x == 'string')
         return make_lisp_string(x);
+    else if (x === true)
+        return t;
+    else if (x === false)
+        return nil;
     else if (typeof x == 'function'){
         // Trampoline calling the JS function
         return (function(values, nargs){