Am Donnerstag, 29. September 2016 07:02:26 UTC+2 schrieb T L:
>
> I know of the syntax in spec. 
> I just want to understand what is the deep reason for the syntax 
> inconsistency between map index and type assert.
>

"deep reason"s are found in religion and math not in
programming language design.

A type assertion states "this has type x" which is a bold
statement, an assertion and these tend to fail/abort/terminate/throw
if violated in most languages. Also: What could be the possible
return value if the assertion failed? The zero value only.
Now think about how you would use x := foo.(bar)  after a failed
type assertion. Basically impossible, a practically useless language
construct. Which in turn would force to allow the the x, ok = foo.(bar)
only. Now again you do have an "inconsistency" (whatever you mean
with this term) with map access which allows both forms.

Btw: What do you think about the inconsistency between import
statements and for loops :-) ?

V. 


-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to