Keyword Arguments
Kurtis Rainbolt-Greene <[email protected]> Sat, 9 Jun 2012 14:22:28 -0500
| Newsgroups | gmane.comp.lang.io |
|---|---|
| Message-ID | <CAMhJPGgRL3+J8raVNd4XnhZbjh_=55+vphCF5Dx8dnkorcsNxA@mail.gmail.com> |
One of the cool things about SmallTalk, and other languages including
Ruby in v2, was the keyword argument syntax sugar (pseudo-code):
define help(title, keywords, options)
# Logic Here
end
Then you could call a function like so:
help("this is the title", ["thing", "thang", "thong"], {"format"
=> "ascii"})
Or with keyword arguments:
help(title: "this is title", keywords: ["thing", "thang",
"thong"], options: {"format" => "ascii"})
help(options: {"format" => "ascii"}, title: "this is title")
The second version is where the real advantage comes in: Being able to
have unordered arguments. It reduces refactor problems that are solely
in the realm of order of arguments.
It also helps people learn the concept of arguments faster ("Oh, these
map to these!").
Brings me to the question: How would you implement this in Io? Not
just code wise, but syntax. Since Io has no Map literals you might
have to invent some new syntax concepts.
--
Kurtis Rainbolt-Greene, Hacker
Difference Engineers, LLC
643 Magazine St. #102
New Orleans, LA 70130