When making instances of my composite Julia types, such as

foo = Foo(1, "bartxt", 3.14)

I often have to look up the definition, because I don't remember whether, 
in this case, "bar" was the first or the second field:

type Foo
      bar::AbstractString
      baz::Int
      qux::Float64
end

"bar" was the first field, so the correct construction is

foo = Foo("bartxt", 1, 3.14)

In this case the first, incorrect code would not compile because of no 
matching method.

But for

type Goo
      vertical::Float64
      horizontal::Float64
      qux::Float64
end

it is easy to write incorrect code when the order of the fields gets mixed 
up, and such bugs are potentially difficult to find.

Wouldn't it be possible to allow (optionally) for a syntax like

foo = Foo(;bar=bartxt, baz=1, qux=3.14);
goo = Goo(;horizontal=186.,vertical=0.33, qux=3.14)

where the keyword arguments are the fieldnames of the type?

Often I remember the fields of a type, but not their order.
With this syntax the argument order would be arbitrary.
The syntax would imply, that incorrect, non-existing, or missing 
fields/keywords result in an error.

Thanks for your consideration.

Reply via email to