{"id":13733931,"url":"https://github.com/scriptkitties/perl6-style-guide","last_synced_at":"2025-04-07T19:31:33.988Z","repository":{"id":80058797,"uuid":"118324195","full_name":"scriptkitties/perl6-style-guide","owner":"scriptkitties","description":null,"archived":false,"fork":false,"pushed_at":"2018-01-21T11:20:28.000Z","size":10,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T23:11:19.461Z","etag":null,"topics":["perl6","styleguide"],"latest_commit_sha":null,"homepage":null,"language":null,"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/scriptkitties.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"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}},"created_at":"2018-01-21T10:18:05.000Z","updated_at":"2018-07-05T11:57:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"bb9e3e56-dcb4-4baf-817c-cb69614eefea","html_url":"https://github.com/scriptkitties/perl6-style-guide","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/scriptkitties%2Fperl6-style-guide","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptkitties%2Fperl6-style-guide/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptkitties%2Fperl6-style-guide/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptkitties%2Fperl6-style-guide/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scriptkitties","download_url":"https://codeload.github.com/scriptkitties/perl6-style-guide/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247716281,"owners_count":20984211,"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":["perl6","styleguide"],"created_at":"2024-08-03T03:00:51.040Z","updated_at":"2025-04-07T19:31:33.670Z","avatar_url":"https://github.com/scriptkitties.png","language":null,"funding_links":[],"categories":["Introduction"],"sub_categories":["First Steps"],"readme":"= Perl 6 Style Guide\n:toc: preamble\n\nThis is a styleguide for writing https://perl6.org/[Perl 6] code. It's still in\nit's early stages, and feedback would be greatly appreciated. Also note that\nthis is a set of rules for https://scriptkitties.church[Scriptkitties]\nprojects, not necesarily for you.\n\n== Meta\n=== Module hierarchy\nModules should keep the following hierarchy in their root directory:\n\n- `bin` for executable files, if any.\n- `lib` for the actual source of the module.\n- `t` for tests\n- `resources` for additional resources\n\n==== Source file name extensions\nPerl 6 source files must use `.pm6` and `.pl6` as extensions to properly\nindicate they are Perl 6 files, and not Perl 5.\n\n=== Shebang\nAll Perl 6 source files must have a\nhttps://en.wikipedia.org/wiki/Shebang_(Unix)[shebang]. For scripts that are\nintended to be executed as programs, this would be the following:\n\n[souce,sh]\n----\n#! /usr/bin/env perl6\n----\n\n*Never* refer to a hardcoded perl6 path, as this is likely to break on the\nsetups of others.\n\nFor modules that are *not* intended to be ran as a standalone program, the\nfollowing shebang is to be used:\n\n[source,sh]\n----\n#! /usr/bin/env false\n----\n\nThis will ensure the script won't be ran as a standalone program. If it's\nincluded by a program as a module, the shebang is simply interpreted as a\ncomment, and thus ignored.\n\n=== `use` for the Perl 6 version\nEvery script must have a `use` statement to indicate which version of Perl 6 is\nbeing used:\n\n[source,perl6]\n----\nuse v6.c;\n----\n\n=== Indentation style\nThe preferred indentation style for Scriptkitties projects is to use **tabs**\nfor indention. If you need to *align* things, however, you should use spaces:\n\n[source,perl6]\n----\nsub foo (\n\t%bar,\n) {\n\t%bar\u003csome-index\u003e    = \"Some string\";\n\t%bar\u003canother-index\u003e = \"Another string\";\n}\n----\n\nAligning code is *not* required, but is allowed if you think it will improve\nreadability of the code.\n\n=== Line length\nLines in Perl 6 source files should not extend the *120 character* mark.\nExceptions for this are cases where the source is easier to understand by\nsurpassing the 120 character limit.\n\n=== Unicode operators\nUnicode operators should be used in favour of the longer ASCII operators.\nDepending on your editor, plugins may already be available that convert them on\nthe fly:\n\n- https://github.com/vim-perl/vim-perl[vim]\n\n== Documentation\n=== POD comments\nApply POD comments to your subs. A small description on the method should go\ndirectly above it, and descriptions on the arguments should go above the\narguments themself:\n\n[source,perl6]\n----\n#| A small description on the sub foo. This is returned on foo.WHY.\nsub foo (\n\t#| What to expect of the bar argument\n\tStr:D $bar,\n) is export {\n\t…\n}\n----\n\n== Styles to avoid\n=== `else`\nUsing an `else` is almost never necesary, yet they add a lot of cognitive load\nto the source code. As such, you should try to write your code in such a way\nthat an `else` is not necessary. If you do find a circumstance that you *must*\nuse an `else` block, the `else` must go on the same line as the closing `}` of\nthe foregoing `if`:\n\n[NOTE]\n====\nThis is still open for discussion!\n====\n\n[source,perl6]\n----\nif ($some-condition) {\n\t…\n} else {\n\t…\n}\n----\n\n=== Misc\n\n* Avoid using $_, unless needed.\n[source,perl6]\n----\nfor @array -\u003e $element { # good\n\tsay $element;\n}\nfor @array {\n\t.say # good\n}\n.say for @array; # better\n----\n\n* Declare constants with my, otherwise they are **automatically** *exported* by any module that uses it.\n[source,perl6]\n----\nconstant CONST = 10; # BAD\nmy constant CONST = 10; # good\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscriptkitties%2Fperl6-style-guide","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscriptkitties%2Fperl6-style-guide","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscriptkitties%2Fperl6-style-guide/lists"}