{"id":16315202,"url":"https://github.com/robrwo/perlx-let","last_synced_at":"2025-04-04T10:45:37.611Z","repository":{"id":56830200,"uuid":"169770251","full_name":"robrwo/PerlX-Let","owner":"robrwo","description":"Syntactic sugar for lexical constants","archived":false,"fork":false,"pushed_at":"2023-06-14T20:35:01.000Z","size":49,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T20:45:44.516Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robrwo.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-08T17:09:25.000Z","updated_at":"2023-06-14T20:35:06.000Z","dependencies_parsed_at":"2024-12-17T13:41:48.448Z","dependency_job_id":"0b76a78e-23f5-4e22-a2ad-20dd3d8d8bec","html_url":"https://github.com/robrwo/PerlX-Let","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FPerlX-Let","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FPerlX-Let/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FPerlX-Let/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robrwo%2FPerlX-Let/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robrwo","download_url":"https://codeload.github.com/robrwo/PerlX-Let/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166149,"owners_count":20894652,"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":"2024-10-10T21:56:29.892Z","updated_at":"2025-04-04T10:45:37.588Z","avatar_url":"https://github.com/robrwo.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME\n\nPerlX::Let - Syntactic sugar for lexical state constants\n\n# VERSION\n\nversion v0.3.0\n\n# SYNOPSIS\n\n```perl\nuse PerlX::Let;\n\n{\n\n    let $x = 1;\n    let $y = \"string\";\n\n    if ( ($a-\u003e($y} - $x) \u003e ($b-\u003e{$y} + $x) )\n    {\n      something( $y, $x );\n    }\n\n}\n```\n\n# DESCRIPTION\n\nThis module allows you to define lexical constants using a new `let`\nkeyword, for example, code such as\n\n```perl\nif (defined $arg{username}) {\n  $row-\u003eupdate( { username =\u003e $arg{username} );\n}\n```\n\nis liable to typos. You could simplify it with\n\n```perl\n{\n    let $key = \"username\";\n\n    if (defined $arg{$key}) {\n        $row-\u003eupdate( { $key =\u003e $arg{$key} );\n    }\n\n}\n```\n\nThis is roughly equivalent to using\n\n```perl\nuse Const::Fast ();\n\n{\n    use feature 'state';\n\n    state $key = \"username\";\n\n    unless (state $_flag = 0) {\n        Const::Fast::_make_readonly( \\$key );\n        $_flag = 1;\n    }\n\n    if (defined $arg{$key}) {\n        $row-\u003eupdate( { $key =\u003e $arg{$key} );\n    }\n\n}\n```\n\nHowever, if the value contains a sigil, or (for versions of Perl\nbefore 5.28) the value is not a scalar, then this uses a my variable\n\n```perl\nuse Const::Fast ();\n\n{\n    Const::Fast::const my $key =\u003e \"username\";\n\n    if (defined $arg{$key}) {\n        $row-\u003eupdate( { $key =\u003e $arg{$key} );\n    }\n}\n```\n\nThe reason for using state variables is that it takes time to mark a\nvariable as read-only, particularly for deeper data structures.\nHowever, the tradeoff for using this is that the variables remain\nallocated until the process exits.\n\n# KNOWN ISSUES\n\nA let assignment will enable the state feature inside of the current\ncontext.\n\nThe parsing of assignments is rudimentary, and may fail when assigning\nto another variable or the result of a function.  Because of this,\nyou may get unusual error messages for syntax errors, e.g.\n\"Transliteration pattern not terminated\".\n\nBecause this modifies the source code during compilation, the line\nnumbers may be changed, particularly if the let assignment(s) are on\nmultiple lines.\n\n# SUPPORT FOR OLDER PERL VERSIONS\n\nThe this module requires Perl v5.12 or later.\n\nFuture releases may only support Perl versions released in the last ten years.\n\n# SEE ALSO\n\n[feature](https://metacpan.org/pod/feature)\n\n[Const::Fast](https://metacpan.org/pod/Const%3A%3AFast)\n\n[Keyword::Simple](https://metacpan.org/pod/Keyword%3A%3ASimple)\n\n# AUTHOR\n\nRobert Rothenberg \u003crrwo@cpan.org\u003e\n\n# COPYRIGHT AND LICENSE\n\nThis software is Copyright (c) 2019-2023 by Robert Rothenberg.\n\nThis is free software, licensed under:\n\n```\nThe Artistic License 2.0 (GPL Compatible)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobrwo%2Fperlx-let","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobrwo%2Fperlx-let","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobrwo%2Fperlx-let/lists"}