Dicebot:

While you can do this:

void foo(in @(int a, int b, int c}) {...}
auto result = arr.map!foo;

I believe it is dangerous misfeature and I don't want to see this in D. Sorry :(

Why do you think it's a dangerous and a misfeature? I think you are misaken.

It's present in most functional languages, with slight syntax differences.

The problem is that it's hard to explain how much nice a language feature is if you have not used it extensively in some language :-) So I suggest you to try to write some functional code that uses plenty of tuples. You will see how commonly useful is what I have written :-)

A similar program in Haskell:


foo (a, b) =
    show a ++ " - " ++ show b

lst = [(10, 20), (30, 40)]

main = do
    print $ map foo lst


Output:

["10 - 20","30 - 40"]

And Haskell is regarded as one of the safest languages :-)

Similar code is possible in F#, OCaml, Scala, etc.

Bye,
bearophile

Reply via email to