{"id":27197723,"url":"https://github.com/preaction/tie-iterator","last_synced_at":"2025-04-09T20:29:27.341Z","repository":{"id":16444067,"uuid":"19195793","full_name":"preaction/Tie-Iterator","owner":"preaction","description":"An experiment to use perl syntax and built-ins with iterators/generators","archived":false,"fork":false,"pushed_at":"2014-11-06T06:27:45.000Z","size":216,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-17T21:17:03.738Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/preaction.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-27T04:30:28.000Z","updated_at":"2024-04-17T21:17:03.739Z","dependencies_parsed_at":"2022-09-17T05:52:36.067Z","dependency_job_id":null,"html_url":"https://github.com/preaction/Tie-Iterator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preaction%2FTie-Iterator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preaction%2FTie-Iterator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preaction%2FTie-Iterator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/preaction%2FTie-Iterator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/preaction","download_url":"https://codeload.github.com/preaction/Tie-Iterator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248106813,"owners_count":21048800,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-09T20:29:26.786Z","updated_at":"2025-04-09T20:29:27.325Z","avatar_url":"https://github.com/preaction.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"NAME\n    Tie::Iterator - Work with an iterator like an array\n\nVERSION\n    version 0.001\n\nSYNOPSIS\n        tie my @iter, 'Tie::Iterator', sub { };\n        for my $item ( @iter ) {\n\n        }\n\nDESCRIPTION\n    This is an attempt to add a more-transparent iterator to Perl. The full\n    solution must work transparently in all useful list-type things:\n\n        for my $item ( @iter )\n        map { ... } @iter\n        grep { ... } @iter\n        sort { ... } @iter\n\nTREATISE\n  Why A Core Iterator?\n    while ( defined( my $i = $iter-\u003e() ) )\n        The current iterator pattern is unintuitive and requires a set of\n        iterator-specific functions to implement map, grep, and sort.\n\n        Iterator::Simple is the best way of doing iterators available on\n        CPAN, but it requires a CPAN module and so can only do what CPAN\n        modules can do. This isn't itself a reason for adding a core\n        iterator, but it should be considered.\n\n    A Better for ( \u003c$fh\u003e ) Pattern\n        New users often try to do a `for` loop over a filehandle and get\n        confused when it fails or performs poorly on very large files.\n        Another pattern that must be learned: \"while ( my $line = \u003c$fh\" )\u003e.\n\n        An \"iterable\" filehandle would allow while and for to be treated\n        equally.\n\n    Cannot be implemented on CPAN.\n        This module is an attempt to use \"tie\" to make an array that had an\n        iterator underneath. It fails because tied arrays cannot be returned\n        from subs, since only lists are allowed to be returned from subs.\n\n        It would work with an arrayref, but this is not transparent, and as\n        soon as the array being referenced is given to \"map\", \"grep\", \"for\",\n        \"sort\", or otherwise, the array is reduced to a list, which will run\n        the iterator until exhaustion.\n\n        Solving that problem doesn't make everything work, because an array\n        must know exactly how big they are before \"map\" or \"grep\" will work\n        on them. See t/iterator.t 'map iterator' for a failing test for\n        this. Since \"for\" allows modification of the array during iteration,\n        tied arrays work just fine.\n\n  Possible Syntax\n    Magic \"iterable\" flag on @array\n        If the magic flag is there, @array is really either a sub or a\n        filehandle.\n\n        This is both the most magic and the least amount of user work.\n\n        use feature qw( iterator ); my @iter = iterator { };\n            @array is now backed by an iterator.\n\n            \"gather\" is not used as the function name because we are not\n            implementing \"take\".\n\n        use feature qw( iterator ); my @iter = iterator $fh;\n            If the \"iterator\" gets a \"GLOB\" or IO::Handle, it does the right\n            thing.\n\n            In fact, most of Iterator::Simple's functionality could work\n            this way.\n\n        open my @fh, '\u003c', 'FILENAME'\n            @fh is now an iterable filehandle according to $/ at the time of\n            reading the next line.\n\n            This is currently allowed (is not a syntax error), and under \"no\n            strict \"refs\"\" creates a filehandle called \"0\".\n\n    \u003c@array\u003e\n        This is already used as a glob() operation, so this would be a\n        backwards- incompatible change. Evil.\n\n    @\u0026array or \u0026@array\n        The first one is a syntax error currently. The second can sometimes\n        be interpreted as bitwise-\"\u0026 @array\".\n\n  Difficulties\n    *   XS code that works with arrays may need to handle iterables\n        differently, especially with the magic version.\n\n        This would break the abstraction quite impressively, and a leaky\n        abstraction is frequently worse than no abstraction at all...\n\nAUTHOR\n    Doug Bell \u003cpreaction@cpan.org\u003e\n\nCOPYRIGHT AND LICENSE\n    This software is copyright (c) 2014 by Doug Bell.\n\n    This is free software; you can redistribute it and/or modify it under\n    the same terms as the Perl 5 programming language system itself.\n\nPOD ERRORS\n    Hey! The above document had some coding errors, which are explained\n    below:\n\n    Around line 189:\n        '=item' outside of any '=over'\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreaction%2Ftie-iterator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpreaction%2Ftie-iterator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreaction%2Ftie-iterator/lists"}