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

[FEATURE] Iterators #486

Open
1 task done
gvwilson opened this issue Dec 26, 2021 · 3 comments
Open
1 task done

[FEATURE] Iterators #486

gvwilson opened this issue Dec 26, 2021 · 3 comments
Labels
feature request Discussion about a new feature

Comments

@gvwilson
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem?

C-style for loops are more complex for novice programmers to work with than iterator-based loops (it's one of the reasons the latter were added to Python).

Describe the solution you'd like

Wren-style iterators's would be relatively straightforward to add to Dictu; I'd be happy to help with implementation and testing.

Describe alternatives you've considered

No response

Additional context

I'm looking for a teaching language the size of Python as it was in the early 2000s or Pascal as it was in the early 1980s; Dictu seems promising. I'd be happy to chat - https://third-bit.com/ for contact details.

@gvwilson gvwilson added the feature request Discussion about a new feature label Dec 26, 2021
@Jason2605
Copy link
Member

Iterator based loops I think would be a nice addition. Things like .forEach are in the language which I find can be slightly easier to reason than standard C-style loops but they're a bit bare at the moment (and need to be implemented manually for each data type).

If we can make it more generic (kinda like Wren in that it has .iterate / .iterateValue methods (if memory serves)) that would be much better, and allow users to define custom iterators.

@gvwilson
Copy link
Contributor Author

I think a Wren/Python-style iteration protocol would be straightforward, and would move a few things out of the compiler/VM into user space. What I don't understand is how that would interact with fibers (assuming they're added): a readline iterator would probably want to be written as a wrapper around call/yield, which would require some careful thought, and given how I much I had for dinner last night, careful thought isn't on today's menu :-)

@Jason2605
Copy link
Member

given how I much I had for dinner last night, careful thought isn't on today's menu :-)

Haha, hope you had a good Christmas if you celebrate it!

Yeah I think there's probably a few places which may need some thought with regards to fibers, but I still think given all the types of concurrency models there are this is probably the best choice for Dictu.

I think even a naive implementation for IO where it blocks as it reads and returns an iterator object is perfectly fine, especially for now (unless you meant something different and I misunderstood?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Discussion about a new feature
Projects
None yet
Development

No branches or pull requests

2 participants