Skip to content

Agreeing on doc, and doc contribution style guide, about hash construction; {...}, %(...), hash(), ... #2117

Closed
@Juerd

Description

@Juerd

The problem

The style guide suggests using {} for empty hashes and %() for non-empty hashes. This is inconsistent.

Suggestions

Since {} is considered confusing (although technically it's supposed to be straight forward) with blocks, and empty %() is considered a trap (see rakudo/rakudo#1946), why not just use hash instead? According to jnthn in rakudo/rakudo#1946 (comment) these are a "sure bet".

Suggested: avoid both %() (empty construct is a trap) and {} (possible confusion with blocks) for constructing hashes, and always use hash instead:

my $foo = hash;  # empty hash
my $bar = hash a => 'b', c => 'd';  # non-empty hash

Note: these can be used with or without parentheses. Since that goes for most expressions, that could probably use its own recommendation in the style guide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    metaRFCs, general discussion, writing style, repository organization, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions