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
WIP: Add Node.js to Perl 6 nutshell page #1975
Conversation
doc/Language/js-nutshell.pod6
Outdated
|
||
=SUBTITLE Learning Perl 6 from Node.js, in a nutshell. | ||
|
||
This page attempts to provide a way for users experienced in Node,js to learn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node,js
should be using a .
instead of a ,
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no comma in Node.js
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This page attempts to provide a way for users experienced in Node,js to learn
Node,js
I'm pretty sure the exact line I referenced contains a ,
right there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in line 7, experienced in node,js
doc/Language/js-nutshell.pod6
Outdated
In Perl 6, there are two ways to write this in the same way: | ||
|
||
=begin code | ||
put 'Hello, world!'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation on say
comes with this line
Prints value to $*OUT after stringification using gist method with newline at end. To produce machine readable output use .put.
I'd consider using say
in your examples, since this is the most commonly used (from what I gather in #perl6
, that is).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is the most commonly used (from what I gather in #perl6, that is)
Whether you use one or another depends on your intent (but yes, most examples should probably use say
)
doc/Language/js-nutshell.pod6
Outdated
console.log('Hello, world!'); | ||
=end code | ||
|
||
In Perl 6, there are two ways to write this in the same way: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many more, actually. Like say
.
doc/Language/js-nutshell.pod6
Outdated
say "What's up, " ~ $name ~ "?"; | ||
say "What's up, $name?"; | ||
say "What's up, ", $name, "?"; | ||
=end code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're showing different quote styles in the Javascript example, one without interpolation and one with interpolation. Why not do the same for Perl 6, ie: single quotes and double quotes?
doc/Language/js-nutshell.pod6
Outdated
This is how the equivalent types of variables are defined in Perl 6: | ||
|
||
=begin code | ||
my $foo = 1; // Lexically scoped with blocks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
» perl6 -e 'my $foo = 1; // Lexically scoped with blocks'
===SORRY!=== Error while compiling -e
Null regex not allowed
at -e:1
------> my $foo = 1; //⏏ Lexically scoped with blocks
Perl 6 uses #
to start a comment, not //
.
Updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check also the test error and try to fix it in your next commit.
doc/Language/js-nutshell.pod6
Outdated
Since he didn't hear us, let's greet him again, this time in Perl 6: | ||
|
||
=begin code | ||
my $name := 'Joe'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is let binding? If it's not, it's better to just use =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you have a look at this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let
is not binding in Javascript, let
makes it a block scope local variable.
doc/Language/js-nutshell.pod6
Outdated
logDupe(2); // 2 | ||
=end code | ||
|
||
Perl 6 also allows this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see it clearly here, but we're using the unicode character non-breaking space for the space before 6. If you've done so, no problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*
is not, per se, a twigil; $* together are the twigil.
doc/Language/js-nutshell.pod6
Outdated
console.log('Hello, world!'); | ||
=end code | ||
|
||
In Perl 6, there are two ways to write this in the same way: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, there's "say" too... Maybe this example should include printing of variables, and how that is done in Perl using dd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should show off dd
as being a Perl 6 feature, as dd
is a Rakudo specific feature.
584ad81
to
6af128f
Compare
Updated, corrected some parts of the basic syntax section that were incorrect |
doc/Language/js-nutshell.pod6
Outdated
|
||
=SUBTITLE Learning Perl 6 from Node.js, in a nutshell. | ||
|
||
This page attempts to provide a way for users experienced in Node,js to learn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you've told me twice already that you don't see a comma here, but it still reads Node,js
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, thought I got that in the last commit
doc/Language/js-nutshell.pod6
Outdated
let foo = 2; | ||
console.log(foo); | ||
} | ||
logDupe(2); // 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add console.log(foo)
here to show that the original foo
declared before the function
is unaffected.
doc/Language/js-nutshell.pod6
Outdated
my $foo = 2; | ||
say $foo; | ||
} | ||
log-dupe; # 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a say $foo
here to show that the original $foo
declared before the sub
is unaffected.
doc/Language/js-nutshell.pod6
Outdated
The C<=> operator works the same across both languages. | ||
|
||
The C<:=> operator in Perl 6 binds a value to a variable. This makes it so the | ||
variable can't be reassigned. Binding a variable to another variable gives them |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the variable can't be reassigned.
Oh? Afaik :=
just binds the value directly to the variable, but you can still reassign the variable:
> my $a := 5; $a := 4; say $a;
4
doc/Language/js-nutshell.pod6
Outdated
my %bound := %map; | ||
%map<foo> = 'bar'; | ||
say %bound; # {foo => bar} | ||
=end code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you show how a regular hash would look like, if it were assigned with =
? This would make it more clear to see the differences between assignment done with =
and :=
.
cdffe91
to
e0d3509
Compare
Updated with documentation on operators |
d2930af
to
91b1a70
Compare
Please check the POD error and fix it. |
I think that come a certain point, it's better to accept it so that anyone
can work on it. It's better to have something there than to have something
perfect.
|
Done
I think this is a good idea. The rest of the first section is relatively straightforward to write, but the later ones are too complex to write comprehensive documentation for alone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm aproving this as it is now, and leave the rest for future improvements. The areas are well marked, and anyone can work on them now. I'll create an issue to that effect.
DO NOT MERGE YET
Just looking for some feedback as I write the page.
Fixes #1968