ianlancetaylor

Joined 15 years ago

Karma
182
Submissions
40
Member since
Jun 3
View on Hacker News

Recent submissions

Comment · 10 months ago
Rob Pike retired from Google a few years back.
Comment · 2 years ago
You can use it with other functions that use iterators. For example, here is code that makes a copy of a map keeping only the even keys.

  maps.Collect(xiter.Filter2(func(k, v int) bool { return k%2 == 0 }, maps.All(m)))
Comment · 2 years ago
Yes.
Comment · 2 years ago
Comment · 3 years ago
Comment · 3 years ago
Go made a deliberate decision to use multiple results rather than Option<T> or Result<S, E>. It's of course entirely reasonable to disagree with that decision, but it's not the case that the Go language designers were unaware of programming language theory or unaware of sum types. Although you suggest that you want sum types as the primary tool for error handling, Go made a different decision, not due to accident or lack of knowledge, but intentionally.

(Separately, I'm not entirely sure what you mean when you say that Go doesn't use interface types for its error handling, since the language-defined error type is in fact an interface type.)

Comment · 3 years ago
Comment · 5 years ago
There is no ambiguity there. The ambiguity arises for parameterized types.

type A[T] int

Is that a parameterized type named A with a type parameter T, or is it a definition of an array named A whose length is T?

Separately, it's nice that type parameter lists use the same syntax as non-type parameter lists.

Comment · 5 years ago
Very little. The announcement here is not a new draft, it is starting the formal proposal process for adding type parameters to the language.
Comment · 6 years ago
There isn't a code review for the changes on the dev.go2go branch (though you could construct one using git diff).

The dev.go2go branch will not be merged into the main Go development tree. The branch exists mainly to support the translation tool, which is for experimenting with. Any work that flows into the main Go development will go through the code review process as usual.

Comment · 8 years ago
Remember that they are only pinned to an old language version. They will still work fine with new release of Go, they will just be built with the old language semantics. So what's the harm?

I agree that unmaintained libraries that don't adapt to modules could be a problem. We'll have to see what happens.

Comment · 8 years ago
Go could introduce a moving GC without requiring that map keys not be interface types. The simplest approach would be to use read barriers as we already use write barriers, and forward pointers during the moving phase of the GC. (Efficiency costs might prohibit that, but it could be done.)

Another approach would be to use two different map implementations, and use a less efficient one for older code that used an interface type as a map key.

It's an interesting example, though. You're right: if there is an old language feature that can not be supported by a newer runtime, then there needs to be some sort of shim to let the older code keep working. That necessity may prevent us from making certain sorts of language changes.

Comment · 8 years ago
One step at a time. It's certainly a natural extension, and I don't think anything in the current design draft precludes it.
Comment · 8 years ago
Unfortunately [T] is also ambiguous with the current Go syntax. The parser can't distinguish an array declaration from a generic type.
Comment · 8 years ago
Thanks for the comments. We tried for some time to declare contracts like interfaces, but there are a lot of operations in Go that can not be expressed in interfaces, such as operators, use in the range statement, etc. It didn't seem that we could omit those, so we tried to design interface-like approaches for how to describe them. The complexity steadily increased, so we bailed out to what we have now. We don't know whether this is is OK. We'll need more experience working with it.

I'm not sure that Go is a language in which higher-level abstraction is appropriate. After all, one of the goals of the language is simplicity, even if it means in some cases having to write more code. There are people right here in this discussion arguing that contracts adds too much complexity; higher order polymorphism would face even more push back.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton