Skip to content

Merging sequences (like Merge keys for mappings) #48

@perlpunk

Description

@perlpunk

In #35 a syntax to merge sequences was proposed, but the syntax isn't going to happen, while I can understand that it would be useful to have a standard way of doing this.

There are plans to add programmatic features in YAML 1.3, as @ingydotnet mentioned, but they simply don't exist yet.

The question is, can we come up with something simple, that doesn't introduce new syntax?

Here are some suggestions:

  1. @ingydotnet 's suggestion was:
array1: &my_array_alias
- foo
- bar

array2:
- <: *my_array_alias
- baz
  1. My alternative suggestion would be:
array1: &my_array_alias
- foo
- bar

array2:
- <<
- *my_array_alias
- baz

This approach would be very close to the merge key feature; also when thinking about the implementation (because I have just implemented this in my YAML processor).

  1. Another variant would be almost equal to @ingydotnet's suggestion:
array1: &my_array_alias
- foo
- bar

array2:
- <<: *my_array_alias
- baz

I can't think of a reason not to use the same << as for merge keys.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions