-
Notifications
You must be signed in to change notification settings - Fork 5
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
qw Word quoting returns Str with one word #46
Comments
The behavior is due to the Single Argument Rule. Not to say that it isn't confusing at first, or that the docs for quoting constructs don't mention it. It is confusing if you don't know why, and the docs don't cover every possible situation. Single Argument Rule is one of those thing along the DWIM / WAT continuum. It mostly exists to make things like below work more how most people expect. (When coming from a Perl background. Which is what Raku was primarily catering to for the first 10 years or so.)
with the single argument rule:
without, it would be:
( @b would contain one item in slot 0 - the array [1,2,3] ) For a qw<> construct it shouldn't really be an issue. You won't ever get anything other than what is in there. If you know you will need a Positional and you only have one item, either use a different quoting form or explicitly coerce. When using qqw<> constructs that interpolate, you probably should explicitly coerce because you may not know how many items will be returned. Probably not a bad idea to always explicitly coerce anyway.
|
How to declare my own quoting construct? I figured out that I can do |
The documentation says that
qw
split input into words.However...
Example showing why this is problematic
test.raku:
Even worse: (because you cannot use
*@pos
)Some error here.
The text was updated successfully, but these errors were encountered: