Arc Forumnew | comments | leaders | submitlogin
(map _!name bleh)
2 points by d0m 5168 days ago | 3 comments
Hi, it's me and my annoying suggestion (again) :-/

I think _ could be use in a somewhat strange way but which might be useful:

  (= bleh (map [obj num _] (range 1 5)))

  (map _!num bleh) === (map [_ 'num] bleh) 

or:

  (let b 'num
    (map _.b bleh))  === (map [_ b] bleh) 

My reasoning is that _ is highly bound to [ ] so it makes sense that _.a be transformed into [_ a] instead of (_ a).

Sadly, I'll give the first counter-argument to my suggestion:

(This is from PG in a HN comments) :

    (defop offerless req
      (offerlesspage (get-user req)))

    (newscache offerlesspage user 90
      (listpage user (msec)
                ranked-stories*
                [and (>= (realscore _) front-threshold*)
                     (cansee user _)
                     (no (begins _!title "Offer "))
                     _]
                nil nil "offerless")) 
Since _ is already bound in the outer scope, that wouldn't work anymore.


7 points by fallintothis 5168 days ago | link

  $ grep "(def get" arc.arc
  (def get (index) [_ index])

  arc> (ssexpand '.a)
  (get a)
  arc> (ssexpand '!b)
  (get (quote b))
  arc> (= bleh (map [obj num _] (range 1 5)))
  (#hash((num . 1)) #hash((num . 2)) #hash((num . 3)) #hash((num . 4)) #hash((num . 5)))
  arc> (map !num bleh)
  (1 2 3 4 5)
  arc> (let b 'num (map .b bleh))
  (1 2 3 4 5)

-----

1 point by akkartik 5167 days ago | link

That explains the cryptic errors about get I've gotten on occasion. Thanks!

-----

1 point by d0m 5168 days ago | link

awesome!

-----