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

Perl 5 implementation #4

Open
wants to merge 7 commits into
base: master
from

Conversation

@ffluffyhedgehog
Copy link
Contributor

@ffluffyhedgehog ffluffyhedgehog commented Jun 8, 2017

there is always more than one way to do it.

Somewhere perl lacks functionality, so i try to propose (readable) analogues.

@aqrln
Copy link
Contributor

@aqrln aqrln commented Jun 8, 2017

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

This comment has been minimized.

@aqrln

aqrln Jun 9, 2017
Contributor

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

This comment has been minimized.

@aqrln

aqrln Jun 9, 2017
Contributor

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!

This comment has been minimized.

@aqrln

aqrln Jun 9, 2017
Contributor

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"

This comment has been minimized.

@aqrln

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.

This comment has been minimized.

@ffluffyhedgehog

ffluffyhedgehog Jun 9, 2017
Author Contributor

Yup, it's a good idea.


my @cities = ("Athens", "Roma", "London", "Beijing", "Kiev", "Riga");

my $f = sub {return scalar @_;};

This comment has been minimized.

@aqrln

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.

orDef(1, 2);
orDef(1);
orDef(1, 0);

This comment has been minimized.

@aqrln

aqrln Jun 9, 2017
Contributor

Ditto.

@@ -0,0 +1,4 @@
#!/usr/bin/perl

print "Actually, perl cant introspect functions :(\n";

This comment has been minimized.

@aqrln

aqrln Jun 9, 2017
Contributor

So... I'd say we don't need this file at all, right?

This comment has been minimized.

@aqrln

aqrln Jun 9, 2017
Contributor

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

This comment has been minimized.

@aqrln

aqrln Jun 9, 2017
Contributor

Maybe you should change the filename in this case.

This comment has been minimized.

@aqrln

aqrln Jun 9, 2017
Contributor

Maybe you should change the filename in this case.

This comment is still unaddressed.

return $a + $b;
}

# declarement of package is between package statements.

This comment has been minimized.

@aqrln

aqrln Jun 9, 2017
Contributor

s/declarement/declaration


use strict;
use Data::Dumper;
# i take the responsibility to rename this chapter too

This comment has been minimized.

@aqrln

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.

@ffluffyhedgehog
Copy link
Contributor Author

@ffluffyhedgehog ffluffyhedgehog commented Jun 9, 2017

I hope now it's ready.

use strict;
use v5.10;

# everytime shift is called inside a function without array passed to shift operator

This comment has been minimized.

@aqrln

aqrln Jun 9, 2017
Contributor

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

This comment has been minimized.

@aqrln

aqrln Jun 9, 2017
Contributor

Ditto.

use strict;
use v5.10;


This comment has been minimized.

@aqrln

aqrln Jun 9, 2017
Contributor

Redundant empty line.

@@ -0,0 +1,4 @@
#!/usr/bin/perl

print "Actually, perl cant introspect functions :(\n";

This comment has been minimized.

@aqrln

aqrln Jun 9, 2017
Contributor

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";

This comment has been minimized.

@aqrln

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.

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

This comment has been minimized.

@aqrln

aqrln Jun 9, 2017
Contributor

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

This comment has been minimized.

@aqrln

aqrln Jun 10, 2017
Contributor

s/fucntion/function

@@ -1,4 +0,0 @@
#!/usr/bin/perl

This comment has been minimized.

@aqrln

aqrln Jun 10, 2017
Contributor

Can you please update the names of the other files so that there are no gaps in the ordering?

@tshemsedinov tshemsedinov force-pushed the HowProgrammingWorks:master branch from 495ce31 to 90728b6 Sep 11, 2017
@tshemsedinov tshemsedinov force-pushed the HowProgrammingWorks:master branch from 516d3a6 to a2f04c4 Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.