Skarmander:
No, let's go one step further. In Malingua, they have objects which
outwardly resemble cars. However, if you get into one, you find out that
they're actually showers. You can't drive them; they just happen to have
car-shaped enclosures.
OK, I'm with you so far...
If you're surprised by this, don't be: it's your own fault for assuming
that things that look like cars in Malingua are cars. If you don't like
it, then tough -- but don't use ignorance as an excuse to imply fault in
Malingua's culture.
Indeed, as a Westerner, I might find it quite strange that Malingua's
showers look like cars.
What can I do about it? Well, before travelling to Malingua, I can say,
"OK, I going to disregard everything I learned in Ireland, and I'm going to
start afresh in Malingua without making any presumptions as to how things
work."
Is this a viable choice? No, not when talking about going to a different
country.
However, we're talking about a programming language. When you're learning a
new programming language, you can't really build on past experience. You
need to confirm and clarify everything.
The simple fact of the matter is that you have to be in the know when it
comes to a programming language. Some people may presume that you can pass
an array by value, but alas they're wrong. Was their intuition flawed to
think they could simply write:
void Func(int arr[5]) {}
Maybe, maybe not. At the end of the day though, the C Standard is the C
Standard. You can either come to terms with the fact (however much you
dislike it) that Malingua's showers look like cars, or you can rant on
about how backwards Malingua is.
This reminds me of the argument posed recently whereby the following was
deemed to be bad style:
SomeAggregateType obj = {0};
in place of:
SomeAggregateType obj;
memset(&obj,0,sizeof obj);
(Let's forget for the moment that the latter form is only guaranteed to
work with integer types.)
The argument posed was that the former form wasn't explicit enough, i.e.
that the programmer wasn't expected to know that all the members/elements
would be default-initialised.
This, in my own humble opinion, is BS. The semantics of the former form are
perfectly well defined by the Standard, and that's good enough for me. One
shouldn't censor one's code because they think a particular feature might
be a little too advanced for some people.
The only compromise I would accept is the following:
SomeAggregateType obj = {0}; /* Everything ges default value */
I find it quite odd that a programmer would choose a flawed construct over
a simple comment. We have comments, use them if you like.
Your point (that the semantics of a language are dictated, and match our
expectations only when they happen to do so) is well taken. It is,
however, disingenuous to pretend that therefore, a language can be
designed in whatever way we please and no-one can fault it for having
syntax or semantics that mislead a programmer's casual instincts.
Yes, we can agree (slightly) on this one. Maybe C should have disallowed
the following:
void Func(int arr[5]) {}
Whether you agree with the criticism is one thing, but simply dismissing
it as invalid is silly.
It is the implication of a flaw in C that I was dismissing.
If programming were just a programmer reading the language standard and
henceforth magicking programs out of the void with the assimilated
knowledge, there would be no need to evaluate language design decisions.
However, it's not.
Oh but a boy can dream...