Re: [go-nuts] Generics and parentheses

2020-08-17 Thread Frederik Zipp
jlge...@gmail.com schrieb am Montag, 17. August 2020 um 19:13:45 UTC+2: > >- No support covariance or contravariance. Maybe I am on shaky ground >in terms of my understanding but doesn't this mean, for instance, that if > I >have two interfaces, Foo and Bar, and a third composite

Re: [go-nuts] Generics and parentheses

2020-08-17 Thread Ian Lance Taylor
On Mon, Aug 17, 2020 at 10:13 AM Jonathan Gerber wrote: > > 1) Of the enumerated omissions, the ones that I think are really unfortunate > are, in order of importance, from my perspective: > > No operator methods & no adapters - Doesn't this make generic types sort of > second class?. I think

Re: [go-nuts] Generics and parentheses

2020-08-17 Thread Beka Westberg
> No support covariance or contravariance. Maybe I am on shaky ground in terms of my understanding but doesn't this mean, for instance, that if I have two interfaces, Foo and Bar, and a third composite interface, FooBar, which consists of Foo and Bar, that a function with a generic parameter T

Re: [go-nuts] Generics and parentheses

2020-08-17 Thread Jonathan Gerber
As someone who has spent a LOT of time in Rust, I really miss generics in Go (Conversely, i miss the simplicity of Go. My personal favorite, imaginary language would probably be Go + Generics + Sum Types and destructuring) and so I am really excited to see this taking shape. That being said,

Re: [go-nuts] Generics and parentheses

2020-08-10 Thread Edwin S
I am trying to add my 2 cents here. I am sorry if my opinions have been mentioned. I personally prefer Round Brackets (parentheses). It is not about readability on symbols, but the way how I understand the logic of Type Parameters. I see Type Parameters as a way to describe how to

Re: [go-nuts] Generics and parentheses

2020-08-08 Thread Denis Cheremisov
> Have the authors considered the implications of requiring the `type` keyword to use a generic type, not just at declaration time? Would this open up more syntax possibilities, such as `var x T`? This might be easier to read at the expense of five more characters of typing. It also could

Re: [go-nuts] Generics and parentheses

2020-08-06 Thread 'Axel Wagner' via golang-nuts
On Thu, Aug 6, 2020 at 9:26 PM 'Red Daly' via golang-nuts < golang-nuts@googlegroups.com> wrote: > Have the authors considered the implications of requiring the `type` > keyword to use a generic type, not just at declaration time? Would this > open up more syntax possibilities, such as `var x T`?

Re: [go-nuts] Generics and parentheses

2020-08-06 Thread Ian Lance Taylor
On Thu, Aug 6, 2020 at 12:25 PM 'Red Daly' via golang-nuts wrote: > > Have the authors considered the implications of requiring the `type` keyword > to use a generic type, not just at declaration time? Would this open up more > syntax possibilities, such as `var x T`? This might be easier to >

Re: [go-nuts] Generics and parentheses

2020-08-06 Thread 'Red Daly' via golang-nuts
Have the authors considered the implications of requiring the `type` keyword to use a generic type, not just at declaration time? Would this open up more syntax possibilities, such as `var x T`? This might be easier to read at the expense of five more characters of typing. It also could

Re: [go-nuts] Generics and parentheses

2020-08-06 Thread Mike Schinkel
Hi Russ, In general, I think the proposal is a really good one. I like that you abandoned contracts as interfaces were just too similar, and personally I like the choice of square brackets. There are a few aspects I do not like — 1.) no zero value and 2.) lack of covariance and

Re: [go-nuts] Generics and parentheses

2020-07-22 Thread Steven Blenkinsop
On Wed, Jul 22, 2020 at 8:02 PM, Russ Cox wrote: > So it sounds like everyone is in favor of the entire generics proposal and > all the semantics, and all we have left to hammer out is the bracket > characters? Do I have that right? > > Best, > Russ > I think this thread is specifically about

Re: [go-nuts] Generics and parentheses

