Arc Forumnew | comments | leaders | submitlogin
1 point by thaddeus 5104 days ago | link | parent

For the record I prefer:

  (obj 'a 1 'b 2)
keys are not variable names, so I'll ask (in general) why should obj be treated so special or differently?

Again, as you already pointed out, it boils down to flexibility and consistency. I don't see why I would trade saving one character spot over both 1. being clear & consistent and 2. allowing functions to be passed in:

  (obj (look-up-something) 1 (look-up-something-else) 2)


2 points by rocketnia 5104 days ago | link

Right, but once again, adding a few characters may make things more consistent, but does it aid clarity? I really don't know either way.

Using the same heiroglyphics as I posted last time, we can implement 'case entirely as a function:

  ; Hypothetically, this uses the macros 'def, 'whenlet, 'iflet, and
  ; 'do; the functions 'if, 'testify, 'get, and 'apply; the special
  ; forms 'fn, 'zap, and 'quote; and the read macros
  ; #,x for (fn (gs123) (zap gs123 x)), #'x for (fn () x), and
  ; 'x for (quote x).
  
  (def #,case (subject . args)
    (whenlet (first . rest) args
      (iflet (then . rest) rest
        
        ; Check the testified result of (first) against the subject.
        (if (.subject:testify:do.first)
          
          ; Return the result of (then).
          then
          
          #'(apply case-part-2 subject rest))
        
        ; Return the result of (first). It's the last else.
        first)))
  
  ; was (case x y (dosomething))
  (case x #''y dosomething)
This is even an overall brevity boost, I think. What do you think of its clarity? I seriously might try this out in Penknife....

-----

1 point by thaddeus 5104 days ago | link

Not sure. I find the #''y hard on the eyes :)

Though it reminds me a little on how clojure handles inline anonymous functions, which I really like:

    #{+ %1 %2} ;% being the args, %1 being the first, %2 the second, and so on
wondering if something similar is possible with case:

(case x #(myfun)(dosomething))

yet still able to:

(case x 'y (dosomething))

note: Sorry if I missed something and am suggesting non-sense stuff, I haven't yet looked into the code details you provided - so I could be out to lunch.

-----

1 point by rocketnia 5103 days ago | link

In case you missed the post I referred to, here it is: http://arclanguage.org/item?id=13240

All the necessary assumptions are listed in the top comment though (assuming you can intuit my intentions for the 'iflet macro, etc.). It's by no means implemented. ^^

Also, I welcome any switch in the heiroglyphics that makes them more readable. In Penknife, where there are infix operators but no read macros, I'd probably represent #''y as "thunk:sym.y" or "sym.y^". In Arc, ^'y looks like a good choice. Maybe :y or %y could be the zapper (or some better-suited abstraction over setforms).

-----

1 point by evanrmurphy 5102 days ago | link

> Maybe :y or %y could be the zapper (or some better-suited abstraction over setforms).

Maybe something with `=` in it?

-----

1 point by evanrmurphy 5104 days ago | link

> keys are not variable names, so I'll ask (in general) why should obj be treated so special or differently?

There is at least some precedent of special treatment. In JavaScript's object literals, for example, you can do

  {a : 1, b : 2}
instead of

  {'a' : 1, 'b' : 2}
Then again, in other languages like Ruby, the keys must be explicit symbols:

  {:a => 1, :b => 2}
I'm not sure what the prevailing trend is on this (or whether knowing so would help to inform us about which is the better design choice).

-----