The linked spec is the the definitive language specification. I read it
carefully a couple of time (cannot recommend it enough) and knew about
type switches.
The most common language implementation is go's default compiler gc.
Which is the place to implement the language spec and type switches.
I knew that the go command is used to compile with the gc compiler. I
opened the go src and looked at the cmd package, finding the compile and
gc folder and finally the swt.go file. So I didn't even need grep.
Hope that helps!
Again, my recommendation: the go language spec is really very well
written and very readable for a language spec.
On 29.07.20 23:21, Shane H wrote:
On Wednesday, July 29, 2020 at 7:23:22 PM UTC+10, mb0 wrote:
This is a special kind of switch called a type switch. You can read
more
about it in the language specification where its part of the intrinsic
go syntax. https://golang.org/ref/spec#Switch_statements
<https://golang.org/ref/spec#Switch_statements>
Because it is a special language construct you need to look at the
compiler. You probably want to check out the default gc compiler and
may
start your journey here:
https://github.com/golang/go/blob/master/src/cmd/compile/internal/gc/swt.go#L617
<https://github.com/golang/go/blob/master/src/cmd/compile/internal/gc/swt.go#L617>
This is really helpful, thanks.
The two questions I am left with are:
How do I recognise that something is a "special language construct"; is
it simply a matter of, I cannot ctrl-] to it directly, so I need to grep?
And, just as importantly, how do I find out what I need to grep /for/
Regards
--
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
<mailto:golang-nuts+unsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/5d2cfcd6-579a-4846-8c33-0aa763a9efd9o%40googlegroups.com
<https://groups.google.com/d/msgid/golang-nuts/5d2cfcd6-579a-4846-8c33-0aa763a9efd9o%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
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/b39512e8-08ae-9d56-7d73-11375d47569d%40mb0.org.