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

Is that inside a quasiquote? I don't follow.


2 points by Pauan 4618 days ago | link

Hm... I assume you're talking about getting rid of the "unquote-splicing" operator. If so, then why can't you do that right now?

  `(foo ,@(list a b c))
Would expand into this:

  (quasiquote (foo (unquote (splicing a b c))))
I'm not entirely sure what the problem is, as to why you can't replace ,@ with @

-----

1 point by akkartik 4618 days ago | link

Holy smokes, you're right!

Update No now I'm confused again. When I see:

  `(cons ,@(list 1 2))
I read it as:

  eval (list 1 2)
  splice it in (to what?)
  insert it into the backtick
When I see:

  `(cons @,(list 1 2))
I read it as:

  eval (list 1 2)
  insert it into the backtick (as say x)

  then at eval time, eval (cons @x)
Neither seems quite what I want.

-----

1 point by Pauan 4618 days ago | link

"`(cons ,@(list 1 2))"

I would assume that it is splicing it into the list. In other words, it would evaluate into this list:

  (cons 1 2)
But I don't know how you're implementing splicing, so I'm not sure how much I can help.

---

"Neither seems quite what I want."

Why not? Both seem to end up as the same end result as you would get in Arc, right?

-----

1 point by akkartik 4618 days ago | link

Yeah I want it to splice it into the list. That's what it does right now. But it takes a special-case. I'm having trouble figuring out how it would work if I removed the special-case from tokenize, parse, and eval. I'm not sure that the behavior of ,@ can be boiled down to just , and @. It should be independent of my implementation.

Perhaps I should just try it, see what happens.

-----

3 points by rocketnia 4618 days ago | link

I think it's kinda intuitive for `(foo ,@(list 1 2)) to expand to (quasiquote (foo (unquote 1 2))). If unquote takes multiple subexpressions, as it does in Common Lisp (http://arclanguage.org/item?id=9912), this can evaluate to (foo 1 2).

However, I really think this should be considered part of the behavior of 'quasiquote. Just like 'unquote has no meaning except as interpreted by 'quasiquote, it's fine for @ to have no meaning except as interpreted by function calls and 'quasiquote.

Hmm... if you say `@(list 1 2), does that pass (splicing (list 1 2)) or something to 'quasiquote, or does it actually pass 1 and 2? If I were trying to accomplish @ with fexprs, I think I'd prefer the former, and I'd treat regular functions/applicatives as though they were fexprs that expanded (splicing ...) manually.

-----

1 point by Pauan 4618 days ago | link

"Perhaps I should just try it, see what happens."

Yeah, that would be my suggestion.

-----