Groups
Groups
Sign in
Groups
Groups
golang-nuts
Conversations
About
Send feedback
Help
Can generics save virtual function calls?
146 views
Skip to first unread message
Amit Lavon
unread,
Apr 5, 2022, 2:05:36 PM
4/5/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Hi gophers,
When we use an interface as a type parameter, does it mean that calls to that interface will be replaced with calls to the concrete type?
To demonstrate, consider
https://go.dev/play/p/j4N8G_n-3uG
.
Will the compiler create a static call to MyDoer.Do instead of a virtual call to Doer.Do?
Ian Lance Taylor
unread,
Apr 5, 2022, 3:05:40 PM
4/5/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Amit Lavon, golang-nuts
Occasionally, yes. In general, no. It depends, and it will likely
vary between different Go compilers and different releases of the same
Go compiler.
Ian
Amit Lavon
unread,
Apr 6, 2022, 5:05:02 PM
4/6/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Thank you!
Reply all
Reply to author
Forward
0 new messages