seems good but let's get the test working http://codereview.appspot.com/774041/diff/7001/8003 File compiler/testdata/Makefile (right): http://codereview.appspot.com/774041/diff/7001/8003#newcode47 compiler/testdata/Makefile:47: diff ...
15 years, 4 months ago
(2010-03-27 07:38:24 UTC)
#4
dsymonds@golang.org wrote: > On 2010/03/26 16:56:15, r wrote: > > is this flag standard? never ...
15 years, 4 months ago
(2010-03-27 09:49:41 UTC)
#5
dsymonds@golang.org wrote:
> On 2010/03/26 16:56:15, r wrote:
> > is this flag standard? never seen it. feels to me like a portability
> issue; i'd just drop it from the CL
It's not standardised by SUSv3 (the 2001 version of POSIX) and
is missing from at least some commercial Unixen.
OTOH Go already has build dependencies on bash, Python,
mercurial and some indirect dependencies those tools need such
including GNU make, so adding GNU diffutils wouldn't be the
end of the world, and 'diff -u' matches the 'hg diff' output
we're used to.
Sorry if this drifting too far off topic.
Giles
Tests fixed. It turns out that the reflect.Type returned by reflect.Typeof differs depending on the ...
15 years, 4 months ago
(2010-03-29 03:39:50 UTC)
#6
Tests fixed.
It turns out that the reflect.Type returned by reflect.Typeof differs
depending on the package path, even if it points to the same .6 file.
If I imported extension_base.pb as:
import base "extension_base.pb" // (A)
in the test then reflect.Typeof(base.BaseMessage) is different to if I
had imported it as:
import base "./extension_base.pb". // (B)
That caused the reflect.Typeof check in extensions.go (in
checkExtensionTypes) to fail.
This feels like unexpected and undesirable behavior. I can file an
issue about it if you agree. Regardless, this code review is ready to
proceed.
Dave.
> If I imported extension_base.pb as: > import base "extension_base.pb" // (A) > in the ...
15 years, 4 months ago
(2010-03-29 04:13:40 UTC)
#7
> If I imported extension_base.pb as:
> import base "extension_base.pb" // (A)
> in the test then reflect.Typeof(base.BaseMessage) is different to if I
> had imported it as:
> import base "./extension_base.pb". // (B)
This is correct behavior: different import paths are
different package names, just as import "private/math"
is different from import "math". The solution is not to do that.
Russ
On Mon, Mar 29, 2010 at 3:13 PM, Russ Cox <rsc@golang.org> wrote: >> If I ...
15 years, 4 months ago
(2010-03-29 05:20:30 UTC)
#8
On Mon, Mar 29, 2010 at 3:13 PM, Russ Cox <rsc@golang.org> wrote:
>> If I imported extension_base.pb as:
>> import base "extension_base.pb" // (A)
>> in the test then reflect.Typeof(base.BaseMessage) is different to if I
>> had imported it as:
>> import base "./extension_base.pb". // (B)
>
> This is correct behavior: different import paths are
> different package names, just as import "private/math"
> is different from import "math". The solution is not to do that.
Yeah, I understand why it's happening, but it's still a weird
situation. It's not that I'm comparing import paths or package names;
I'm trying to compare types that are imported differently, but are
still the same type (and ultimately in the same .6 file). It seems
like it would be useful to have type equality well-defined in some way
that is modulo the import path. In the case here the programmer has no
control over one of the import paths (it's in generated code), and I
could easily imagine the same type coming via two different import
paths in a diamond-dependency situation.
Dave.
Furthermore, the docs do not imply that the import path matters (see http://golang.org/pkg/reflect/#Type). In the ...
15 years, 4 months ago
(2010-03-29 05:24:15 UTC)
#9
Furthermore, the docs do not imply that the import path matters (see
http://golang.org/pkg/reflect/#Type). In the description it is only
implying that types are scoped such that they are unique to a program,
not to an imported package. That may just be a shortcoming of that
doc, though.
Dave.
> that is modulo the import path. In the case here the programmer has no ...
15 years, 4 months ago
(2010-03-29 05:28:31 UTC)
#10
> that is modulo the import path. In the case here the programmer has no
> control over one of the import paths (it's in generated code), and I
> could easily imagine the same type coming via two different import
> paths in a diamond-dependency situation.
We made a conscious decision to be sticklers about always
importing a package by its canonical path. If everything uses
the canonical import path, then this diamond won't happen.
It might be worth putting in a compiler warning or error if the
same file is reached by two different import paths, just to catch
things earlier on.
I don't quite understand your next message, about type scoping.
The fundamental issue is this: "extension_base.pb" and "./extension_base.pb"
are two different packages, just like "http/pprof" and "runtime/pprof"
are two different packages and so are "math" and "rpc".
Types from one are necessarily distinct from types from the other.
When you link the program, you get one set of everything from
"extension_base.pb" and a second set from "./extension_base.pb",
just like you get all of "math" and all of "rpc".
Russ
On Mon, Mar 29, 2010 at 4:28 PM, Russ Cox <rsc@golang.org> wrote: > I don't ...
15 years, 4 months ago
(2010-03-29 05:44:23 UTC)
#11
On Mon, Mar 29, 2010 at 4:28 PM, Russ Cox <rsc@golang.org> wrote:
> I don't quite understand your next message, about type scoping.
> The fundamental issue is this: "extension_base.pb" and "./extension_base.pb"
> are two different packages, just like "http/pprof" and "runtime/pprof"
> are two different packages and so are "math" and "rpc".
> Types from one are necessarily distinct from types from the other.
> When you link the program, you get one set of everything from
> "extension_base.pb" and a second set from "./extension_base.pb",
> just like you get all of "math" and all of "rpc".
I guess I was thinking that a type is a type is a type, and since
extension_base.pb.go should only need compiling once (hence the source
of much of Go's speed) then there will be only one underlying type
record for it so that two other pieces of code importing that will
have the same thing (e.g. they can do a reflect.Typeof(base.Blah) and
pass it around). I managed to track this down in this case, but it was
counter-intuitive that the same package imported different ways would
have different types. Does the linker duplicate the type info? Are the
compiled methods on those types all duplicated?
Dave.
You keep saying duplicate. Yes they're duplicated, but that's the wrong mental model. They are ...
15 years, 4 months ago
(2010-03-29 05:56:59 UTC)
#12
You keep saying duplicate. Yes they're duplicated, but that's
the wrong mental model. They are different packages,
in exactly same way that "math" and "rpc" are different.
Just like the linker doesn't replace pieces of "math" with
declarations of the same name from "rpc", it doesn't replace
pieces of "extension_base.pb" with declarations of the same
name from "./extension_base.pb".
Russ
On Mon, Mar 29, 2010 at 2:39 PM, David Symonds <dsymonds@golang.org> wrote: > Regardless, this ...
15 years, 4 months ago
(2010-04-03 01:49:13 UTC)
#13
On Mon, Mar 29, 2010 at 2:39 PM, David Symonds <dsymonds@golang.org> wrote:
> Regardless, this code review is ready to proceed.
This code review got a bit side-tracked. Rob, can you take another
look when you get a chance?
Dave.
Issue 774041: code review 774041: Add extensions to the generator.
(Closed)
Created 15 years, 4 months ago by dsymonds
Modified 15 years, 4 months ago
Reviewers:
Base URL:
Comments: 9