Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
51 lines (31 sloc) 1.4 KB

Use whitespace around infix operators

Example

Write 1 + 1 instead of 1+1.

Rationale

Perl 6 has a very rich grammar, and in some cases whitespace disambiguates certain constructs. While 1+1 does what you mean, 1<2 does not. Without a blank between the 1 and the <, the latter is parsed as a postcircumfiix, just like in %hash<key>. It is therefore recommended to always use whitespace on both side of an infix operator.

Exceptions

If you write lists, 1, 2, 3 is much more readable than 1 , 2 , 3. So in the case of the comma operator, stick to conventional spacing style.

Champions

moritz, masak

Do not base your design on junctions and autothreading

Example

TODO

Rationale

Junctions and the associated autothreading fascinate newcomers. Sometimes they want to base an entire system design on junctions (for example solving equations or systems related to declarative programming).

Since junctions are not meant to represent sets, this is usually a bad idea; debugging code with junctions is hard, and often confusing to read.

So the author recommmends to use junctions only locally, as in if $x eq 'a' | 'z' { ... }, or for matchers such as arguments to grep, first or when.

Exceptions

None known yet; Note that this rule does not mean "do not use junctions"; see previous section.

Champion

moritz, masak