References of the Go program to external variables

Source: Internet
Author: User

Assume that there is a function A and A has multiple local variables, and a go procedure B is enabled. B directly uses the local variables of A (call parameters/internal parameters ).

Obviously, each call to a should only involve the internal variable environment of a at that time, or the program will be messy.

This is required in any language, as is go.

However, this poses a problem: After a is executed, the data stack it occupies cannot be released (because the external environment of the open go process needs to be maintained ).

If a occupies a very large stack, it will lead to serious memory waste.

Therefore, the new go program should minimize the dependency on the external environment, especially the reference to the local variables of the external function, the variables used as parameters should be passed to the Go program as much as possible.

In this way, the compiler can perform better optimization by avoiding the go program that depends on the external function environment.

References of the Go program to external variables

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.