Author: Wander Nauta (wandernauta)
Created: 2010-05-10
Type: Feature
Status: Draft
Licence: This ORC is released under the Creative Commons Attribution-Share Alike 3.0 License
- Motivation
- Specification
- Rationale
Functions and methods in ooc are defined with their arguments in a well-defined order. Sometimes, however, the programmer might want to deviate from that order to add clarity to his/her code. Keyword arguments, as they are implemented in other languages such as Python, provide a mechanism to do exactly that.
ooc should understand function arguments preceded by a keyword and an equals sign (=) to signify keyword arguments. The compiler should then sort the keyword arguments into the order specified when defining the function.
In other words, defining foo: func(spam: Int, eggs: String) {}
then calling foo(eggs="Bar", spam=3)
should give identical results to calling foo(3, "Bar")
Using the equals sign to signify keyword arguments is compatible with keyword arguments in other languages.
Keyword arguments add flexibility to the order of arguments a function takes. Keyword arguments, when used correctly, can greatly improve code readability.