Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Detrapping #67

Closed
2 of 92 tasks
AlexDaniel opened this issue Jul 17, 2019 · 1 comment
Closed
2 of 92 tasks

[WIP] Detrapping #67

AlexDaniel opened this issue Jul 17, 2019 · 1 comment
Assignees
Labels
fallback If no other label fits

Comments

@AlexDaniel
Copy link
Member

AlexDaniel commented Jul 17, 2019

The list is taken from this page: https://docs.perl6.org/language/traps

Separate tickets will be filed for some of the traps, and the discussion should take place there.

The goal is to investigate which traps are fixable and eventually get rid of them.

  • Variables and constants
    • Constants are computed at compile time
    • Assigning to Nil produces a different value, usually Any
    • Using a block to interpolate anon state vars
    • Using set subroutines on Associative when the value is falsy
  • Blocks
    • Beware of empty "blocks"
  • Objects
    • Assigning to attributes
    • BUILD prevents automatic attribute initialization from constructor arguments
  • Whitespace
    • Whitespace in regexes does not match literally
    • Ambiguities in parsing
      • Block vs. Hash slice ambiguity
      • Reduction vs. Array constructor ambiguity
      • Less than vs. Word quoting/Associative indexing
      • Exclusive sequences vs. sequences with Ranges
  • Captures
    • Containers versus values in a capture
  • Cool tricks
    • Strings are not List s, so beware indexing
    • List s become strings, so beware .index() ing
    • List s become strings, so beware .contains()
    • Numeric literals are parsed before coercion
    • Getting a random item from a List
    • List s numify to their number of elements in numeric context
  • Arrays
    • Referencing the last element of an array
    • Typed array parameters
    • Using «» quoting when you don't need it
  • Strings
    • Quotes and interpolation
    • Strings are not iterable
    • .chars gets the number of graphemes, not Codepoints
    • All text is normalized by default
    • Allomorphs generally follow numeric semantics
    • Case-insensitive comparison of strings
  • Pairs
    • Constants on the left-hand side of pair notation
    • Scalar values within Pair
  • Sets, bags and mixes
    • Sets, bags and mixes do not have a fixed order
  • Operators
    • Junctions
    • Exclusive sequence operator
    • String ranges/Sequences
    • Topicalizing operators
    • Fat arrow and constants
    • Infix operator assignment
  • Regexes
    • <{$x}> vs $($x) : Implicit EVAL
    • | vs || : which branch will win
    • $/ changes each time a regular expression is matched
    • vs. < foo> : named rules vs. quoted lists
    • Non-capturing, non-global matching in list context
  • Common precedence mistakes
    • Adverbs and precedence
    • Ranges and precedence
    • Loose boolean operators
    • Exponentiation operator and prefix minus
    • Method operator calls and prefix minus
  • Subroutine and method calls
    • Named parameters
    • Argument count limit
    • Phasers and implicit return
  • Input and output
    • Closing open filehandles and pipes
    • IO::Path stringification
    • Splitting the input data into lines
    • Proc::Async and print
    • Using .stdout without .lines
  • Exception handling
    • Sunk Proc
  • Using shortcuts
    • The ^ twigil
    • Using » and map interchangeably
    • Word splitting in « »
  • Scope
    • Using a once block
    • LEAVE phaser and exit
    • LEAVE phaser may run sooner than you think
  • Grammars
    • Using regexes within grammar's actions
    • Using certain names for rules/token/regexes
  • Unfortunate generalization
    • :exists with more than one key
    • Using […] metaoperator with a list of lists
    • Using [~] for concatenating a list of blobs
  • Maps
    • Beware of nesting Map s in sink context
    • Smartmatching
    • Smartmatch and WhateverCode
@AlexDaniel AlexDaniel added the fallback If no other label fits label Jul 17, 2019
@AlexDaniel AlexDaniel self-assigned this Jul 17, 2019
@AlexDaniel
Copy link
Member Author

This ticket was inspired by poor design decisions in Bash and the corresponding BashPitfalls page, except that I hoped that in Raku we would be able to improve things (instead of just documenting them, which is currently done somewhat poorly). For us the problem is in some sense worse because of the complexity of the language, but the current situation is somehow considered normal. I was thinking that we can slowly adjust the language so that it's more predictable, but there was a lot of resistance even during the attempts to document the issues. This ticket was then used just to seed the idea that we can make the language better instead of religiously defending it, but in retrospect I don't think I managed to change any minds. Of course, some problems will be resolved eventually (if not most of them). For example, .index and .contains on lists now print a warning instead of silently giving unexpected results. But the amount of changes that would make me satisfied will likely take years at that pace and given that I really didn't manage to do anything so far I guess I'll just leave it to somebody else. Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fallback If no other label fits
Projects
None yet
Development

No branches or pull requests

1 participant