If it will only replace why not keep goinstall as the tool name?
--
André Moraes
http://andredevchannel.blogspot.com/
The exp package will still live in the tip and will be removed only on
the "Go N" versions?
> See http://blog.golang.org/2011/10/preview-of-go-version-1.html.
> Please post comments in this thread. Thanks.
Is the plan to incrementally change the current tree to meet these goals? How many releases (weekly/monthly or otherwise) do you envision between now and Go 1? The most invasive changes from my perspective[1] are the package rearrangements and the move to error.Value from os.Error. I think it would be beneficial to make these structural changes as soon as possible. The other changes are more subtle.
Brian
LGTM
particular +1s to: composite literals, map deletion, no function equality,
composite map keys, package renaming.
not sure about: error.Value as a name, go/types noncompletion,
i'll miss gotry, although i doubt anyone else will.
equality
The current language does not define equality on struct and array values. It does define equality on function and map values. Function equality is problematic in some contexts and map equality compares pointers, not the maps’ content. Only types with defined equality can be used as map keys.
Go 1 will define equality on struct and array values composed from fields on which equality is also defined (element-wise comparison).
It will remove equality on function and map values except for comparison with nil.
> See http://blog.golang.org/2011/10/preview-of-go-version-1.html.
> Please post comments in this thread. Thanks.
Regarding composite literals, can they used for unnamed parameters, as
in:
type Entry struct {
Name string
Value float64
}
var f func(*Entry)
...
f({Name: "pi", 3.14})
?
I still think it would make sense to aim for more consistent error
handling (callers always have to check the error return).
I just think the number of builtins should be minimized, but I may be
missing something. (By the way, the same syntax could be applied to
closing channels too: c <- _, then the restriction to close
receive-only channels would be evident.)
Also, I don't really like error.Value, but I don't have a better
proposal and I agree os.Error was not right.
Anyway, I'd like to say that in general terms I like very much the
suggested changes and the idea of a stable release. In particular, I
find the go command very nice and the solution to shadowing return
values quite original.
--
- yiyus || JGL .
My main disappointment is that Go 1 won't include a succinct literal form for user-defined function types as the current need to type cast anonymous functions is ugly, ugly, ugly, ugly, ugly.
Ellie
Eleanor McHugh
Games With Brains
http://feyeleanor.tel
----
if _, ok := reality.(Reasonable); !ok { panic(reality) }
For me, this is by far the most exciting part of the proposal. I'd
love to hear as much detail as possible about this new tool.
Specifically, I'm interested in how the authors propose to address
dependencies of packages on both runtimes and other packages. Also, it
would be great to see a clear definition of where "go"-installed
packages can possibly reside (if that would differ from the current
implementation).
Fantastic news there. Exciting times.
As a detail, for the append improvement it'd be nicer to see a fix for
issue 2204 instead, since it's a generic desire to be able to handle
an underlying string byte-by-byte without incurring in gratuitous
allocation. The issue describes a few different cases in addition to
the append support that come from the same problem.
--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/plus
http://niemeyer.net/twitter
http://niemeyer.net/blog
-- I never filed a patent.
I can't see that for a Go 1 "early next year" that there's enough time
to devise, implement, and soak-test generics for Go.
Much as I would like to have them myself ...
Chris
--
Chris "allusive" Dollin
Been stuck under a rock for a while? anyway, the append() built-in
offers all the functionality of container/vector for any type of slice.
http://golang.org/doc/go_spec.html#Appending_and_copying_slices
http://code.google.com/p/go-wiki/wiki/SliceTricks
Errors are just values. The compiler doesn't know that what you are
ignoring is an error.
I doubt it. That would make most strings a lot fatter than they need be.
You can cast to and from []int already if you need to -- that will just become
[]rune.
> We could finally use :
> s:= "世界"
> len(s) // 2
> s[1] // 世
(s[0], not s[1])
> range
range works on strings already.
--
Chris "allusive" Dollin
The new "Go" tool will have more features than goinstall + make
Or will only replace those?If it will only replace why not keep goinstall as the tool name?
Is the plan to incrementally change the current tree to meet these goals? How many releases (weekly/monthly or otherwise) do you envision between now and Go 1? The most invasive changes from my perspective[1] are the package rearrangements and the move to error.Value from os.Error. I think it would be beneficial to make these structural changes as soon as possible. The other changes are more subtle.
Strings aren't implemented as []byte.
Even if they were, implementing something as []byte doesn't demand that
all accesses be to bytes.
The inconsistency is that s[x] gets you raw bytes but range gets you codepoints.
It's a compromise that keeps strings slim and [] access fast. Most of
the time there's
no problem, and there are no problem-free constructs ...
When does one type-cast anonynous functions?
Or do you mean that an anonymous function comes with a heavy-weight
func ... syntax? It's not clear to me that you could leave it out and preserve
Go's type-safety.
Another thing I forgot to put in the last post:The exp package will still live in the tip and will be removed only on
the "Go N" versions?
It will remove equality on function and map values except for comparison with nil.
However this particular change seems a bit drastic... Isn't it possible to keep the possibility to compare function and map values for equality while disallowing their usage as a part of map keys ? Could you elaborate on the potential problems with function equality ?
I'd like to know what is the reason to add the "delete" builtin
instead of the syntax which has been proposed before: m[k] = _I just think the number of builtins should be minimized, but I may be
missing something. (By the way, the same syntax could be applied to
closing channels too: c <- _, then the restriction to close
receive-only channels would be evident.)
After reading that text the name change really makes sense.
As a suggestion a "pack" command could be placed there.
It will use the same logic for list, but instead of just listing it
will copy to some dir and pack as a zip/tar.gz/etc...
Of course that the user can just use the list command with some other
tool to achive the same result.
--
André Moraes
http://andredevchannel.blogspot.com/
There's a lot of nice stuff in there.
However, I just can't bring myself to like error.Value. It seems such
an ... icky name for something that I find myself using all the time
when writing library code.
Can't we promote it further to a builtin type "error"?
error.New could be a cast instead - i.e. error("foo")
If that isn't acceptable, how about a "lang" package for such things?
Then we could have lang.Error and lang.NewError. This could also be a
home for things like lang.Version ...
--
Julian
I was thinking in _ as some sort of /dev/null, so the two meaning were
not so unrelated, at least in my head.
> A new function name is clear and does not interfere with other parts of the
> language.
Fair enough. I just wanted to know the reason the other option was
discarded. Thanks for your answer.
And by the way, thanks for asking. You did not only make your
(mid-term?) plans public, you asked for opinion. That's very kind of
you.
It might make sense to error out if *any* return value is ignored, not
just os.Error. Explicitly ignoring errors when there are other result
values does not appear common. Most reports to the mailing list
seemed to involve functions which return nothing but an error.
But this is only part of the problem. Currently, for io.Reader and
similar interfaces, you have to check the non-error value before the
error-value, and for most other functions, you have to check the error
value before anything else. This leads to bugs.
I would presume because the value of slices can change, and it
normally doesn't make sense to copy them, which makes them not so
useful as map keys. On the other hand, if you *did* copy slices, then
I don't see any particular problem with having them as map keys under
the same constraints.
David
One is regarding the lack of specification for rejection due to
shadowing of result variables:
> Go 1’s compilers will reject a return statement without arguments when any of the result variables has been shadowed. This rule will not be defined in the language spec, by analogy with the rules about when a function is missing a return statement. Not specifying the behavior, while enforcing with the compilers, makes it easier to adjust the rules as we continue to explore this area of the Go language.
I can understand the appeal of this (allowing for future refinements
to the "fatal warnings" algorithms), but it seems like it seriously
undermines the utility of having a specification: if it's not
possible to determine whether a given program is valid from the
specification seems like a real problem, particularly in a stable
release. Once go 1 is released, I presume that these checks will be
frozen in stone... or at least the compiler will only become more
liberal. Otherwise valid go 1 programs will fail to compile under go
1.1 or later. If this is the case, it'd be nice to have careful
wording in the spec that indicates which programs will *not* fail.
I guess a commitment that programs that compile under go 1 are
guaranteed to compile in go 1.x. On the other hand, that still makes
the compiler itself a de facto language specification, which seems
inelegant and potentially dangerous (e.g. what happens if gccgo and gc
are found to differ on a given case). Probably this won't happen, but
bugs in compilers have been known to be found in the past...
David
I might be jumping the gun, but where will development effort be
focused after the release? Will it be aimed towards improving the
release or will development on "Go 2" begin immediately? Somewhere in
between?
- Evan
My concern is that a lot of types will now be comparable by "==", and
some of those shouldn't be -- any type for which elementwise equality
is wrong. E.g., types with pointers, or where only part of a field is
used.
Go 1 will allow abbreviating a composite literal of the form &T{...} initializing a value of type *T, by omitting the &T.
Or do you mean that an anonymous function comes with a heavy-weightfunc ... syntax? It's not clear to me that you could leave it out and preserve
Go's type-safety.
I have to echo this. Even though it's not implemented as a function,
it appears to be a function call and its very 'magical'. It says
'delete the entry x from map m' but it does it in a way that looks
like we're deallocating the value contained at m[x]. It looks a but
too much like a free() to me.
delete(m, x) is a great suggestion for making this syntax clear and
easy to read and write. It says to delete the value associated with
the key x in the map m.
- Jim
> A later version of Go will change rune to be an alias for int32, which will make it> reasonable to change int to be 64 bits.Why have you postponed this change?
I like the plan to create a "rune" type alias, but I'm concerned about waiting until "a later version" to make int 64-bit. Slices larger than 2**31 elements are increasingly reasonable, and over the lifetime of Go 1 will become more so. Is there a reason that using too much space for runes until they can become int32s is a major concern?
On Oct 6, 3:08 pm, Russ Cox <r....@golang.org> wrote:
> Seehttp://blog.golang.org/2011/10/preview-of-go-version-1.html.
> Please post comments in this thread. Thanks.
The Go 1 preview document says:
"Go 1 will continue to exclude equality for slices. (In the general
case it is infeasible.)"
I don't understand the reasoning behind this. Is the reason
performance, or complexity of implementation, or something else?
Regarding composite literals, can they used for unnamed parameters, as
in:type Entry struct {
Name string
Value float64
}var f func(*Entry)
...
f({Name: "pi", 3.14})?
I still think it would make sense to aim for more consistent error
handling (callers always have to check the error return).
+1 for lang.Error, lang.NewError, etc.
I'm saddened that "uses of operating system errors (for example, the
uses of os.EINVAL and os.ERANGE by package strconv) will be
discouraged." Error numbers are very attractive to me because they're
machine-actionable and can be propagated outside the Go runtime.
Within Go, type switches on values that implement os.Error are great
but syntactically tedious.
Use of plain-string errors like os.stringError should be what's discouraged.
The plan for Go version 1 look great.
On Fri, Oct 7, 2011 at 12:08 AM, Russ Cox <r...@golang.org> wrote:
> See http://blog.golang.org/2011/10/preview-of-go-version-1.html.
> Please post comments in this thread. Thanks.
I have two comments on the proposal, both of with have been raised
already in this thread:
1. map delete syntax - I agree that adding a new builtin to replace
the old map delete syntax is a good improvement, but I think Jonathan
and Jim have a good point that delete(m[k]) is a little strange. What
is the type of the single argument passed to delete, m, or k? I think
delete(map, key) fits pattern established by append and copy. There is
also the issue of someone new to the language attempting to use
delete() as some form of free(). A two argument delete builtin would
make such incorrect usage a syntax error.
2. error.Value - I agree completely that os.Error needs addressing but
am not sure that error.Value is a good replacement for the following
reasons.
* error.Value is 3 characters longer than os.Error, which is a small
footprint increase on disk, but does run contrary to Go's emphasis on
concise syntax and variable names. A possible replacement could be
error.E, which follows the pattern set by the testing package. However
this does not fully address my next point.
* import "error" removes error as a possible variable name. We saw
that identified during the development of exp/sql, which decided
against using the use of "db" as the package name for this reason.
* error.Value implies might imply that there are other types inside
the error package. While this probably isn't the case, it sets a
precident for a package that contains only a single interface type and
a few helper functions.
* While importing os, just to get the os.Error type may be overkill,
having to import the error package simply to return an error, which
most likely came from the function your package is calling, is just as
clunky.
I have two suggestions, which may or may not be feasable
* go.Error, in the package go. At least it's the same count as
os.Error, and does not consume error as a variable name. I am not sure
if this would conflict with the go statement.
* Some new type for errors, which itself is a built in alias for fmt.Stringer.
Cheers
Dave
Thank you to everyone who has made Go possible to this point. I look
forward to enjoying Go 1. :-)
Two ideas stated by Frederick P. Brooks, Jr., have resonated with me
ever since I read them [1]. I've found that they apply to far more than
software projects:
1. The Programming Systems Product (pp. 4-6).
2. Conceptual Integrity (pp. 42-43).
In context of the subject, the following quotation also comes to mind (I
am unable to find a source attribution):
"A programming language is only as good as its library."
I encourage the implementers of Go 1 to aim for nothing less than
exemplary achievement in all regards, including the above. Given the
personnel, technical, and financial resources of Google, this should be
possible.
A final idea -- release Go 1 when it is ready; no sooner.
David
References:
[1] Frederick P. Brooks, Jr.,, 1995, "Mythical Man-Month The: Essays on
Software Engineering, Anniversary Edition", Addison Wesley Longman,
Inc., ISBN 0-201-83595-9.
- Issue 1875: rename ReadFrom/WriteTo to WriteFrom/ReadTo?
Perhaps Go 1 is a good and final chance to do this.
- Please add os/inotify to the package rearrangement packing list
Overall I think Go 1 sounds good. All the language changes seem like
improvements and so does the package reorganization.
However:
- I prefer the delete(map, key) that several people have suggested
(although I still like the "cute" m[k] = _ best of all)
- Replacing os.Error with error.Value seems a bit ugly (although
sensible in terms of packages)
Suggestion #1: Although illogical, move Error into the go package so
that we replace os.Error with go.Error (oh, Dave Cheney already
suggested this:-)
Suggestion #2: call the error package err (precedents: strconv,
syscall, fmt), so we get err.Value
Suggestion #3: as #2 but use Info for the interface, so we get
err.Info
--
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
C++, Python, Qt, PyQt - training and consultancy
"Programming in Python 3" - ISBN 0321680561
http://www.qtrac.eu/py3book.html
Do you realise that this would break every piece of Go code out there?
naming the package "err" would mean that "err" wouldn't be usable as a
variable name in any package that needed to import err and "err" is used
as a variable pretty much everywhere.
error.Value seems a bit weird to me.
- jessta
On the other hand, now is the time for breaking changes, before things
reach version 1.0. If breaking changes cannot happen whilst a system is
experimental, how do you introduce improvements?
> error.Value seems a bit weird to me.
?
--
Russel.
=============================================================================
Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel...@ekiga.net
41 Buckmaster Road m: +44 7770 465 077 xmpp: rus...@russel.org.uk
London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Nice. Two immediate comments,
> To run gofix with specific options, run gofix itself.
> To run gofmt with specific options, run gofmt itself.
> (etc.)
"go" as simply a wrapper for "goxxx" commands, rather than a proper
replacement, seems half-hearted and incorrect. Seems better to fold
every "goxxx" into "go" completely, and do away with the separate
binaries.
> usage: go get [importpath...]
> . . .
> . . . it uses the default version for
> the version control system: HEAD for git, tip for Mercurial,
> and so on.
"tip" is not the default version for Mercurial. It's simply the most
recently committed changeset, regardless of what branch it happens to
be on. Probably what you want here is "default".
Or: var x []interface{}; x = append(x, x).
I meant: x := make([]interface{}, 1); x[0] = x. But the point is that
it's not just recursive types.
- I prefer the delete(map, key) that several people have suggested
(although I still like the "cute" m[k] = _ best of all)
"go" as simply a wrapper for "goxxx" commands, rather than a proper
replacement, seems half-hearted and incorrect. Seems better to fold
every "goxxx" into "go" completely, and do away with the separate
binaries.
i wonder if the error interface could be treated as special because the
runtime knows about it - it's the only interface that has special
mention in the specification:
http://golang.org/doc/go_spec.html#Run_time_panics
perhaps this might be sufficient rationalisation for giving it
its own place in pkg/builtin.
type error {
String()
}
specific error constructors would live in particular packages, as
currently.
oops, i meant:
type error interface{
String()
}
of course.
> Suggestion #1: Although illogical, move Error into the go package so
> that we replace os.Error with go.Error (oh, Dave Cheney already
> suggested this:-)
This suggestion can't work, because "go" is a keyword in the language.
"package go" is a syntax error.
Ian
Ah, I'd been looking at http://golang.org/pkg/go/ but actually that only
has packages inside the directory; I hadn't noticed before that it isn't
a package itself.
--
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
C++, Python, Qt, PyQt - training and consultancy
"Advanced Qt Programming" - ISBN 0321635906
http://www.qtrac.eu/aqpbook.html
> usage: go get [importpath...]
> . . .
> . . . it uses the default version for
> the version control system: HEAD for git, tip for Mercurial,
> and so on."tip" is not the default version for Mercurial. It's simply the most
recently committed changeset, regardless of what branch it happens to
be on. Probably what you want here is "default".
It's on the to-do list.
Russ
That's actually runtime.Error, not os.Error.
> perhaps this might be sufficient rationalisation for giving it
> its own place in pkg/builtin.
(...)
> specific error constructors would live in particular packages, as
> currently.
That sounds like a very good idea, though. I was also unhappy with
error.Value, but had no better idea.
os.Error is certainly a widely used type in Go code across the board,
so having it as a standard type always available and with shorter name
would be very handy.
Warm +1.
--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/plus
http://niemeyer.net/twitter
http://niemeyer.net/blog
-- I never filed a patent.
No, HEAD is right. For a remote, HEAD tells you which is the default
branch, i.e. the branch you will be tracking if you just run git clone.
This is often master (being the default), but it doesn't have to be.
For example, if you clone git://github.com/libgit2/libgit2 you will get
a branch called development, not master.
Locally HEAD refers to what is currently checked out.
In neither case does it behave like tip.
--
Julian
-1 The fact that some Git subcommands are part of the Git binary and
some are dispatched to git-whatever is confusing, especially when
looking at man pages. I would much prefer Go retain separate tools,
separately documented. Is there any technical advantage to gofmt
being in the same binary as goinstall, anyway?
I too do not feel comfortable with error.Value, but I haven't seen a
better suggestion in this thread. Making Error a built-in interface
comes close, because while not special it is certainly ubiquitous and
fundamental. I don't see the worth of jamming any extra interfaces
into builtins, however. Maybe have the Error interface built in and
keep the error package with just:
type Value string
func New(s string) Error { return Value(s) }
func (v Value) String() string { return string(v) }
inside so we still have a place for easily making plain jane string ->
Error values without tying it to a particular package, such as os.
That would give us Error for the type, error for the package, and err
for the variable name.
And +1 for delete(m, k) over delete(m[k]).
Separate tools, separately documented is what we have now. It works
OK. I imagine the Go authors have a good reason to combine them into
one; I would prefer it slightly, as an end user, in the same way I
prefer "hg foo bar" over "git-foo bar".
My point is only that having a simple "wrapper" binary, providing
explicitly limited functionality to other binaries, is the best of no
worlds. It violates the One And Only One edict: the minute you need to
do something slightly complex with eg. gofmt, you're changing not only
the flags but the command. That's confusing and bad. Enabling *some*
common workflows through a special lens on a pool of tools is a false
economy. Better if users know, and use, the authoritative and
unambiguous source.
> It looks like the difference between go fix/fmt and gofix/gofmt is
> that the former fixedly runs on the tree that go acts on.
I understood them as identical, except "go fix" provides only a subset
of the functionality of "gofix." If they do fundamentally different
things, even more reason to eliminate the duplicity. Separate tools,
nearly identically named, with fundamentally different semantics?
Eish, I hope not.