Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • pike pike
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 105
    • Issues 105
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • pikelang
  • pikepike
  • Issues
  • #10085
Closed
Open
Issue created Jul 20, 2022 by Henrik (Grubba) Grubbström@grubbaMaintainer

Adjust Iterator API to be more simple to implement and simpler to generate code for.

With the current (Pike 8.0) iterator API, the iterator starts at the first item, which means that foreach() needs to do something like:

  if (!!(iter)) { // Calls lfun::`!().
    do {
      mixed ind = iter->index();
      mixed val = iter->value();

      // Body

    } while (iter->next());
  }

Changing it so that iterators start before the first item simplifies the code:

  while(iter->_iterator_next()) {
    mixed ind = iter->_iterator_index();
    mixed val = iter->_iterator_value();

    // Body
  }

Also consider supporting having _iterator_next() return the current index if there is no _iterator_index().

Note that this change naturally requires having the compiler add a backward compat implementation of _iterator_next() for old-style iterators.

Assignee
Assign to
Time tracking