1

I know that global variables are stored in slots of storage layout. But where are the functions stored?

I would like to know technically why.

2 Answers 2

2

Basically, given a function selector, your bytecode knows where the functions are kept and use the selector to know where to jump your code to.

Here is a useful link: https://blog.openzeppelin.com/deconstructing-a-solidity-contract-part-iii-the-function-selector-6a9b6886ea49/

0

I’m assuming you are referring to one of the four data storing locations: storage, memory, call data, and stack. Function parameters and variables declared inside functions are generally stored in memory data locations (location for value type variables are stored in memory while locations for reference type variables are stored in storage).

Function parameters and variables declared inside functions are stored in memory because they are short-lived and local to the scope of the function.

See: https://subscription.packtpub.com/book/application-development/9781788831383/3/ch03lvl1sec38/storage-and-memory-data-locations

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.