Re: Keyword Arguments

Jeremy Tregunna <[email protected]> Sat, 09 Jun 2012 13:31:55 -0600
Newsgroups gmane.comp.lang.io
Message-ID <[email protected]>
This discussion goes back many years, and Steve's always said something along these lines:

Tell me how this parses:

a: b c d: e: f

Smalltalk had 3 precedence rules for message sends that you had to remember. I stipulate that there's a higher cognitive load on remembering those, and you don't really reduce any cognitive load with a smalltalk style keyword args because you still have to remember the position of the arguments. Even if you didn't, you'd still have to remember their names, which again doesn't reduce any cognitive load.

While learning the precedence rules doesn't take long, and I generally like the smalltalk syntax more than I do s-expressions or m-expressions, I don't think their benefits outweigh their cost. Reducing cognitive load should be the goal of any language designer.

That said, you'd have to invent new syntax to support this kind of system. You'd also end up building your own runtime on top of Io to support the way your messages work, and this would involve a lot of proxies which can mess with the way the system is going to work.

A case in point of Io mapping to keyword arguments is in the Objective-C bridge, at least now : is an identifier so your idea is possible. But yes, you'd definitely have to invent all the stuff you want.  

Regards,

Jeremy Tregunna


On Saturday, 9 June, 2012 at 1:22 PM, Kurtis Rainbolt-Greene wrote:

>    
> 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
>