Named Parameters

Sapphire will support named parameters like so:

class Foo
  def initialize(name, age)
    # ...
  end
end

f = Foo.new(:age => 38, :name => "Daniel")

In short, the argument names a programmer uses in the method definition automatically become keywords. Those keywords can then be used instead of positional parameters. Note that positional parameters would still be valid also:

f = Foo.new("Daniel", 38)

Or, a combination of both positional and keyword arguments:

f = Foo.new(:age => 38, "Daniel")

However, mixing and matching named and positional arguments should generally be frowned on, since it becomes confusing as to what the positions are in methods with larger signatures.

Explicit hashes

The notation that Sapphire uses requires that explicit hashes be used to disambiguate between keyword arguments and literal hashes:
class Foo
  def initialize(name, options)
    # ...
  end
end

f = Foo.new(:name => "Daniel", :options => {:red => true, :blue => false})

Alternative Syntax

I'd also consider something along the lines of Scala's argument syntax: http://www.scala-lang.org/node/2075

The types could be used for some sort of inferencing engine, or simply be annotative.

class Foo
  # Standard parameters
  def method_a(name, age)
    # ...
  end

  # Parameters with defaults
  def method_b(name: "John", age: 30)
    # ...
  end

  # Parameters with types
  def method_c(name: String, age: Fixnum)
    # ...
  end

  # Parameters with types and default arguments
  def method_d(name: String => "John", age: Fixnum => 30)
    # ...
  end

Also available in: HTML TXT