Pre-RFC: variadic tuple

Hi updated the RFC with the last feedbacks:

  • support for functions without recursion
  • trait library utilities and their usage

Considering the ambiguous range syntax, I have several suggestions:

Option 1 - Original

(for (ref k, map) type (K, V) in ..(k, maps) type ..(K, V) {
    HashMap::<K, V>::get(&map, k)
})

(for (ref key,) type (Key,) in ..(k,) type ..(K,) {
    Key::do_something(key)
})

This one is ambiguous with ranges

Option 2 - loose the ..

(for (ref k, map) type (K, V) in (k, maps) type (K, V) {
    HashMap::<K, V>::get(&map, k)
})

(for ref key type Key in k type K {
    Key::do_something(key)
})

In my opinion, this is dangerously close to standard for loop. Although the compiler can makes the different because variadic tuple identifier are used, but for a human, this is ambiguous.

Option 3 - Enclosed in brackets

(for (ref k, map) type (K, V) in <k, maps> type <K, V> {
    HashMap::<K, V>::get(&map, k)
})

(for ref key type Key in <k> type <K> {
    Key::do_something(key)
})

Option 4 - No delimiters

(for (ref k, map) type (K, V) in k, maps type K, V {
    HashMap::<K, V>::get(&map, k)
})

(for ref key type Key in k type K {
    Key::do_something(key)
})

Option 5 - Enclosed by dot

(for (ref k, map) type (K, V) in .(k, maps). type .(K, V). {
    HashMap::<K, V>::get(&map, k)
})

(for ref key type Key in .k. type .K. {
    Key::do_something(key)
})

Option 6 - Enclosed by flipping table

(for (ref k, map) type (K, V) in (╯°Д°)╯(k, maps)/(.□ . \) type (╯°Д°)╯(K, V)/(.□ . \) {
    HashMap::<K, V>::get(&map, k)
})

(for ref key type Key in (╯°Д°)╯k/(.□ . \) type (╯°Д°)╯K/(.□ . \) {
    Key::do_something(key)
})

Option 7 - Prefixed by @

(for (ref k, map) type (K, V) in @(k, maps) type @(K, V) {
    HashMap::<K, V>::get(&map, k)
})

(for ref key type Key in @k type @K {
    Key::do_something(key)
})

Option 8 - Prefixed by a dot

(for (ref k, map) type (K, V) in .(k, maps) type .(K, V) {
    HashMap::<K, V>::get(&map, k)
})

(for ref key type Key in @k type @K {
    Key::do_something(key)
})

Option 9 - Prefixed by &~

(for (ref k, map) type (K, V) in &~(k, maps) type &~(K, V) {
    HashMap::<K, V>::get(&map, k)
})

(for ref key type Key in &~k type &~K {
    Key::do_something(key)
})

What do you think of theses?

3 Likes