charly-vm icon indicating copy to clipboard operation
charly-vm copied to clipboard

Iterator protocol

Open KCreate opened this issue 3 years ago • 1 comments

  • Iterators for data structures are created by calling the iterator(old = null) method declared on every instance

    • When passed null, the initial iterator is created
    • When passed an iterator as an argument, the iterator gets incremented to the next position, the method returns the updated iterator
    • When the iterator method returns null, the iterator has finished
    • The value of the iterator can be accessed via the iterator_value(iterator) method
  • Loop structures like the foor loop use the iterator protocol to iterate over all instance objects

KCreate avatar Mar 30 '22 19:03 KCreate

Parsing and validation for this is currently broken, for x in y {} causes a compiler crash

KCreate avatar Jul 27 '22 22:07 KCreate