Skip to content

change signature of concatenate() to take an Iterable #738

@jvasileff

Description

@jvasileff

Currently, there is an asymmetry in the signatures of expand and concatenate:

shared Element[] concatenate<Element>({Element*}* iterables)

shared Iterable<Element,OuterAbsent|InnerAbsent> expand<Element, OuterAbsent, InnerAbsent>
    (Iterable<Iterable<Element,InnerAbsent>,OuterAbsent> iterables)
    given OuterAbsent satisfies Null
    given InnerAbsent satisfies Null {}

with, IMO, the non-variadic iterables in expand being better, providing the following benefits:

  1. In some cases, the production of a nonempty result
  2. More convenient syntax for named argument invocations

I believe the second point is an important one, since when programming with apis such as ceylon.ast and ceylon.html, it is far more convenient to always use named argument lists, to avoid confusion between ) and } in the middle of large expressions.

In the examples below, the first is superior:

    printAll {
        expand {
            {"a", "b"},
            {"c", "d"}
        };
    };

    printAll {
        concatenate(
            {"a", "b"},
            {"c", "d"}
        );
    };

    printAll {
        concatenate {
            [
                {"a", "b"},
                {"c", "d"}
            ];
        };
    };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions