Perl 5 implementation #4
Conversation
|
Oh gosh... Perl. I don't even know who can review this. |
| } | ||
| # everytime shift is called inside a function without array passed to shift operator | ||
| # it returns next argument | ||
| # note that shift is an operator, so it thinks of things next to it as of its arguments |
aqrln
Jun 9, 2017
Contributor
Can you please wrap the comment at 80 characters?
Can you please wrap the comment at 80 characters?
| sub inc1 { | ||
| return 1 + shift; | ||
| } | ||
| # everytime shift is called inside a function without array passed to shift operator |
aqrln
Jun 9, 2017
Contributor
I believe it is better to have these comments above the corresponding functions, not below them.
I believe it is better to have these comments above the corresponding functions, not below them.
| print inc2(2); # returns 3 | ||
| print inc3(2); # returns 2 (look in comments near function definition) | ||
| print sum(1, 2); # returns 3 | ||
| #print sum(1, 2, 3); # produces an error. Uncomment and try it! |
aqrln
Jun 9, 2017
Contributor
I'd find it prettier to have a space after the hash.
I'd find it prettier to have a space after the hash.
|
|
||
| use strict; | ||
| # in original repo this file is named "context" | ||
| # i take the responsibility to rename it to "scopes" |
aqrln
Jun 9, 2017
Contributor
+1 on this. Mind sending a PR to change it throughout the whole repo? I'd be in support for it.
+1 on this. Mind sending a PR to change it throughout the whole repo? I'd be in support for it.
ffluffyhedgehog
Jun 9, 2017
Author
Contributor
Yup, it's a good idea.
Yup, it's a good idea.
|
|
||
| my @cities = ("Athens", "Roma", "London", "Beijing", "Kiev", "Riga"); | ||
|
|
||
| my $f = sub {return scalar @_;}; |
aqrln
Jun 9, 2017
Contributor
I find it more readable to have extra surrounding spaces inside the braces, but feel free to ignore this comment if the current style is idiomatic in Perl.
I find it more readable to have extra surrounding spaces inside the braces, but feel free to ignore this comment if the current style is idiomatic in Perl.
| orDef(1, 2); | ||
| orDef(1); | ||
| orDef(1, 0); | ||
|
|
aqrln
Jun 9, 2017
Contributor
Ditto.
Ditto.
| @@ -0,0 +1,4 @@ | |||
| #!/usr/bin/perl | |||
|
|
|||
| print "Actually, perl cant introspect functions :(\n"; | |||
aqrln
Jun 9, 2017
Contributor
So... I'd say we don't need this file at all, right?
So... I'd say we don't need this file at all, right?
aqrln
Jun 9, 2017
•
Contributor
So... I'd say we don't need this file at all, right?
This comment is still unaddressed.
So... I'd say we don't need this file at all, right?
This comment is still unaddressed.
| use Data::Dumper; | ||
| # spread operator is not needed in perl | ||
| # because only way for us to get our params is through array | ||
| # but i'll show how to iterate through params |
aqrln
Jun 9, 2017
Contributor
Maybe you should change the filename in this case.
Maybe you should change the filename in this case.
aqrln
Jun 9, 2017
•
Contributor
Maybe you should change the filename in this case.
This comment is still unaddressed.
Maybe you should change the filename in this case.
This comment is still unaddressed.
| return $a + $b; | ||
| } | ||
|
|
||
| # declarement of package is between package statements. |
aqrln
Jun 9, 2017
Contributor
s/declarement/declaration
s/declarement/declaration
|
|
||
| use strict; | ||
| use Data::Dumper; | ||
| # i take the responsibility to rename this chapter too |
aqrln
Jun 9, 2017
Contributor
Don't worry about renaming. These files are not meant to copy the extract structure of the JavaScript samples. To the contrary, I find it detrimental that most people are doing exactly that thing instead of writing pieces of idiomatic code in a given language from scratch.
Don't worry about renaming. These files are not meant to copy the extract structure of the JavaScript samples. To the contrary, I find it detrimental that most people are doing exactly that thing instead of writing pieces of idiomatic code in a given language from scratch.
|
I hope now it's ready. |
| use strict; | ||
| use v5.10; | ||
|
|
||
| # everytime shift is called inside a function without array passed to shift operator |
aqrln
Jun 9, 2017
Contributor
Please wrap the line at 80 characters.
Please wrap the line at 80 characters.
|
|
||
| # everytime shift is called inside a function without array passed to shift operator | ||
| # it returns next argument | ||
| # note that shift is an operator, so it thinks of things next to it as of its arguments |
aqrln
Jun 9, 2017
Contributor
Ditto.
Ditto.
| use strict; | ||
| use v5.10; | ||
|
|
||
|
|
aqrln
Jun 9, 2017
Contributor
Redundant empty line.
Redundant empty line.
| @@ -0,0 +1,4 @@ | |||
| #!/usr/bin/perl | |||
|
|
|||
| print "Actually, perl cant introspect functions :(\n"; | |||
aqrln
Jun 9, 2017
•
Contributor
So... I'd say we don't need this file at all, right?
This comment is still unaddressed.
So... I'd say we don't need this file at all, right?
This comment is still unaddressed.
| #!/usr/bin/perl | ||
|
|
||
| print "Actually, perl cant introspect functions :(\n"; | ||
|
|
aqrln
Jun 9, 2017
•
Contributor
A superfluous empty line. The text files in Unix are supposed to have one empty line at the end, not two of them :)
This comment is still unaddressed.
A superfluous empty line. The text files in Unix are supposed to have one empty line at the end, not two of them :)
This comment is still unaddressed.
| use Data::Dumper; | ||
| # spread operator is not needed in perl | ||
| # because only way for us to get our params is through array | ||
| # but i'll show how to iterate through params |
aqrln
Jun 9, 2017
•
Contributor
Maybe you should change the filename in this case.
This comment is still unaddressed.
Maybe you should change the filename in this case.
This comment is still unaddressed.
| # it returns next argument | ||
| # note that shift is an operator, so it thinks of things next to it as of its arguments | ||
| # note that shift is a fucntion that awaits arguments |
aqrln
Jun 10, 2017
Contributor
s/fucntion/function
s/fucntion/function
| @@ -1,4 +0,0 @@ | |||
| #!/usr/bin/perl | |||
aqrln
Jun 10, 2017
Contributor
Can you please update the names of the other files so that there are no gaps in the ordering?
Can you please update the names of the other files so that there are no gaps in the ordering?
495ce31
to
90728b6
516d3a6
to
a2f04c4
there is always more than one way to do it.
Somewhere perl lacks functionality, so i try to propose (readable) analogues.