Arc Forumnew | comments | leaders | submitlogin
4 points by kens 6131 days ago | link | parent

I noticed that colon syntax is broken when used with strings-as-functions:

  arc> (pr:"abc" 2)
  Error: "car: expects argument of type <pair>; given ()"
I was expecting that to work the same as (pr ("abc" 2))


5 points by sjs 6130 days ago | link

Indeed, and it does when you call compose directly. The good news is that if you name the string it works as expected.

  arc> (= s "abc")
  "abc"
  arc> (prn:s 1)
  b
  #\b
The reader splits expressions such as (prn:"foo":[idfn _] 2) into (prn: "foo" : (make-br-fn (idfn _) 2). You could check for trailing : in the car or a leading : in the cadr, and if found then wrap strings and tables in id fns. Stash them (as well as literal fns and make-br-fns) under a uniq name. Finally, add the uniq name to the end of the head symbol and repeat if necessary. This would be done before expand-ssyntax. I'm not sure it's worth the effort.

I think the final result would be very cool, mostly to allow things like (prn:[_ 3] "hello").

-----

2 points by drcode 6131 days ago | link

Yeah, the colon operator has many limitations, I've noticed... I haven't been able to get it to work for any case that doesn't involve simple symbol names for functions...

-----