3 ms·
A few random thoughts: - C++'s std::array is an example of marrying fixed sized arrays with templates. - I'd say keep the built-in types and their behavior un
by YZF 9y ago
A few random thoughts:
- C++'s std::array is an example of marrying fixed sized arrays with templates.
- I'd say keep the built-in types and their behavior unchanged but offer a way of providing those for user types. I guess the Deletable interface is one idea but maybe the "delete" override should have nothing to do with interfaces. I think something like func (t Type) operator delete(k KeyType) ? I guess in Go a function is an interface but I wouldn't start with the interface here.
- Allowing e.g. delete or slicing on user types does not need to imply those types are polymorphic with the built-in types. This might be a little confusing but I think it's still worth while to draw that line. I don't think it's necessary to allow creating a function that takes a Deletable to take either the built-in map type or a user type.
- range support requires some sort of iterators. Could be done through co-routines like Python's generators or something more like C++ iterators? co-routines could be a cool addition to the language :)
I think you'd want to try and "contain" the change as much as possible. More syntactic sugar than fundamental changes and as little change as possible to the built-in types. Otherwise you end up with a completely new language.
- kjksf 9y agoAnd how many decades did it take for C++ to support std::array? What people seem to ignore is that templates are a bottomless pit of complexity. Swift is on version 3 and they still didn't finalize the semantics of generics. Not due to lack of trying. Swift was trying to design and implement generics from day 1 and they still haven't. That's how complicated designing generics is. I prefer stable language with fast compiler to Swift/Rust situation, with language taking years to mature and very slow compiler. Judging by popularity of Go, so do many other people. While the languages probably will mature after couple more years, I don't see much hope for making the compiler as fast as Go, regardless of the effort. See C++ compilers.
- pjmlp 9y ago> And how many decades did it take for C++ to support std::array? About one decade. In the mid-90's already most C++ compilers had their own version of std::array, for example Borland compilers.
- ngrilly 9y ago> I think something like func (t Type) operator delete(k KeyType) ? Robert Griesemer, a member of the Go team, has presented a similar design at dotGo 2016: https://talks.golang.org/2016/prototype-your-design.pdf https://talks.golang.org/2016/prototype-your-design.pdf