Skip to content

Instantly share code, notes, and snippets.

@wandernauta
Created May 10, 2010 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wandernauta/395852 to your computer and use it in GitHub Desktop.
Save wandernauta/395852 to your computer and use it in GitHub Desktop.

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

Keyword arguments

Index

  • Motivation
  • Specification
  • Rationale

Motivation

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.

Specification

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.

Rationale

Keyword arguments add flexibility to the order of arguments a function takes. Keyword arguments, when used correctly, can greatly improve code readability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment