onyx-lang / onyx

✨ The compiler and developer toolchain for Onyx
https://onyxlang.io
BSD 2-Clause "Simplified" License
576 stars 22 forks source link

Feature: Iterators use `? T` for return type #136

Closed brendanfh closed 7 months ago

brendanfh commented 7 months ago

This pull request changes how Iterator(T) yields its next value. It used to return a (T, bool), where it was understood that returning false would result in termination of the iteration and that the T value given should be ignored. This had needlessly complicated semantics and can be easily replaced with ? T as the return type, since ? T encodes the presence or absence of a value.