2020-07-22 Thread Kent Sandvik
[ ] is nice. Nim also uses [ ] for generics. --Kent On Wed, Jul 22, 2020 at 4:41 PM Denis Cheremisov wrote: > Lesser and greater signs never were a good choice. They were chosen > because of C syntax restrictions. Go creators would do *slice[T]* (or may > be just *[T]*), *map[K,V]*,* chan[T]*,

Re: [go-nuts] Generics and parentheses

2020-07-22 Thread Michael Jones
So it seems! nothing substantive on the hard part. On Wed, Jul 22, 2020 at 5:02 PM Russ Cox wrote: > So it sounds like everyone is in favor of the entire generics proposal and > all the semantics, and all we have left to hammer out is the bracket > characters? Do I have that right? > > Best, >

Re: [go-nuts] Generics and parentheses

2020-07-22 Thread David Riley
On Jul 22, 2020, at 8:02 PM, Russ Cox wrote: > > So it sounds like everyone is in favor of the entire generics proposal and > all the semantics, and all we have left to hammer out is the bracket > characters? Do I have that right? We haven't covered what the bike shed roof is going to be made

Re: [go-nuts] Generics and parentheses

2020-07-22 Thread Michal Strba
Very correct! At least from my perspective. On Thu, 23 Jul 2020 at 02:02 Russ Cox wrote: > So it sounds like everyone is in favor of the entire generics proposal and > all the semantics, and all we have left to hammer out is the bracket > characters? Do I have that right? > > Best, > Russ > > >

Re: [go-nuts] Generics and parentheses

2020-07-22 Thread David Riley
On Jul 15, 2020, at 4:59 PM, Ian Lance Taylor wrote: > > On Wed, Jul 15, 2020 at 5:44 AM Jan Mercl <0xj...@gmail.com> wrote: >> >> My 2c - Alternative type parameters syntax (ab)using @$: >> https://docs.google.com/document/d/1AoU23DcNxYX2vYT20V2K16Jzl7SP9taRRhIT8l_pZss/edit?usp=sharing > >

Re: [go-nuts] Generics and parentheses

2020-07-22 Thread Russ Cox
So it sounds like everyone is in favor of the entire generics proposal and all the semantics, and all we have left to hammer out is the bracket characters? Do I have that right? Best, Russ -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Generics and parentheses

2020-07-22 Thread Denis Cheremisov
Lesser and greater signs never were a good choice. They were chosen because of C syntax restrictions. Go creators would do *slice[T]* (or may be just *[T]*), *map[K,V]*,* chan[T]*, etc if they had generics in mind. Because, if you have managed not to notice it, Go barely inherited anything from

Re: [go-nuts] Generics and parentheses

2020-07-22 Thread Sahas Subramanian
With angled brackets, do we really need the colon or dot on both sides? Wouldn't it be enough to just have it on the left to eliminate the parse time ambiguities? Like f<:int> or f<.int>? On Wed, 22 Jul 2020, 22:46 Евгений Кошевой, wrote: > Maybe something like this: > using <.Type.> > func

Re: [go-nuts] Generics and parentheses

2020-07-22 Thread Евгений Кошевой
Maybe something like this: using <.Type.> func f(T<.int.>) struct{ T<.int.> } interface{ T<.int.> } []T<.int.>{} среда, 22 июля 2020 г. в 01:12:32 UTC+3, Steven Blenkinsop: > On Tue, Jul 21, 2020 at 3:12 PM, Michal Strba wrote: > >> I'd say a dot is necessary when instantiating a function call

Re: [go-nuts] Generics and parentheses

2020-07-21 Thread Steven Blenkinsop
On Tue, Jul 21, 2020 at 3:12 PM, Michal Strba wrote: > I'd say a dot is necessary when instantiating a function call but > unnecessary when instantiating a type because it's always syntactically > clear when a type is required. > That's not true in Go. Conversions look like function calls:

Re: [go-nuts] Generics and parentheses

2020-07-21 Thread Michal Strba
I'd say a dot is necessary when instantiating a function call but unnecessary when instantiating a type because it's always syntactically clear when a type is required. ut 21. 7. 2020 o 18:51 napísal(a): > Using angle brackets is not a must for supporting generics, but it is the > common syntax

Re: [go-nuts] Generics and parentheses

