The Solidity documentation states
in the section about arrays (But I don't think this is different for any of the other compile-to-EVM languages):
Due to limitations of the EVM, it is not possible to return dynamic content from external function calls. The function f in contract C { function f() returns (uint[]) { ... } } will return something if called from web3.js, but not if called from Solidity.
The only workaround for now is to use large statically-sized arrays.
What exactly does this mean?
Say I have a very simple contract where people can push a number to the end of a publicly visible dynamic array.
- Can I return all values in this array when calling a `constant` function from the outside world or not?
- Can I return all values in this array when calling a function from another contract or not?
- Can I not read the dynamic array at all from outside that contract, and are therefore limited to return a fixed-size array and use pagination to iterate through the dynamic array as a whole?
Answers