guppylang
guppylang copied to clipboard
Prelude: `next` and `iter`
i.e. that allow you to manually iterate through a list, rather than using for.
While iter probably just needs a custom checker/compiler that calls __iter__(), next needs to be a bit more complicated to handle the failure case - what does next do to handle __hasnext__ returning false? (I.e. we need either an Optional return type, which would be pythonic, or else make next panic and then provide some way for client to call __hasnext__ first...)
Longer term we should just get rid of __hasnext__ and make __next__ return an option type. However, this requires enums or some other ways to encode sums in the language.
See #96