Arc Forumnew | comments | leaders | submit | zackman's commentslogin
3 points by zackman 5927 days ago | link | parent | on: "." not allowed in quasiquote?

Scheme's map doesn't handle improper lists, I guess. On line 167 of ac.scm, replace the following expression:

  (map (lambda (x) (ac-qq1 level x env)) x)
with

  (let loop ((x x) (acc '()))
    (cond ; inline map to handle improper lists
      ((null? x) (reverse acc)) ;properly terminated list
      ((pair? x) (loop (cdr x) (cons (ac-qq1 level (car x) env) acc)))
      (else (append (reverse acc) (ac-qq1 level x env)))))
I realise it looks stupid to write an inline map that handles improper lists. Is there a better way to do this?

-----

3 points by zackman 5927 days ago | link | parent | on: "." not allowed in quasiquote?

This works around the bug for variable arguments, at least.

  arc> `(fn ,(cons 'name 'args) args)
  (fn (x . args) args)

-----

1 point by jimbokun 5927 days ago | link

Thanks! I think this will work best for me for now. But the suggested change to ac.scm is probably the best fix long term.

-----


A couple more comments:

(1) Upon reading arc.arc, I noticed that strings not being lists is a compromise, implying that whole set of problems may go away at some point.

(2) "If you want Haskell, you know where to find it". I really do think that the Right Thing is for the list to be built of the return type of first function. But that is impossible in a dynamically typed language so the Right Thing is probably the type of the sequence map was given.

However, from a pragmatic standpoint, I've more often needed to map the characters of a string to something else. I know this because most Scheme code where I map over a string looks like this: (map (lambda (c) (char->integer c)) (string->list "foo"))

In the PLT standard collects, it looks like about it's about half and half, though; perhaps a few more uses of map in which the return type is not ultimately a string.

-----