I think the answer is probably the simpler one. Go seems to be checking
"Is this expression composed of Go official instructions and libs or is it
a user-defined construct?"

Maybe it is just discarding user-defined functions because it doesn't know
if the function return value may change during the program execution. Just
to be on the safe side.


[]'s Ailton


2018-03-29 14:13 GMT-03:00 Nilsocket <nilsoc...@gmail.com>:

>
> > https://research.swtch.com/godata
>>
> I did read it, but what I was asking is irrelevent to it.
>
> func showInt(x int) {
>     res := (*[unsafe.Sizeof(x)]byte)(unsafe.Pointer(&x))
>     for i := range res {
>         fmt.Printf("%.2x ", res[i])
>     }
>     fmt.Println()
> }
> // showInt(12345)
> // 39 30 00 00 00 00 00 00
>
> An integer in it's binary form is stored like above, little endian.
> What I mean is how, strings are represented, while converting a string to
> []byte, gives me utf-8 values,
> but directly ascessing the underlying memory of string, without converting
> it to []byte shows different things.
>
>
>
>
>> > Because in Go the size of an array must be a constant.
>> >
>> > Ian
>>
>
>
> An array size must be constant, but my real question is?
> How come, a uintptr type value returned by unsafe.Sizeof(x), is considered
> as const?
> and doesn't accept, if uintptr type value is returned by someother
> function.
> I mean, how was it able to differentiate between someother function and
> unsafe.Sizeof(x).
>
> --
> 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.
>

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