On Tue, Aug 20, 2019 at 9:53 PM Xiangdong JI <xiangdong...@arm.com> wrote:
>
> Thanks Ian.
> Curious to know the purpose of those dummy functions, and for the 'import' 
> functions do they have real function bodies?

The dummy functions are there mainly so that the "init" line can list
all imported packages without having an even weirder syntax.  For the
real functions, yes, they have real function bodies defined in the
appropriate package.

Ian


> On Wednesday, August 21, 2019 at 12:40:44 PM UTC+8, Ian Lance Taylor wrote:
>>
>> On Tue, Aug 20, 2019 at 9:12 PM Xiangdong JI <xiang...@arm.com> wrote:
>> >
>> > In 'init' section of .gox files, there might be functions like the 
>> > followings besides those 'import',
>> >
>> >             math ~math bits ~math..z2fbits atomic 
>> > ~runtime..z2finternal..z2fatomic
>> >
>> > where and how are those functions generated, any source code or doc I can 
>> > refer to? Thanks.
>>
>> These are pairs of package name and init function name.  If the init
>> function name starts with "~" then it is a dummy name and there is no
>> actual function.  Otherwise it is a real function.  The function is
>> generated by the compiler and handles initialization of package scope
>> variables that cannot be statically initialized, and calls all the
>> init functions in the package.
>>
>> Ian
>
> --
> 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/322e7407-bc21-44ea-8ca3-4ad07a7851b7%40googlegroups.com.

-- 
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/CAOyqgcWne8igK9-v2pBbkPqCqARASXWoLRnxJwk%3D-BqLpr_qWQ%40mail.gmail.com.

Reply via email to