Any update on Arrays?

SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
I need my arrays, whats the status?

**Apologies for impatients.
**Gav & Team, Solidity is a real pleasure to code on, great work.


  • StephanTualStephanTual London, EnglandMember, Moderator Posts: 1,282 mod
    edited January 2015
    Probably not the answer you wanted to hear, but sadly this is currently not a priority - we might see it appear in future versions of Solidity though, as changes to the higher level languages do not require hardforks.
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    As a prototyping solution, should mapping (uints to something) with a uint count be used instead? I understand miners can re-order transactions, so will using this method be a safe solution?
  • KenKKenK Member Posts: 44 admin
    mappings offer basically the same functionality - however mappings are can be any size and there address in storage is calculated using sha3. I am not sure I understand the second part of your question?
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    edited January 2015
    uint num_orders;
    mapping (uint => string32) orders;
    function submit_order(string32 name) returns (uint id)
        id = num_orders++;
        orders[id] = name;
    @‌KenK When orders are submited, could a miner reorder submit_order transactions so that some orders go before other orders (front-run orders)? My understanding is that they can.
  • chrisethchriseth Member Posts: 170 ✭✭✭
    If two orders are submitted from two accounts in separate transactions, miners have to find an order of the transactions. Note that they are free to choose how to order the transactions and that there is no intrinsically "correct" order.
    But this question is independent from how to model arrays in Solidity...
    The way you did it involves a hash computation for each access to the array. On the other hard, this makes it quite safe as it is hard to get storage address collisions.
  • SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
    @chriseth, thanks for clearing that up. I'll stick with the mapping and count option then. Cheers.
Sign In or Register to comment.