Arc Forumnew | comments | leaders | submitlogin
1 point by aw 5234 days ago | link | parent

OK, here's a version that uses the lshift parser that you ported. Uncomment the require file line and put in the path to the original json.ss module...

  (def deepcopylist (xs)
    (if (no xs)
         nil
         (cons (deepcopy (car xs)) (deepcopylist (cdr xs)))))

  (= scheme-f (read "#f"))
  (= scheme-t (read "#t"))
  (= scheme-vector? ($ vector?))
  (= scheme-void? ($ void?))
  (= vector->list ($ vector->list))
          
  (def deepcopy (x)
    (if (is x scheme-t)
         t
        (is x scheme-f)
         nil
        (scheme-void? x)
         nil
        (scheme-vector? x)
         (w/table new
           (each (k . v) (vector->list x)
             (= (new (deepcopy k)) (deepcopy v))))
        (acons x)
         (deepcopylist x)
         x))

  ; ($ (require (file "/tmp/json-scheme-20050827134102/json.ss")))

  (= scheme-json-read ($ json-read))

  (def json-read (s)
    (deepcopy (scheme-json-read s)))
I timed a few runs of your port and this version against your data set; times for both versions varied between 585ms and 831ms on my laptop, but there wasn't a difference that I could see between the two versions given the spread of times for each run.


1 point by akkartik 5234 days ago | link

Interesting that you see no difference! What platform are you on?

BTW, you can replace deepcopylist with simply (map deepcopy x).

-----

1 point by aw 5234 days ago | link

I'm running Linux on my laptop. There could well be a difference, I simply haven't run the tests enough times to be able to tell, given that I'm getting a pretty wide spread of run times for each version. Which could be for example my web browser sucking up some CPU at random times or whatever...

-----