Arc Forumnew | comments | leaders | submitlogin
3 points by thaddeus 5122 days ago | link | parent

Being related to the topic at hand I thought this may be of interest:

http://arclanguage.org/item?id=4247



1 point by akkartik 5122 days ago | link

Ooh, interesting. Thanks. &o and &k, hmm.. arc is basically like a lisp-1 lisp, so this would embrace that further.

clarification: ..like a lisp-1 common lisp.

-----

2 points by rocketnia 5121 days ago | link

What do &o and &k have to do with lisp-1-ness?

-----

1 point by akkartik 5121 days ago | link

Arc seems mostly like common lisp (nil vs (), nil vs #f, unhygienic macros, ..); the only two things it shares with scheme seem to be being a lisp-1 and dot syntax for rest args. Now &o makes the optional syntax similar to common lisp as well.

-----

1 point by evanrmurphy 5121 days ago | link

So when you said "lisp-1 lisp", that second "lisp" was referring to Common Lisp, not the general lisp family of programming languages?

I was just confused by that phrase. In any case, now I understand your point.

-----

1 point by akkartik 5121 days ago | link

Yeah I wasn't clear. I've been thinking about lisp-1 vs lisp-2 ever since http://arclanguage.org/item?id=12814

-----

1 point by evanrmurphy 5121 days ago | link

For what it's worth, I think your `?` looks much nicer than `&o`, and it elegantly fits into the language so long as we continue to have no ssyntactic use for the question mark.

-----

2 points by akkartik 5121 days ago | link

Yeah, the & is just a superficial point. But I've been thinking more about &key in common lisp. I thought it was pretty redundant if you get pervasive keyword args, but there's one case it doesn't cover: if you want your rest args to take priority over the optionals.

Consider the final versioning of updating that I came up with at http://arclanguage.org/item?id=12974:

  (mac updating(place ? expr t iff 'is . body)
    (w/uniq rhs
      `(let ,rhs ,expr
         (unless (,iff ,place ,rhs)
           (= ,place ,rhs)
           ,@body))))
It's nice to have the optional args when I need them, but I need to either specify both or say :body to begin the rest args:

  (mac firsttime(place . body)
    `(updating ,place
        :body
          ,@body))
If I had 'greedy rest args' or 'lazy optionals' I could make the rest args take precedence instead. Hmm.

Update: But it looks like I can't allow both these formulations at once:

  ; A
  (updating (uvar u last-login) (date)
    (++ karma.u))

  ; B
  (ret max 0
    (each elem '(1 3 2 6 5)
      (updating max :iff > elem
        (prn "max now: " max))))
Perhaps I can use ?? for lazy optionals:

  (mac updating(place ? expr t ?? iff 'is . body)
    (w/uniq rhs
      `(let ,rhs ,expr
         (unless (,iff ,place ,rhs)
           (= ,place ,rhs)
           ,@body))))
Now I can say both A and B above, but must have :body in:

  ; C
  (mac firsttime(place . body)
    `(updating ,place
        :body
          ,@body))
What do you think? Am I over-optimizing? :)

Update 2: Hmm, perhaps I should get rid of required args (your suggestion) and have eager optionals (default), lazy optionals after '?', and rest.

-----

2 points by rocketnia 5121 days ago | link

IMO, as long as we don't have ? ssyntax, ? should be usable as a local variable name, which a special parameter list meaning defeats. Conversely, &o is already impractical as a variable name thanks to & ssyntax, so it can have a special meaning in parameter lists without introducing any warts. (I consider it a wart that in official Arc 3.1, 'o can only be used as a variable name when not destructuring.)

-----

2 points by akkartik 5121 days ago | link

I think I disagree. o is certainly a wart, but ? seems unlikely to be a variable name anyway. Have you actually used ? as a variable name before?

There's nothing special about ssyntax. If we would consider using ? as ssyntax, it's fair game to use for other syntactic purposes as well.

Update: A second rationale. As waterhouse found out (http://arclanguage.org/item?id=12612) arc is extremely permissive about letting us override things, so there's no point focusing on what is legal in this arbitrary implementation.

A third rationale. Right now you want to disallow ? because it's not ssyntax. When it becomes ssyntax won't it still be unusable in arglists for the same reason & is unusable now? :) At that rate we'd never get syntax inside arglists. Which may be a plausible position, but then we should be arguing about whether arglists can benefit from syntax.

-----

1 point by rocketnia 5121 days ago | link

Have you actually used ? as a variable name before?

I agree with you that it's unlikely. I'm mainly just a consistency nut. :) I'd like for every symbol to be seen as either special everywhere, maximizing its potential power, or else special nowhere, maximizing the number of macros that'll know what to do with it.

At least, I like this kind of consistency as long as the language/utility is going for ease of customization ('cause of fewer cases to cover) and minimalism. When it comes to making code readable and writable, consistency can be less important.

---

A second rationale. As waterhouse found out (http://arclanguage.org/item?id=12612) arc is extremely permissive about letting us override things, so there's no point focusing on what is legal in this arbitrary implementation.

For a language people are eager to make breaking changes to for their own purposes, that's true. But several programmers trying to make interoperable code won't each make breaking changes independently, right? Arc may promote a philosophy of fluidity, but any particular version of Arc is still made immovable by the community that uses it.

---

A third rationale. Right now you want to disallow ? because it's not ssyntax. When it becomes ssyntax won't it still be unusable in arglists for the same reason & is unusable now? :) At that rate we'd never get syntax inside arglists. Which may be a plausible position, but then we should be arguing about whether arglists can benefit from syntax.

Hmm? You've got what I'm saying completely backwards. I think we should commit to having ? be completely special (a kind of ssyntax, for instance) as long as we want it to be special in parameter lists. Meanwhile, & is totally usable for special behavior in parameter lists, since it's already useless for normal behavior (variable names).

-----

1 point by akkartik 5121 days ago | link

I think I'm ok with us as a community saying "this version of arc treats ? as ssyntax" without necessarily having any code to do so :) expand-ssyntax for ? is the identity until we come up with a use for it. "Use ? as a variable at your own risk."

(Probably a strawman.) What I don't want is to start reserving tokens or characters 'for later use' and enforcing that they can't be variables and so on. Common Lisp does this and it's stupid. Did you know you can't declare a function called type even though it doesn't do anything, hasn't done anything for the past 15 years? What a colossal waste of a great token! https://github.com/akkartik/wart/blob/master/009core.lisp#L1

---

You've got what I'm saying completely backwards.

Ah yes, I did. You said &o is ok.

It does raise the question of the right way to setup ssyntax. Either we're making changes to expand-ssyntax everytime we want a special case to turn off ssyntax expansion or we're saying "leave & as is when it begins or ends a symbol."

But then you could argue that &o is still impinging on a potential variable name. It's starting to feel like arguing about angels and pinheads; why is it ok to pun + and & and : so they do different things in different contexts, but not use ? because of some speculative fear of potentially punning variable names?

-----

1 point by rocketnia 5121 days ago | link

Those are all questions I worry about. ^_^ I'm really itching to post about Penknife's syntax, since I think it does a good job of dissolving these issues.

-----

1 point by evanrmurphy 5121 days ago | link

> I'm really itching to post about Penknife's syntax, since I think it does a good job of dissolving these issues.

I'd like to know more about this.

-----

1 point by rocketnia 5120 days ago | link

Ye sorta receive. ^_^ http://arclanguage.org/item?id=13071

-----

1 point by evanrmurphy 5121 days ago | link

I see what you mean. So what are some ideas for an eventual `?` ssyntax? (I realize this is kind of changing the subject...)

-----

1 point by rocketnia 5121 days ago | link

Well, one thing I've occasionally considered is having string?b become [isa b 'string]. :-p That would only do so much though, since you can just define (def a- (type) [isa _ type]) and say a-!string.b.

A while ago I was thinking of using a?b to mean (b a), with the question mark acting as sort of a backwards-pointing period. Now, for Penknife, I'm using a'b for that purpose, since it's sorta an upside-down period and it doesn't require the shift key (or even reaching off of the home row). However, a'b is parsed as two expressions in Arc, so using a`b or a?b for this purpose would probably be easier.

-----

1 point by akkartik 5121 days ago | link

I'm starting to see the reason for your fears around ? :)

-----