diff --git a/lua.lua b/lua.lua index 567b167..cb5336f 100644 --- a/lua.lua +++ b/lua.lua @@ -198,29 +198,7 @@ local function scmto(x) elseif x==null or is_pair(x) then error("NULL/PAIR!") elseif is_vector(x) then - local t=sym2str(vector_ref(x,0)) - if t=="_v" then - local v=x[2] - local r={} - for i=2,#v do - r[i-1]=scmto(v[i]) - end - return r - elseif t=="hashv" then - local v=vector_ref(x,1) - local r={} - while not is_null(v) do - local x=car(v) - local k=tostr(car(x)) - if r[k]==nil then - r[k]=scmto(cdr(x)) - end - local v=cdr(v) - end - return r - else - error("STRUCT!") - end + error("VECTOR!") elseif is_symbol(x) then return sym2str(x) elseif is_atom(x) then @@ -256,7 +234,7 @@ toscm=function(x) for k,v in pairs(x) do r=cons(cons(symbol(tostring(x)),toscm(v)),r) end - return vector(symbol("hashv"),r) + error("HASH!") end elseif is_procedure(x) then return function(...) diff --git a/lua.rkt b/lua.rkt index 192c031..279041e 100644 --- a/lua.rkt +++ b/lua.rkt @@ -191,17 +191,23 @@ [(string? x) (format "~s" x)] [(char? x) (++ "char(" (format "~s" (string x)) ")")] [else (error 'quote x)])) -(define max-len 55) -(define (%QUOTE x var c) +(define max-c 10) +(define (%QUOTE x c f) (if (pair? x) (if (> c max-c) - (let ([as (gensym)] [ds (gensym)]) - (let ([a (%QUOTE (car x) as 0)] [d (QUOTE (cdr x) ds 0)]) - (++ - a - d - (newvar+set var (++ "cons(" a "," d ")"))))) - ( + (let ([var (symbol->string (gensym))]) + (%QUOTE (car x) 0 (λ (a c) + (%QUOTE (cdr x) c (λ (d c) + (++ + (newvar+set var (++ "cons(" a "," d ")")) + (f var (+ c 1)))))))) + (%QUOTE (car x) c (λ (a c) + (%QUOTE (cdr x) c (λ (d c) + (f (++ "cons(" a "," d ")") (+ c 1))))))) + (f (QUOTE1 x) (+ c 1)))) +(define (QUOTE x) + (block + (%QUOTE x 0 (λ (x c) (return x))))) (define (feval x) (++