Arc Forumnew | comments | leaders | submitlogin
2 points by akkartik 5155 days ago | link | parent

Could we get rid of the ./! distinction by having it check if the second operand is bound?

  (. userinfo user stations station read-list doc title)


3 points by evanrmurphy 5155 days ago | link

I think you're onto something!

This would mean that (h k) in table access would sometimes be synonymous with (h k). If k is bound, look up the value of k, else look up the symbol k. If k is ever bound but you actually wanted to pass in the symbol, you can still use (h 'k).

---

Since this all boils down to entities in functional position, why not take it a step further: auto-quote [1] all unbound symbols, the ones most relevant to this discussion being those passed as arguments to functional position entities, including functions, lists, tables and strings.

Ramifications:

  > (def f(x) (list 1 2 x))
  #<procedure: f>

  > (f x)
  (1 2 x)
  > f.x
  (1 2 x)
  > (= x 3)
  3
  > (f x)
  (1 2 3)
  > f.x
  (1 2 3)
  > f.x.0
  1

  > f.h
  (1 2 h)
  > (= h (obj k1 'v1 k2 'v2))  ; [2]
  #hash((k1 . v1) (k2 . v2))
  > f.h
  (1 2 #hash((k1 . v1) (k2 . v2)))
  > f.h.2
  #hash((k1 . v1) (k2 . v2))
  > f.h.2.k1
  v1
I like this...

---

[1] Perhaps another way to think about this, instead of in terms of quotation, is that all symbols are initially bound to themselves. (Note that this plays nicely with t and nil.)

[2] Actually, by the same principle this could be written:

  (= h (obj k1 v1 k2 v2))
You don't need to quote v1 and v2 because they're unbound in the enclosing environment.

-----

1 point by Pauan 5155 days ago | link

I really like the idea of combining the two. It seems like there's such a small distinction between them that they really serve a similar purpose. This would also solve all the problems with discussions about alternate syntaxes, since there would be a single syntax for both.

Crazy idea, having symbols bound to themselves by default. I wonder if that would cause any problems, though... sounds like an interesting idea to experiment with.

-----

1 point by evanrmurphy 5155 days ago | link

No responses yet, eh? I should have known that the incredible glory of this idea would leave you all speechless. XD

Here's another thing it gives you for free, super convenient alist initialization:

  > (x.1 y.2)
  ((x 1) (y 2))
  > (= a that)
  ((x 1) (y 2))
  > (alref a x)
  1
And then, with a variation on http://awwx.ws/alistcall, you get super convenient alist lookups too:

  > a.x
  1

-----

2 points by akkartik 5155 days ago | link

Patience, I was trying to make wart autoquote :) The obvious place to start is just call with one arg, but I am stumped trying to make this test pass:

  (test "call on one arg autoquotes"
    :valueof (call 'idfn xxzx)
    :should be 'xxzx)
It's the old problem with wart: there's no way to check if a variable has a lexical binding.

Hmm, I wonder if I should shoot for the moon and find the right handler to install for the UNBOUND-VARIABLE condition..

Update: I'm tantalizingly close, but perhaps it's not possible. This page outlines how: http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node322.html

But I'm concerned by the phrase, "If this [restart clause] were part of the implementation of symbol-value.." Does that mean it isn't possible?

If we can do this we can also handle 'undefined-function and turn wart into a lisp-1!

-----

1 point by evanrmurphy 5155 days ago | link

Oh I see. You're actually doing something instead of just sitting here yappin' about possibilities. Delay excused then. XD

-----