Arc Forumnew | comments | leaders | submitlogin
1 point by akkartik 5236 days ago | link | parent

Yeah, that's a bug. Sigh. The whole nil vs () makes it non-trivial for arc to benefit from mzscheme's extensive libraries.

Hmm, perhaps there's a way to fix it: get the reader to recognize #t, #f, #<void>, and get (is nil ()) to return t. Is that reasonable?



1 point by aw 5236 days ago | link

(is nil ()) does return t:

  arc> (is nil (ac-scheme '()))
  t
or in Anarki,

  arc> (is nil ($ '()))
  t
Arc does treat Scheme's '() as a synonym for nil quite a bit, so there's only a few odd corner cases where the use of '() becomes visible.

Not sure what you mean by getting the reader to recognize #t, #f, #<void>?

For fun I once hacked ac.scm so that Arc's nil was represented internally by Scheme's '(). Inside of Arc everything was still the same: nil was still a symbol and so on. It even seemed to work, though I didn't test it very much.

-----

1 point by akkartik 5236 days ago | link

Most interesting, thanks for these ideas and tips.

The original scheme version converted true to #t, false to #f, and null to (void) which turns into the #<void> literal. These break in arc because #f isn't nil, and #<void> can't even be read by the reader. So I think I have to take a comprehensive look at mzscheme's syntax at some point and make sure that anything scheme code can emit can be read and understood by the arc compiler.

-----

1 point by aw 5236 days ago | link

Oh, do you mean that if, for example, Arc treated #t as a synonym for t, then we wouldn't have to do that conversion ourselves manually?

-----

1 point by akkartik 5236 days ago | link

Yes.

-----

1 point by aw 5236 days ago | link

hmm, ac.scm is a module, so you should be able to import it into json.ss:

  (require "../ac.scm")
that would give you access to ac-niltree, so at the point where json.ss is creating a list you could convert it to a nil-terminated list.

Another option is to recursively copy the return value of json-read.

-----