Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prelude: next and iter #502

Open
acl-cqc opened this issue Sep 16, 2024 · 1 comment
Open

Prelude: next and iter #502

acl-cqc opened this issue Sep 16, 2024 · 1 comment

Comments

@acl-cqc
Copy link
Contributor

acl-cqc commented Sep 16, 2024

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...)

@mark-koch
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants