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

http://doc.perl6.org/routine/spurt: example lacks ':' #427

Closed
jkeenan opened this issue Mar 19, 2016 · 3 comments
Closed

http://doc.perl6.org/routine/spurt: example lacks ':' #427

jkeenan opened this issue Mar 19, 2016 · 3 comments
Labels
docs Documentation issue (primary issue type)

Comments

@jkeenan
Copy link

jkeenan commented Mar 19, 2016

$ perl6
> my $filename = 'enc_missing_colon.txt'
enc_missing_colon.txt
> say $filename, "latin1 text: äöüß", enc => 'latin1';
Unexpected named parameter 'enc' passed
> say $filename, "latin1 text: äöüß", :enc => "latin1";
enc_missing_colon.txtlatin1 text: äöüß(enc => True) => latin1
> exit

The example for use of :enc lacks a colon before enc.

coke added a commit that referenced this issue Apr 17, 2016
@coke coke closed this as completed Apr 17, 2016
@timo
Copy link
Contributor

timo commented Apr 17, 2016

actually,

timo@schmand /tmp> perl6 -e 'spurt "test.txt", "latin1: äöüß", enc => "latin1"'
timo@schmand /tmp> cat test.txt 
latin1: ����⏎
timo@schmand /tmp> perl6 -e 'spurt "test2.txt", "latin1: äöüß", :enc => "latin1"'
Too many positionals passed; expected 1 argument but got 2
  in block <unit> at -e line 1

@timo timo reopened this Apr 17, 2016
@MadcapJake
Copy link
Contributor

MadcapJake commented Apr 17, 2016

@jkeenan this does not need a colon. In your example, you see that you are actually concatenating something quite bizarre (say just concatenates all arguments)
enc => 'latin1 will create a pair with a string key enc and since (1) unquoted or non-coloned string keys will trigger named argument checking and (2) say doesn't accept any named arguments called enc, the code fails. So when you changed it to :enc => 'latin1' you actually are creating a pair with a key that is a pair:
(enc => True) => 'latin1'
Because routines only check for named arguments in the non-quoted or coloned form, say just assumes you want to concatenate the string representation of the pair.

timo added a commit that referenced this issue Apr 17, 2016
This reverts commit e6c92f4.

As discussed in the issue #427, this wasn't correct.
@timo
Copy link
Contributor

timo commented Apr 17, 2016

i should also point out that the issue is about the documentation of spurt and the example code in the initial comment is about say. spurt has the :enc parameter, whereas say doesn't. and say also doesn't take a filehandle as the first argument. That's probably where the confusion came from?

Anyway, with the commit reverted I'm going to close this issue again.

@timo timo closed this as completed Apr 17, 2016
@AlexDaniel AlexDaniel added the docs Documentation issue (primary issue type) label Jun 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation issue (primary issue type)
Projects
None yet
Development

No branches or pull requests

5 participants