Arc Forumnew | comments | leaders | submitlogin
syntax detail: (o bar 12) ==> (bar? 12)
2 points by ms 5940 days ago | 4 comments
Pg's theory behind o probably is that it doubles as an abbreviation for "optional" and as an easily recognizable small-circle sign.

In practice however, I find myself always reading the o as "oh".

  (def foo ((o bar 12)) bar)
I read this as "def foo oh bar ...", and then I have to translate the "oh" into a sign for optional in a second step.

The following syntax makes it immediately obvious that bar is an optional variable:

  (def foo ((bar? 12)) bar)
(Note that the question mark is not a part of the variable's name, only a sigil that indicates that it's optional.)


4 points by dfranke 5940 days ago | link

This would drive me nuts if I were frequently moving between Scheme and Arc (as PG and RTM obviously are). I'd keep reading it as a predicate.

-----

1 point by Grue3 5940 days ago | link

Why wouldn't just (bar 12) do? It's not like there are other kinds of parameters (like keywords).

-----

2 points by randallsquared 5940 days ago | link

Destructuring is also built in. It's not clear to me if there's a destructuring use case for (bar 12) in Arc, but I could easily see using it the way Erlang uses its pattern matching, so that (def myfn (foo (bar 12 _)) (do things)) would mean that myfn was only called if the cadr of the second argument was 12. Since '_' in this case means "don't care", I'm not sure there'd be any conflict with '_' as already used in Arc.

-----

2 points by simonb 5940 days ago | link

Yet. I for one sincerely hope the lack of keyword parameters is only temporary.

-----