On Thursday, 16 July 2020 at 12:51:03 UTC-7 Ian Lance Taylor wrote:

> On Thu, Jul 16, 2020 at 12:41 PM joshua harr <joshu...@gmail.com> wrote: 
> > Just a note on your rationale for why not to use <: :> : 
> > "... requires more typing." Golang has, rather famously, never shied 
> away from making developers type more. The reason it hasn't, as far as I 
> understand, is that code is read far often than it is written, and so the 
> extra verbosity is worth the ease in reading the code. IMHO, that principle 
> very much applies here. The *readability* of the syntax should be a far 
> more important consideration than whether there is an extra character in 
> the syntax. 
>
> That's a fair point. Having two characters is still in my mind a 
> disadvantage, but I agree that that disadvantage could be outweighed 
> by a gain in readability. 
>
> That said, personally I don't find <:T:> to be any more (or less) 
> readable than [T]. 
>
> Ian 
>

I agree that readability should be a big consideration.

The problem with [T] is that you need to actively read the surrounding code 
to discern between a possible array access or type parameter.  I would 
prefer it to be immediately obvious so that visually scanning through code 
is as fast and clear as can be.

An alternative syntax to [T] that could enable "quick looks" is [[T]].  It 
would be nice to use <<T>>, but that has parsing ambiguities with the 
existing bit-shift operator, just as <T> is ambiguous with the comparison 
operator.

The burden of typing the same character twice on a keyboard in quick 
succession for [[T]] is more or less the same as the single-character 
version [T] and less so than two-character delimiters like <: and :>, and 
especially those delimiters that require the shift-key in play at the same 
time.

jpap

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/74bd82c9-c612-43c5-a263-0adcf739372cn%40googlegroups.com.

Reply via email to