2020-07-21 Thread brettcaomail
like java?i like it 在 2020年7月15日星期三 UTC+8上午6:31:55,Harald Weidner写道: > > Hello, > > > A typical computer keyboard provides four easily accessible pairs of > > single-character symmetrical "brackets": parentheses ( and ), square > > brackets [ and ], curly braces { and }, and angle brackets <

Re: [go-nuts] Generics and parentheses

2020-07-21 Thread ahmadelshehy
Using angle brackets is not a must for supporting generics, but it is the common syntax of generics in programming languages that support generics, the same way as square brackets are the common syntax for indexing in programming languages. If I understand correctly, the ambiguity problem with

Re: [go-nuts] Generics and parentheses

2020-07-20 Thread Peter McKenzie
This seems to be very similar to a suggestion I made a couple of years ago: https://gist.github.com/peter-mckenzie/5cc6530da1d966e743f4a39c150a6ac2 The spaces are in different places but that could be regarded as a matter of style. I always liked it, but maybe a little too quirky for most :-)

Re: [go-nuts] Generics and parentheses

2020-07-19 Thread K Davidson
Not that I am for guillemets, but isn't attempting to push the industry towards a richer pallette than ASCII the whole point of building unicode into the core of go? We already include the middot in go assembly, and some core members of the go team love using unicode identifiers in personal

Re: [go-nuts] Generics and parentheses

2020-07-18 Thread Laurens Hellemons
The more I think about this suggestion, the more I like it. - It solves the lookahead problem (I think); - it visually separates the type parameters from the actual parameters and return types, so the choice of delimiter characters for the type arguments becomes less relevant from a

Re: [go-nuts] Generics and parentheses

2020-07-18 Thread Jakob Borg
> Sent: Saturday, July 18, 2020 10:43:11 AM To: Jon Conradt mailto:j...@theconradts.com>> Cc: golang-nuts mailto:golang-nuts@googlegroups.com>> Subject: Re: [go-nuts] Re: Generics and parentheses I don't know if the recommendation to use guillamets is out of spite for the ongo

Re: [go-nuts] Generics and parentheses

2020-07-18 Thread Kiswono Prayogo
Older thread: https://groups.google.com/u/0/g/golang-nuts/c/zGQq_I5r2jg/m/_LPQDf3BBgAJ And the poll: https://www.surveylegend.com/s/2dwe On Saturday, July 18, 2020 at 11:58:50 p.m. UTC+7 golde...@gmail.com wrote: > Can not agree any more. Compiler's job, it's duty, is to translate the > human

Re: [go-nuts] Generics and parentheses

2020-07-18 Thread goldenbull
Can not agree any more. Compiler's job, it's duty, is to translate the human readable code into binary 0 and 1. Human readability should take precedence over the compiler complexity and even performance. 在 2020年7月15日星期三 UTC+8下午12:45:41,robert engels写道: > > My opinion is that every major

Re: [go-nuts] Generics and parentheses

2020-07-18 Thread roger peppe
On Sat, 18 Jul 2020, 13:25 Jan Mercl, <0xj...@gmail.com> wrote: > On Sat, Jul 18, 2020 at 1:39 PM roger peppe wrote: > > > I didn't say there was exactly one construct for each kind of name > definition. In current Go, when a name is defined, it's defined inside a > construct that is explicitly

Re: [go-nuts] Generics and parentheses

2020-07-18 Thread Jan Mercl
On Sat, Jul 18, 2020 at 1:39 PM roger peppe wrote: > I didn't say there was exactly one construct for each kind of name > definition. In current Go, when a name is defined, it's defined inside a > construct that is explicitly about defining that name. By contrast, in your > proposal, we take

Re: [go-nuts] Generics and parentheses

2020-07-18 Thread roger peppe
On Sat, 18 Jul 2020 at 11:05, Jan Mercl <0xj...@gmail.com> wrote: > On Sat, Jul 18, 2020 at 11:12 AM roger peppe wrote: > > Thanks for taking time to think about it. > > > A few reasons that I'm not keen on your $, @ proposal: > > > > - elsewhere in Go, when a name is defined, there is one clear

