What does the package line in b.go say? Does it say 'package b'?
Russ
I think the assumption is more "it is /unlikely/ that it is a compiler
bug in this well-trod area; it is /more likely/ that it is a
user mistake."
> In other words, all 3 options were actively *protecting*
> the compiler from being modified.
I don't think that's "other words" for the assumption.
> And so it is, the compiler won the fight once again. I am wondering,
> how is the compiler doing this (the winning)? Any ideas?
By being pretty close to an implementation of the spec.
Chris
--
Chris "allusive" Dollin
I'm not sure what you're talking about, but I am sure you're
over-assuming about what people's assumptions are. And
your case, it seems to me, relies on the correctness of your
absoluteness assumption.
> You can count your post as the 4th post which is trying to
> protect the compiler.
Assuming that an error like the one described is more likely
to be a user error than a compiler bug is not "trying to protect
the compiler". The compiler doesn't need "protecting"; it needs
fixing, or not.
> I am wondering: how is the compiler doing this?
The compiler isn't "doing this". If there's a doing involved
it's our doing. The compiler is a bunch of code for checking
and translating a formal language, and is relaible to some
degree in doing this -- reliable enough that when problems
using it are reported, one doesn't automatically assume that
it's a bug in that code. Multiple alternatives are available
and once needs more information to winnow them out; but
a preliminary guess isn't "protection".
>> By being pretty close to an implementation of the spec.
>
> Well, but that would imply that the Go spec existed before the
> compiler had even 1 line of source code in it.
No it wouldn't, not if by "the Go spec" you meant exactly the
document we have today ...
> I don't think that's the case (or even possible).
I don't see why it wouldn't be /possible/. Very many things
are /possible/, just not locally true.
> The spec and the compiler were developed
> in concert with each other. Some parts of the spec are based on the
> compiler (i.e: (1) you try to implement idea X from a spec, (2) it
> does not work, (3) you change the spec to meet what works and is
> actually implementable; or (1) you implement something in the compiler
> and (2) add it to the spec afterwards because it works, or just
> because it already exists in the compiler and you are too lazy to
> delete the source code).
Usually -- not always, but usually -- we use the spec to decide
what the behaviour of the compiler and the code it compiles
should be, and if they're different, the spec "wins", (You might
ask "how is the spec doing this?", but I won't.) The compiler
"protects" itself by "allowing" itself to be modified into agreement
with the spec and "evolving" into a "bug-free" descendent.
Sometimes the compiler is a tool to explore new options for the spec.
But the fact that the code is in the compielr doesn't make it right.
This is interesting (in a positive way): we presented you with 3
possible explanations of what the cause of the problem might be. One
of those 3 possibilities (Russ's option) matched the actual cause.
It is worth noting that all the 3 people who responded to your post
had the same assumption: it is not a compiler bug.
In other words, all
3 options were actively *protecting* the compiler from being modified.
And so it is, the compiler won the fight once again. I am wondering,
how is the compiler doing this (the winning)? Any ideas?
> It is worth noting that all the 3 people who responded to your post
> had the same assumption: it is not a compiler bug. In other words, all
> 3 options were actively *protecting* the compiler from being modified.
> And so it is, the compiler won the fight once again. I am wondering,
> how is the compiler doing this (the winning)? Any ideas?
My experience over many years is that 99% of the cases where a
programmer suspects a compiler bug turn out to be a bug in the program.
Because the Go compiler is newer than most compilers, I think one could
reasonably reduce that to 90%.
Anyhow, the compiler isn't somehow being protected from being modified.
It's the spec that matters. If the spec says one thing, and the
compiler does another, then we fix the compiler.
Ian
Also, the probability here varies dramatically with who the programmer is.
It's still well over 99% for new Go programmers.
Russ
> If it is normal to say about a wasp that it is "doing something", then
> it is probably also correct to say that a compiler is "doing
> something".
The compiler is "doing something", insofar as a purely abstract
pattern of bits can be a doer. What it's doing is compiling. What
it's not doing is protecting itself in any useful sense.
> There are stages in every programmer's intellectual development. Once
> the programmer passes stage X of understanding, he or she will never
> make a certain type of errors while programming in the future.
False. I mean, completely clearly and obviously false. Falser
than a very false thing.
Mere understanding is not a Circle of Protection: Mistake.
> Once again: How is it possible that the compiler+spec won?
There was no fight. Nobody (no thing) "won". I really don't see
what's to be gained by casting the problem-solving that went
on as a "fight" with items being "protected" and something
"winning".
> Well, the only rational explanation
Really? The /only/ rational explanation?
> So,
> logically, if he agreed to respect ("submit to") the spec and the
> compiler implementation, then it cannot be a compiler bug.
Submit? Where did that come from?
It's a compiler bug if the compiler doesn't conform to the behaviour
described in the spec, unless the behaviour described in the spec is
not the behaviour that relevant interested parties think is appropriate,
in which case we don't know whether it's a compiler bug or not, just as is
true for any program.
> But he wrote in his post that "This seems to me a bug ...". This
> implies that he did *not* agree to respect the spec or the compiler.
"... or am I doing something wrong?" This implies he is willing to
respect the spec and/or the compiler (which are two different things).
Because compilers get fixed.
> Is it theoretically possible that the spec contains an error which
> will be revealed to us sometime in the future thanks to the compiler
> implementation of the spec?
Of course. This is neither novel nor a problem.
> In reality, an idea is added to the spec *after*:
>
> - the idea has been implemented in a compiler, or
> - the idea has been "implemented" in somebody's mind, or
> - the idea has been proved useful by history, or
> - the idea has been consciously recognized as an experimental idea
> (nobody knows whether it will work)
Ditto.
> If a spec contains ideas that do not fall into any of the 4 mentioned
> categories, the spec is probably doomed.
We (and our specs) are all doomed, yet life goes on.
My explanation would be that the compiler and spec are not
wrong, and so it is rational to conclude that they are not wrong.
> I just want to know *how* it
> is possible that thousands of people are able to accept that their
> source codes are wrong.
Headology.
> On Jun 13, 6:51 pm, Ian Lance Taylor <i...@google.com> wrote:
>>
>> My experience over many years is that 99% of the cases where a
>> programmer suspects a compiler bug turn out to be a bug in the program.
>
> Yes. But why is that?
When Alice's program does not work as she expects, she has to figure out
what is wrong. She looks at her program: she understands her program,
her program is simple, she has written what she wanted and it looks
right. She looks at the compiler: she does not understand the compiler,
the compiler is complex. Add to that the natural inclination to prefer
to think that she has not made a mistake, and it becomes natural to
conclude that the compiler is in error.
I've seen many people follow this line of reasoning when reporting a
compiler bug. Generally they are not sufficently considering that the
compiler is being used satisfactorily by thousands of people, and that
all the simple bugs have been squeezed out by the pressure of all those
people. Their program has been used by one person, and no such pressure
has been applied.
> Is it theoretically possible that the spec contains an error which
> will be revealed to us sometime in the future thanks to the compiler
> implementation of the spec?
Of course. It's not particularly likely but it's certainly
theoretically possible. Implementation often reveals issues in the
spec, but it usually does so immediately, not in the future. I think
it's worth noting that when that happens--when the compiler reveals an
error in the spec--the action taken is not normally to adjust the spec
to conform to the compiler; it is to try to consider the spec by itself
and figure out what the right solution is.
> In reality, an idea is added to the spec *after*:
>
> - the idea has been implemented in a compiler, or
> - the idea has been "implemented" in somebody's mind, or
> - the idea has been proved useful by history, or
> - the idea has been consciously recognized as an experimental idea
> (nobody knows whether it will work)
>
> If a spec contains ideas that do not fall into any of the 4 mentioned
> categories, the spec is probably doomed.
Sure, but what does that have to do with anything? The point is that in
a language like Go the spec is primary and the compilers are secondary.
Ian
Because programming means writing down the actions that you want an
abstract machine to take. Those actions must be ones that the abstract
machine can perform.
In writing a compiler and/or a language spec, the compiler/language
writer is defining a new abstract machine. (The compiler is itself a
program written in an abstract machine, which may or may not be the same
as the abstract machine that the compiler provides for its users.)
When your program doesn't work, and when somebody points out that you
violated some specific rule of the abstract machine, you conclude that
your program is wrong. To conclude that the abstract machine is wrong
is a level shift. It's worth thinking about that if you are in the
business of defining a new abstract machine, as is the case for language
designers. For most people, who are not defining a new abstract
machine, thinking about how the abstract machine could be changed can be
amusing but is time taken away from actually getting their program to
work.
Ian
So you are asking why is it that the Go developers do not reply
to every invalid program by saying "oh, that's our mistake, that
should have worked, we'll change the language and implementations
so that is valid"?
Because Go is not C++.
Russ