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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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! |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
+1 on this. Mind sending a PR to change it throughout the whole repo? I'd be in support for it.
There was a problem hiding this comment.
Yup, it's a good idea.
|
|
||
| my @cities = ("Athens", "Roma", "London", "Beijing", "Kiev", "Riga"); | ||
|
|
||
| my $f = sub {return scalar @_;}; |
There was a problem hiding this comment.
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); | ||
|
|
| @@ -0,0 +1,4 @@ | |||
| #!/usr/bin/perl | |||
|
|
|||
| print "Actually, perl cant introspect functions :(\n"; | |||
There was a problem hiding this comment.
So... I'd say we don't need this file at all, right?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Maybe you should change the filename in this case.
There was a problem hiding this comment.
Maybe you should change the filename in this case.
This comment is still unaddressed.
| return $a + $b; | ||
| } | ||
|
|
||
| # declarement of package is between package statements. |
|
|
||
| use strict; | ||
| use Data::Dumper; | ||
| # i take the responsibility to rename this chapter too |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
| use strict; | ||
| use v5.10; | ||
|
|
||
|
|
| @@ -0,0 +1,4 @@ | |||
| #!/usr/bin/perl | |||
|
|
|||
| print "Actually, perl cant introspect functions :(\n"; | |||
There was a problem hiding this comment.
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"; | ||
|
|
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Maybe you should change the filename in this case.
This comment is still unaddressed.
| # everytime shift is called inside a function without array passed to it | ||
| # 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 |
| @@ -1,4 +0,0 @@ | |||
| #!/usr/bin/perl | |||
There was a problem hiding this comment.
Can you please update the names of the other files so that there are no gaps in the ordering?
495ce31 to
90728b6
Compare
there is always more than one way to do it.
Somewhere perl lacks functionality, so i try to propose (readable) analogues.