Arc Forumnew | comments | leaders | submitlogin
1 point by SteveMorin 5076 days ago | link | parent

Does Arc have keyword arguments in PG's release? I have seen a reference to it in the tutorial


2 points by evanrmurphy 5076 days ago | link

Official arc has optional arguments, designated by `o` in parameter lists:

  arc> (def hello ((o name "stranger"))
         (string "Greetings, " name "!"))
  #<procedure:zz>
  arc> (hello)
  "Greetings, stranger!"
  arc> (hello "Steve")
  "Greetings, Steve!"
The difference between this and keyword parameters is that, with the latter, the caller of a function can bind its arguments to the function parameters in any order by specifying each argument's keyword. In akkartik's system, this looks something like:

  wart> (def hello (? greeting "Greetings" name "stranger")
          (string greeting ", " name "!"))
  #<procedure:zz>
  wart> (hello)
  "Greetings, stranger!"
  wart> (hello :greeting "Hello" :name "Steve")
  "Hello, Steve!"
  wart> (hello :name "Steve" :greeting "Goodbye")
  "Goodbye, Steve!"
But this doesn't work in official arc.

-----