charly-vm
charly-vm copied to clipboard
Iterator protocol
-
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
- When passed
-
Loop structures like the foor loop use the iterator protocol to iterate over all instance objects
Parsing and validation for this is currently broken, for x in y {} causes a compiler crash