jckarter / clay

The Clay programming language
http://claylabs.com/clay
Other
404 stars 34 forks source link

Sequence construction API refactoring using tuples #483

Closed stepancheg closed 11 years ago

stepancheg commented 11 years ago

What is it

This is alternative refactoring of sequence construction API. Another version is here: #480. This version uses tuples instead of elements function.

Description

Before this commit Vector functions were over-overloaded: call to

Vector[T](a)

could interpret a as a sequence or as an element parameter. This is over-overloading that make code harder to read and maintain.

This commit changes sequence construction API. New convention is proposed:

Let Foo be sequence type.

Calls

Foo(arg)
Foo[T](arg)

assume arg is a sequence. Call

foo(..args)

interpret args as elements for new foo sequence. Latter call does not work when args list is empty (because type parameter for Foo cannot be infered and thus must be specified).

To deal with this issue, fourth constructor is added: with elements passed in tuple:

Foo[T]([..args])

This patch changes vector, queue and deque.

jckarter commented 11 years ago

Sounds good.