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

Iterator exceptions #2009

Closed
wants to merge 4 commits into from
Closed

Iterator exceptions #2009

wants to merge 4 commits into from

Conversation

sydow
Copy link
Collaborator

@sydow sydow commented Nov 29, 2024

Changes iterators so that they throw exception StopIteration at termination (rather than returning None).

As a consequence, the Iterator class in builtin.act his now defined by

class Iterator[A] (object):
next : () -> A

(previously the return type was ?A)

@plajjan
Copy link
Contributor

plajjan commented Dec 11, 2024

This is failing CI testing because of the changes to max() I think. It's the same problem as for pop etc in #1986. I said I would work on that to split the change in two parts. I think I can do the same for this PR. As things currently look, I will have some spare cycles early next week.

@plajjan plajjan force-pushed the iterator_exceptions branch 5 times, most recently from 96601ea to e2813f7 Compare December 15, 2024 21:37
Temporarily back out the change of removing default value to max & min
since it breaks existing code. We should only introduce the next max_def
& min_def functions, switch over to using them and once that is done we
can change min & max.
@plajjan
Copy link
Contributor

plajjan commented Dec 15, 2024

This PR has some bug, not sure where. After I have fixed max / max_def, the functionality of Acton programs should be identical before and after this branch, yet, when I do make gen in the respnet repo, it generates entirely different code, indicating that somewhere we have an actual difference in behavior. I suppose it's best if I can find a smaller reproduction.. easier said than done.

@plajjan plajjan force-pushed the iterator_exceptions branch from e2813f7 to 446db37 Compare December 15, 2024 22:07
@sydow
Copy link
Collaborator Author

sydow commented Dec 16, 2024 via email

@plajjan
Copy link
Contributor

plajjan commented Dec 16, 2024

@sydow respnet is https://github.com/orchestron-orchestrator/respnet/ - in that repo is a code generation step that can be run with make gen. The currently generated code (that is checked in) was run on acton main - and I expect the same code to be generated using this branch. You agree with this, right? This PR is not supposed to alter control flow in programs, right?

However, the generated code does change and so I can only conclude that this PR does alter control flow somehow.

@plajjan
Copy link
Contributor

plajjan commented Dec 16, 2024

I have created #2023 which effectively supersedes this PR.

It includes your code @sydow but:

  • is rebased on latest main branch, since this PR has conflicts
    • the conflicts are because I added min_def & max_def to the main branch, so we can do a soft-transition in other projects
  • I changed back the min() and max() functions so they still take a default argument - this way, we avoid changing too many things in - instead we just focus on the StopIteration part and leave the change to min / max for a second PR
  • I did squash in my changes - maybe this was a mistake, but I thought it was easier to see the changes like this

@plajjan
Copy link
Contributor

plajjan commented Dec 16, 2024

Closing this, see #2023 instead!

@plajjan plajjan closed this Dec 16, 2024
@plajjan plajjan deleted the iterator_exceptions branch January 13, 2025 20:24
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

Successfully merging this pull request may close these issues.

3 participants