Re: [go-nuts] Generics and parentheses

2020-07-18 Thread bugpowder
On Sat, Jul 18, 2020 at 12:12 PM roger peppe wrote: > > - elsewhere in Go, when a name is defined, there is one clear construct >> that defines it, not an arbitrary place within a type expression. That's >> not the case in your proposal. >> > On the other hand, $/@ is not dissimilar to using the

Re: [go-nuts] Generics and parentheses

2020-07-18 Thread Jan Mercl
On Sat, Jul 18, 2020 at 11:12 AM roger peppe wrote: Thanks for taking time to think about it. > A few reasons that I'm not keen on your $, @ proposal: > > - elsewhere in Go, when a name is defined, there is one clear construct that > defines it, not an arbitrary place within a type expression.

Re: [go-nuts] Generics and parentheses

2020-07-18 Thread roger peppe
On Thu, 16 Jul 2020, 14:38 Jan Mercl, <0xj...@gmail.com> wrote: > On Thu, Jul 16, 2020 at 3:12 PM 'Axel Wagner' via golang-nuts > wrote: > > > I dislike the idea of using $ and @ because I don't want to add new > symbols to the language, if it can be avoided. In general I'd argue that Go > tends

Re: [go-nuts] Generics and parentheses

2020-07-16 Thread Kulics Wu
Why not try the design of Feel language, There is no ambiguity and no more code. ``` type [Item T] struct { Value T } func (it [Item T]) Print() { println(it.Value) } func [TestGenerics T V]() { var a = [Item T]{} a.Print() var b = [Item V]{}

Re: [go-nuts] Generics and parentheses

2020-07-16 Thread Jan Mercl
On Thu, Jul 16, 2020 at 3:12 PM 'Axel Wagner' via golang-nuts wrote: > I dislike the idea of using $ and @ because I don't want to add new symbols > to the language, if it can be avoided. In general I'd argue that Go tends to > use keywords instead of symbols to convey meaning - e.g. we don't

Re: [go-nuts] Generics and parentheses

2020-07-16 Thread 'Axel Wagner' via golang-nuts
I dislike the idea of using $ and @ because I don't want to add new symbols to the language, if it can be avoided. In general I'd argue that Go tends to use keywords instead of symbols to convey meaning - e.g. we don't write `a -> b`, but `func(a) b`. There are exceptions (pointers are a big one)

Re: [go-nuts] Generics and parentheses

2020-07-16 Thread Henrik Johansson
This is good. I have been reaching for a consistency check and this just may be it. On Thu, Jul 16, 2020 at 12:04 AM 'Dan Kortschak' via golang-nuts < golang-nuts@googlegroups.com> wrote: > On Wed, 2020-07-15 at 14:36 -0700, Randall O'Reilly wrote: > > And the use of [ ] in map is more

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2020-07-15 at 18:09 -0700, lotus.developer.mas...@gmail.com wrote: > Personally think this way is easier to read. In this way, I wrote a > few examples, which may be different from the creator Please post in unstyled plain text. It is almost impossible to read the code examples you have

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread lotus . developer . master
Personally think this way is easier to read. In this way, I wrote a few examples, which may be different from the creator * For example: define a node type Node struct{ prev *Node data T //data *T next *Node } * Call request var node Node * Let's take another example, such as the

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Randall Oreilly
Perhaps another source of resistance to < > is the trauma many of us have from its major obfuscation of C++ code? - Randy > On Jul 15, 2020, at 3:13 PM, Yaw Boakye wrote: > > To summarize the thread so far: > > - parenthesis is a no-no > - angle brackets are popular/common but that alone

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Denis Cheremisov
The big argument I always found less and greater signs to be not visually distinctive enough, at least with fonts I am using. [ and ] are larger and I was really happy with them in Scala although I dislike the language in general. Seriously though, the real big argument is [] are already used

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Ian Lance Taylor
On Wed, Jul 15, 2020 at 3:27 PM Bakul Shah wrote: > > The syntax rule I envisioned was this: > type: ... | type generic-type | ... > > To me, using full parenthesization, this would be > func() int pair pair" == "((func() int) pair)pair --(1) > What you seem to want is > (func() (int pair)) pair

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2020-07-15 at 15:27 -0700, Bakul Shah wrote: > The second issue is the usage for generic functions. Contrast > > (float64, int)PowN(1.2, 3) > with > PowN[float64, int](1.2, 3) > or currently > PowN(float64, int)(1.2, 3) > > I find the alternate syntax easier because

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Bakul Shah
> On Jul 15, 2020, at 1:49 PM, Ian Lance Taylor wrote: > > On Tue, Jul 14, 2020 at 11:06 PM Bakul Shah wrote: >> >> I don't much like square brackets or angle brackets or guillemets. But here >> is a different way >> of reducing the need for parentheses at least for the common case: >> >>

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2020-07-15 at 17:10 -0500, Seebs wrote: > That said, if people don't like square brackets, I'm totally prepared > to make worse suggestions until they give up and say square brackets > aren't that bad. > Let's bring back the special five keywords! func despiteallobjections F insofaras

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Yaw Boakye
To summarize the thread so far: - parenthesis is a no-no - angle brackets are popular/common but that alone doesn't make good argument. some languages have already deviated. scala is popular, uses square instead of angle brackets. - go's current pseudo-generic data structure, the map, already

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Seebs
On Wed, 15 Jul 2020 14:51:17 -0700 jimmy frasche wrote: > I didn't care about () except for having to then have extra parens > around types in a lot of places which was very annoying and came up > often. If [] fixes that, great! I was pretty unhappy with () just because there's too many () and

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread 'Dan Kortschak' via golang-nuts
On Wed, 2020-07-15 at 14:36 -0700, Randall O'Reilly wrote: > And the use of [ ] in map is more semantically associated with its > conventional use as an element accessor in arrays / slices, not with > some more general kind of type parameter. The [] syntax can be viewed as an indexing operation

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread jimmy frasche
I didn't care about () except for having to then have extra parens around types in a lot of places which was very annoying and came up often. If [] fixes that, great! On Wed, Jul 15, 2020 at 2:47 PM Ian Lance Taylor wrote: > > On Wed, Jul 15, 2020 at 2:36 PM Randall O'Reilly wrote: > > > >

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Ian Lance Taylor
On Wed, Jul 15, 2020 at 2:36 PM Randall O'Reilly wrote: > > Regarding the parsing: as I suggested in my email, but perhaps was unclear, > in case of two conflicting *purely syntactic* interpretations (without using > any type information), you could just choose the more high-frequency >

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Robert Engels
This is what I was thinking. Format for the common case. At compile/link time you would be able to figure out the conflict and throw an error and the dev could add the parens to make it unambiguous. > On Jul 15, 2020, at 4:36 PM, Randall O'Reilly wrote: > > Regarding the parsing: as I

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Randall O'Reilly
Regarding the parsing: as I suggested in my email, but perhaps was unclear, in case of two conflicting *purely syntactic* interpretations (without using any type information), you could just choose the more high-frequency interpretation (i.e., type parameters) and force the programmer to use

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Robert Engels
But Scala doesn’t use [] for anything else - Go does. > On Jul 15, 2020, at 9:58 AM, 'Nic Long' via golang-nuts > wrote: > > Square brackets work great. Scala uses them for generics to great effect. > They also make me think of Clojure, which introduced them to Lisp for similar > reasons

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Ian Lance Taylor
On Wed, Jul 15, 2020 at 5:44 AM Jan Mercl <0xj...@gmail.com> wrote: > > My 2c - Alternative type parameters syntax (ab)using @$: > https://docs.google.com/document/d/1AoU23DcNxYX2vYT20V2K16Jzl7SP9taRRhIT8l_pZss/edit?usp=sharing Thanks for the detailed writeup. I'm a bit concerned about name

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Ian Lance Taylor
On Tue, Jul 14, 2020 at 11:06 PM Bakul Shah wrote: > > I don't much like square brackets or angle brackets or guillemets. But here > is a different way > of reducing the need for parentheses at least for the common case: > > A proposal for fewer irritating parentheses! > > One thing to note is

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread David Riley
On Jul 15, 2020, at 2:48 PM, Ian Lance Taylor wrote: > > More seriously, though, let's look closely at Robert's example: > > a, b = w < x, y > (z) TBH, I think a big argument in favor of square brackets over angle brackets is that they ascend above the center line in most typefaces, which

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Seebs
On Wed, 15 Jul 2020 12:26:15 -0700 Ian Lance Taylor wrote: > The suggested syntax, whether with parentheses or square brackets, has > what I consider to be a very nice property: the definition and use > syntaxes are very similar. For the definition we write > > func F[type T]() {} > > For the

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Ian Lance Taylor
On Tue, Jul 14, 2020 at 10:06 PM Paul Johnston wrote: > > If the generic expression was always attached/constrained to the "type" > or "func" keyword (rather than the type or function name), perhaps this would > decrease the lookahead problems with lexing? For example: > > type Point struct {

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Hein Meling
Correction: I think it is much more important that Go remains internally consistent in its use of "square" brackets. On Wednesday, July 15, 2020 at 8:54:58 PM UTC+2 Hein Meling wrote: > When you refer to beginners, I think you mean developers from other > languages (Java/C#/C++...) that

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Hein Meling
When you refer to beginners, I think you mean developers from other languages (Java/C#/C++...) that already know the concept of generics. I don't think they will have problems adapting to a square brackets notation... they are smart people, and after all they have to learn many other

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Ian Lance Taylor
On Tue, Jul 14, 2020 at 9:45 PM robert engels wrote: > > My opinion is that every major language (no flames please… lots of developers > write lots of programs and make money doing it) that supports generics uses < > > for generic types, so Go should too - since there is no reason to deviate >

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Zippoxer
Agreed. I've been a happy Gopher since 2011 and would really like to see <> or even [] instead of (). On Wednesday, 15 July 2020 20:03:40 UTC+3, Dan Markham wrote: > > On Tuesday, July 14, 2020 at 9:45:41 PM UTC-7, robert engels wrote: >> >> My opinion is that every major language (no flames

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Dan Markham
On Tuesday, July 14, 2020 at 9:45:41 PM UTC-7, robert engels wrote: > > My opinion is that every major language (no flames please… lots of > developers write lots of programs and make money doing it) that supports > generics uses < > for generic types, so Go should too - since there is no >

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Seebs
On Tue, 14 Jul 2020 23:19:40 -0700 (PDT) Fino wrote: > I vote for <: and :> I'm conflicted on it. <> match what several other languages do, but are problematic for the parser. () is definitely overused. [] is tolerable. I'd like to bring up the possibility of ??( and ??), mostly so that

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Tao Liu
This is similar to C++ template, and it's very clear to understand. On Wednesday, July 15, 2020 at 1:06:24 PM UTC+8, Paul Johnston wrote: > > If the generic expression was always attached/constrained to the > "type" or "func" keyword (rather than the type or function name), perhaps > this

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread 'Nic Long' via golang-nuts
Square brackets work great. Scala uses them for generics to great effect. They also make me think of Clojure, which introduced them to Lisp for similar reasons to here - to avoid too much overload of regular parentheses - and which people have been very happy with. On Wednesday, 15 July 2020

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread David Riley
On Jul 15, 2020, at 4:47 AM, Nick Craig-Wood wrote: > > In my mind the use of [ ] clashes horribly with the array declaration > syntax. When I see [int] in particular my brain says, ah array declaration of > size int, what, no wait... On the other hand, this is already how maps are declared

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Jan Mercl
On Tue, Jul 14, 2020 at 11:55 PM 'Robert Griesemer' via golang-nuts wrote: > The time has come to revisit this early decision. If square brackets alone > are used to declare type parameters, the array declaration My 2c - Alternative type parameters syntax (ab)using @$:

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Jesper Louis Andersen
On Wed, Jul 15, 2020 at 11:27 AM Randall O'Reilly wrote: > wouldn't gofmt remove the superfluous (z) in this case (and even with a > more complex expression inside the parens, as the > operator would have > appropriate precedence?), in existing code? And thus, would it not be > reasonable to

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Randall O'Reilly
Sorry to perseverate and belabor the point, but here's an analogy that makes the point perhaps more strongly and succinctly: Imagine that, for some reason, Go didn't have the array/slice element operator syntax, [ ], and it was now going to be introduced in Go2, but instead of using this

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Jesper Louis Andersen
On Wed, Jul 15, 2020 at 10:47 AM Nick Craig-Wood wrote: > In my mind the use of [ ] clashes horribly with the array declaration > syntax. When I see [int] in particular my brain says, ah array declaration > of size int, what, no wait... > > This makes [identifier] mean two different things

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Jesper Louis Andersen
On Wed, Jul 15, 2020 at 8:25 AM Michael Jones wrote: > nice. "gen" here is akin to the existing forward declaration of recursive > inner functions. it says, "you are about to see something special and you > need to know *this* about it." > > The real name is "forall", and it presents a binding

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Bakul Shah
As I wrote, parentheses are not needed for the common case of single type parameter. If you have more than one, you need parentheses but note that this is a *prefix* and any parsing ambiguities can removed by using a - if needed. For your example it will be something like (float64,int)PowN(1.2,

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2020-07-14 at 23:53 -0700, Randall O'Reilly wrote: > So, essentially, this puts the onus back on the parser programmers to > definitively *rule out* the use of < > -- is it really that difficult > / costly to do a bit of look-ahead and disambiguate the different use > cases? The absence

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread 'Dan Kortschak' via golang-nuts
On Tue, 2020-07-14 at 23:05 -0700, Bakul Shah wrote: > I don't much like square brackets or angle brackets or guillemets. > But here is a different way > of reducing the need for parentheses at least for the common case: > > A proposal for fewer irritating parentheses! > > One thing to note

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Randall O'Reilly
Tagging onto this point: while Go deviates from other languages in a number of important ways, syntax at the level of things like parens, brackets, etc is not one of these key differences. It is almost entirely consistent with the "de facto" C-style choices in this respect (to the extent that

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Michael Jones
nice. "gen" here is akin to the existing forward declaration of recursive inner functions. it says, "you are about to see something special and you need to know *this* about it." On Tue, Jul 14, 2020 at 11:06 PM Bakul Shah wrote: > I don't much like square brackets or angle brackets or

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Fino
I vote for <: and :> type more on traditional keyboard is acceptable for me, since I don't use generics much. too much parentheses ( and ) in declaration is really hard to read, confused my mind. square brackets [ and ] should reserve for array and slice. and, look ahead, we are able to

Re: [go-nuts] Generics and parentheses

2020-07-15 Thread Bakul Shah
I don't much like square brackets or angle brackets or guillemets. But here is a different way of reducing the need for parentheses at least for the common case: A proposal for fewer irritating parentheses! One thing to note is that generic functions & types are *different* from existing things

Re: [go-nuts] Generics and parentheses

2020-07-14 Thread Paul Johnston
If the generic expression was always attached/constrained to the "type" or "func" keyword (rather than the type or function name), perhaps this would decrease the lookahead problems with lexing? For example: *type Point struct {* *x, y int* *data T* *}* *type Transformer interface {*

Re: [go-nuts] Generics and parentheses

2020-07-14 Thread robert engels
My opinion is that every major language (no flames please… lots of developers write lots of programs and make money doing it) that supports generics uses < > for generic types, so Go should too - since there is no reason to deviate from this other than to avoid changes to the parser. Seems

Re: [go-nuts] Generics and parentheses

2020-07-14 Thread David Riley
On Jul 14, 2020, at 5:54 PM, 'Robert Griesemer' via golang-nuts wrote: > > But if we are comfortable with the extra type keyword, the ambiguity > disappears: > > type A[type N] E > > (When we originally dismissed square brackets, the type keyword was not yet > on the table.) > >

Re: [go-nuts] Generics and parentheses

2020-07-14 Thread Harald Weidner
Hello, > A typical computer keyboard provides four easily accessible pairs of > single-character symmetrical "brackets": parentheses ( and ), square > brackets [ and ], curly braces { and }, and angle brackets < and >. Go uses > curly braces to delineate code blocks, composite literals, and some