Welcome to the new year! Today, let us switch for a while from the discussion about obsolete messages to something different. Stages If you followed the exercises in the previous posts, you might have noticed that some statistics was printed in the console when compiling Rakudo: Stage start : 0.000 Stage parse : 44.914 Stage syntaxcheck: β¦ Continue reading βπ¦11. Compiler stages and targets in Perl 6β
Month: December 2017
π¬10. Obsolete syntax error messages, part 2
Today, we continue exploring the error messages that Rakudo developers embedded to detect old Perl 5 constructions in the Perl 6 code. The obs method But first, letβs make a small experiment and add a call to the obs method in the rule parsing the for keyword. rule statement_control:sym<for> { <sym><.kok> {} [ <?before βmyβ? β¦ Continue reading βπ¬10. Obsolete syntax error messages, part 2β
π¬9. Obsolete syntax error messages in Perl 6, part 1
Yesterday, we saw an error message about the improper syntax of the ternary operator. Letβs look at other similar things that the Rakudo designers has implemented for us to make the transition from Perl 5 smoother. First of all, the Perl 6 grammar file (src/Perl6/Grammar.nqp) contains four different methods for reacting to obsolete syntax: method β¦ Continue reading βπ¬9. Obsolete syntax error messages in Perl 6, part 1β
π¬8. Digging into operator precedence in Perl 6, part 2
Yesterday, we took a look at how the ? and so operators are dispatched depending on the type of the variable. We did it with the intention to understand what is the difference between them. Here is once again an excerpt from the src/core/Bool.pm file, where the bodies of the subs look alike: proto sub β¦ Continue reading βπ¬8. Digging into operator precedence in Perl 6, part 2β
π¬7. Digging into operator precedence in Perl 6, part 1
Today, weβll once again look at the src/core/Bool.pm file. This is a good example of a full-fledged Perl 6 class, which is still not very difficult to examine. Look at the definitions of the ? and so operators: proto sub prefix:<?>(Mu $) is pure {*} multi sub prefix:<?>(Bool:D \a) { a } multi sub prefix:<?>(Bool:U β¦ Continue reading βπ¬7. Digging into operator precedence in Perl 6, part 1β
π¬6. The dd routine of Rakudo Perl 6
In Rakudo, there is a useful routine dd, which is not a part of Perl 6 itself. It dumps its argument(s) in a way that you immediately see the type and content of a variable. For example: $ ./perl6 -eβmy Bool $b = True; dd($b)β Bool $b = Bool::True It works well with data of β¦ Continue reading βπ¬6. The dd routine of Rakudo Perl 6β
π¬5. Lurking behind interpolation in Perl 6
In the previous articles, weβve seen that the undefined value cannot be easily interpolated in a string, as an exception occurs. Today, our goal is to see where exactly that happens in the source code of Rakudo. So, as soon as weβve looked at the Boolean values, letβs continue with them. Open perl6 in the β¦ Continue reading βπ¬5. Lurking behind interpolation in Perl 6β
π¬4. Exploring the Bool type in Perl 6, part 2
Today, we are continuing reading the source codes of the Bool class: src/core/Bool.pm, and will look at the methods that calculate the next or the previous values, or increment and decrement the values. For the Boolean type, it sounds simple, but you still have to determine the behaviour of the edge cases. pred and succ β¦ Continue reading βπ¬4. Exploring the Bool type in Perl 6, part 2β
π¬3. Playing with the code of Rakudo Perl 6
Yesterday, we looked at the two methods of the Bool class that return strings. The string representation that the functions produce is hardcoded in the source code. Letβs use this observation and try changing the texts. So, here is the fragment that we will modify: Bool.^add_multi_method(βgistβ, my multi method gist(Bool:D:) { self ?? βTrueβ !! β¦ Continue reading βπ¬3. Playing with the code of Rakudo Perl 6β
π¬2. Exploring the Bool type in Perl 6, part 1
This is the excerpt for your very first post.
This is the excerpt for your very first post.
π¦1. The proto keyword in Perl 6
Today, we are looking precisely at the proto keyword. It gives a hint for the compiler about your intention to create multi-subs. Example 1 Consider an example of the function that either flips a string or negates an integer. multi sub f(Int $x) { return -$x; } multi sub f(Str $x) { β¦ Continue reading βπ¦1. The proto keyword in Perl 6β