>From an implementation standpoint they are passed by reference (The
representation is actually a pair (pointer to vtable, pointer to
object), but from a semantic standpoint the difference still matters,
because e.g. if the original value was a struct, it still can't be
mutated. There are use cases for what Volker is asking about in the
standard library, even:

package json // import "encoding/json"

func Unmarshal(data []byte, v interface{}) error
    Unmarshal parses the JSON-encoded data and stores the result in the value
    pointed to by v. If v is nil or not a pointer, Unmarshal returns an
    InvalidUnmarshalError.

    ...

Quoting Robert Engels (2018-11-19 09:57:12)
>    Aren't all interface references passed as a pointer? It is a var that
>    contains a pointer to the struct and a concrete type of the struct?
>
>    On Nov 19, 2018, at 8:45 AM, Volker Dobler
>    <[1]dr.volker.dob...@gmail.com> wrote:
>
>    > Is there a way to force "SomeFunction" to take pointers only at
>    compile time?
>    No, sorry.
>    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 [2]golang-nuts+unsubscr...@googlegroups.com.
>    For more options, visit [3]https://groups.google.com/d/optout.
>
>    --
>    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 [4]golang-nuts+unsubscr...@googlegroups.com.
>    For more options, visit [5]https://groups.google.com/d/optout.
>
> Verweise
>
>    1. mailto:dr.volker.dob...@gmail.com
>    2. mailto:golang-nuts+unsubscr...@googlegroups.com
>    3. https://groups.google.com/d/optout
>    4. mailto:golang-nuts+unsubscr...@googlegroups.com
>    5. https://groups.google.com/d/optout

-- 
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