On Wednesday, 29 August 2018 at 22:18:09 UTC, Everlast wrote:
No it is not! you have simply accepted it to be fact, which doesn't make it consistent.

If you take 100 non-programmers(say, mathematicians) and ask them what is the natural extension of allowing an arbitrary number of parameters knowing that A is a type and [] means array and ... means an arbitrary number of, they will NOT think A[]... makes sense.

Has anyone actually done such a survey? If not, how can you possibly be sure what the result will be?

If I'm wrong, then you have to prove why a syntax such as bar(int a...) cannot be interpreted singularly in the way I have specified.

Of course, there's no inherent reason why `bar(int a...)` couldn't be interpreted the way you've specified. But there's also no reason why we couldn't use `bar(int... a)`, like Java, or `bar(params int[] a)`, like C#, or any of the other syntaxes you can see if you visit the Rosetta Code page on variadic functions. [1]

All programming languages are artificial. All syntax is arbitrary. What feels "natural" to you is not a universal truth, but a matter of personal taste and preference. To an experienced Scheme programmer, `(foo . args)` probably feels more natural than any of the examples I've mentioned. To an experienced APL programmer, the entire idea of a separate syntax for variadic functions probably sounds ridiculous.

Personally, I find the most pragmatic approach to be "when in Rome, do as the Romans do." So when I'm programming in D, I write `foo(int[] a...)`, and when I'm programming in Python, I write `foo(*args)`, and when I'm programming in C, I write `foo(...)` and `#include <stdarg.h>`. If your goal is to solve actual problems, arguing about syntactic minutiae is a waste of time.

[1] https://rosettacode.org/wiki/Variadic_function


Reply via email to