This week, the most notable change would be Rakudo sort of working on Java Virtual Machine. It still needs lots of improvements, but it can already run “Hello, world” program, what is important milestone in Rakudo for JVM.
You cannot create a set or bag from list of pairs or hash using a constructor.
The bag {a => 2} was ambiguous, because it could mean either bag containing 'a' with value 2, or bag containg {a => 2} with value 1.
You’re expected to use .Bag or .Set instead, if you mean that.
You cannot use set or bag to mean empty set or bag.
If you really meant that, you are expected to use set() or bag() instead.
Slice adverbs support false booleans.
You can write code like %a<b> :!exists to check whatever the element doesn’t exist.
You can also write code like %a<b> :!delete which does nothing, but can be used for conditionally deleting hash keys (for example %a<b> :delete(%a<c> :!exists)).
Sets and bags use === semantics.
Previously the specification hasn’t said which semantics should be used. As anything other than === semantics would be slow, === semantics are used.
Added FINAL and COMPOSE phases.
FINAL is ran at link time. COMPOSE is ran when a role is composed into a class.
set<a b c> has special error message.
This syntax wasn’t useful for anything, except for perhaps obfuscation. It meant creating empty set, and getting keys 'a', 'b', and 'c' from it. As the empty set doesn’t have these keys, it was returning False 3 times.
As the behavior doesn’t make any sense, you probably wanted to use set <a b c> instead. The old behavior is still accessible using set()<a b c>, but I don’t think you would want to use this.
Perl 5 grammar allows version in require statement.
In Perl 5, you can write code like require 5.010 do make runtime version check (as opposed to use 5.010 which is compile time check). The Perl 5 grammar, included as part of STD.pm6 now supports this syntax.
FINAL and COMPOSE phases is now recognized.
Now that these phases are in specification, the grammar was modified to recognize them.
JVM version of Rakudo supports simplest “Hello, world!” program.
Fixed infinite recursion in IO::Spec::Unix.rel2abs.
rel2abs made infinite recursion if neither $path or $base were absolute.
Set, KeySet, Bag, and KeyBag have default method.
When reading undefined property of those classes, default method contains value that you should receive. In case of sets, it’s False. For bags, it’s 0.
Regexpes support more delimiters.
Previously, Rakudo didn’t accept regexpes like m^42^ or m€cash€. Now, they are allowed, just like in Perl 5.
Set, KeySet, Bag, and KeyBag have default method.
Just like in Rakudo, except with Niecza.
So, well, what’s new. I’m going to answer - lots of changes and fixes. Even the Niecza, where lately development had slowed down got lots of fixes.
Array references aren’t treated as arrays in regular expressions.
Following code used to find 1, 2, or 3.
my $array = [1, 2, 3];
my $number = prompt 'Give me a number!';
say "It's in array" if $number ~~ / ^ $array $ /;
It doesn’t do that anymore, because variables are expected to be stringified inside regexpes. If you want the old behavior, be explicit and write @$array instead of $array.
Please note that currently regular expressions are exception to this rule. This is going to be fixed in the future. Lots of code depends on regexpes to be not stringified, and first the warnings will have to be implemented. You are expected to use <$regexp> instead of $regexp.
Changed capitalize to wordcase.
In the current specification, that method is named wordcase.
ucfirst was long deprecated, and it’s finally time to remove it. You are expected to use tc instead.
Stringification of Set, KeySet, Bag, and KeyBag works properly when they are undefined.
Methods Str, gist and perl expected they deal with defined object. This isn’t the case when dealing with the classes themselves.
Deprecated $% and $@ variable checkers are working just like in STD.
The $@(1) was complaining about use of deprecated variable, when the real problem was use of invalid hard reference syntax.
IO::Spec::Win32 no longer warns when using relative pathes.
The check for initial prefix was using optional alternative (([a | b | c])?). Because of that, it was Nil if it matched nothing. Since the result of match was stringified just after it was matched, it returned a warning when ? matches nothing. It was fixed to do ([a | b | c]?) instead.
Added tests for IO::Path and IO::Spec to list of tests that should pass.
As IO::Path and IO::Spec were implemented, their tests are now ran when you request full test from roast test suite.
Interpolation of quotes in regexpes isn’t done twice anymore.
Previously, quotes inside RegExpes were doing interpolation two times.
https://github.com/rakudo/rakudo/commit/c255f1df the older commits) made it 10 times slower. The performance regression was fixed, and now match is as fast as it used to be.
wordcase method now accepts where which is Mu.
Previously, only Any values were accepted. While using Mu doesn’t make much sense, there is no reason to disallow it, so it’s allowed now.
Configuration instructions don’t say to use –gen-nqp.
It was pointless, since --gen-parrot automatically implied --gen-nqp. If you want Parrot, it’s safe to assume you want NQP for that Parrot too, right?
If you had used our @array, and our %hash, the object wasn’t initialized properly, and it wasn’t working like array or hash. This made our work only with $scalars previously.
Previously, trying to use our with arrays or hashes caused strange uninitialized variable to appear. It didn’t have STORE method, so you couldn’t have put anything in this variable, and had Any instead of empty array of hash.
It’s now possible to augment empty list.
MONKEY_TYPING couldn’t be used to modify lists. Now it can.
Pair.perl can now deal with the cases when Pair is the key.
Doing ((a => 'b') => 'c').perl used to output "a" => "b" => "c", what actually meant (a => (b => 'c')). .perl now outputs correct code in that case.
Perl 6 gets more and more stable, less features are added, and the features that are left are worked on. Also, Rakudo Perl is being ported to JVM.
Updated IO:: classes documentation pages.
To many minor changes to describe, just follow the link.
Flip flops now use smartmatch semantics instead of boolean semantics.
Now you can write code like "BEGIN" ff "END", instead of using regexes for that.
Use of & in infix position is now catched after whitespace.
Previously, code like $some-object.some-method &sub-routine appeared to work. However, it didn’t meant what you would expect, it didn’t called the method with subroutine argument, but assumed junction and. In order to avoid surprises, this is now disallowed.
The message about no parens or colon after method name is more specific.
Now code like $some-object.some-method 42 shows information that colon or parens are required.
Added lots of function declarations.
The STD now recognizes certain functions that were added lately.
is-primeexpmodmkdirrmdirsocketlistenacceptconnectbindinfix:<leg>infix:<cmp>This class is intended to do OS-specific manipulation of pathes. It can get the localizations of special folders (for example home directory, root directory, temponary directory), and can manipulate pathes (by joining them, spliting them, converting them to absolute or relative, and so on).
Implemented IO::Path::<os subclasses>.
Thanks to this change, the pathes objects are OS specific. You can have path marked to be Windows path, so you can parse it in OS specific way, without having to use that OS.
On large arrays, shift is now noticeably faster. For example, if array @a has 50_000 elements, running following snippet of code is processed within 2.5 seconds (and not 9.0 seconds).
@a.shift while @a;
Failed regex matches now return Nil.
Previously, failed regex matches were returning the Match object that stringified to #<failed match> and was converted to False.
&diag function in Test.pm accepts Mu.
This, I think is self explanatory. &diag is a debugging function, outputing its argument. Forbidding Mu didn’t made sense, so it’s now allowed.
Exporting of subroutines now works properly.
use Module qw(sub1 sub2) should now work.
Fixed dir() to work on Windows.
This makes panda work on Windows.
Continuing, still with commit IDs.
DateTime doesn’t accept Callable timezones anymore. 5692ced333IO to IO::Handle. IO itself is a role. 2dca6ed950 37c9956502DateTime doesn’t accept Callable timezones anymore. 71ea142406Cool.lines. 0d1d1194a4It’s sixteen article in the series. The game goes so fast, and I still haven’t done pagination on my website (lazy as always). The scrollbar is still shorter (1 pixel on my PC) than on Planet Six, but most likely because of longer lines.
NQP was bootstrapped on JVM. That means it can compile itself. It still doesn’t support Perl 6 perfectly, because some code still uses pir::, but it progressed really far. Also, the new version of Rakudo Perl, 2013.04 “Albany” was released. Every improvement mentioned here, is in.
I’ve decided to experiment with commit links this time. This way, you can click (or press, or whatever, depends on your device, to get code of this change).
IO::Dir and IO::File classes. fb25fa475854IO::Path is closer to actual spec. 24532aca13Bool method to Capture. 9f873d89e3List.ACCEPTS now has special Whatever handling. f17d339185do...for doesn’t propose repeat...for now. 41a92e808erequire PATH|$variable|Module:file(PATH) syntaxes are now accepted. c946d0f7f7pir:: to nqp::. In particular, getting env variables is now done using NQP, not Parrot directly. e9e1b5d962I apologize I forgot about Perl 6 changes article yesterday. This ought not to happen, but it did. As for reason why it happened, well, I guess I will tell you anyway - it’s that game.
Parcels are allowed to have 0 elements..DUMP method can detect recursion for hashes.ForeignCode for non-Perl 6 code objects (like C code).pir:: usage for JVM port of Rakudo.PRE ; now has specific error message.symlink and link.require can take paths.big_pow when either of values is -1, 0, or 1.You may have noticed may page went down for some time. This appears to be connected to newest domain change. In order to be more… modern, I’ve moved the repository to glitchmr.github.io, but that made entire page to go down. I apologize for inconvience, but it didn’t affected Planet Six, so I think it’s fine.
As always, I’m going to describe changes in Perl 6.
weekday-of-month to day-of-week-in-month.Pod::Block.gist, so it works properly with multis.for loops are eager now.Buf.perl.Buf.gist, so it works properly with multis.The month is coming to end, and with that, I’m going to make yet another list of changes.
IO::Path methods: .contents, .is-absolute, .is-relative, .absolute, and .relative..path is now NOP that returns itself. For its previous behavior, use .Str.Numeric.conjugate to Numeric.conj.+(23..2300000000) is optimized.--help reports -I and -M options.I really should optimize my blog layout, so empty intro wouldn’t be ugly. But I guess I’m too lazy to do it right now, so I have to explain stuff. Every week, I list the list of changes in Perl 6 specifications, and its implementations. That’s just everything, boring, I know. Still, it doesn’t look that bad on Planet Six, so I guess I will continue to make these articles :-).
This week, the Rakudo 2013.03 was released. Every change mentioned here was implemented in it.
X::Range::InvalidArg.pir:: usage.I would put nothing here, but the layout of blog would make this look ugly. So, well, like usually I put something here, even if it is meaningless. Just look below to see list of changes.
Closing brace, followed by newline and infix operator was parsed incorrectly. For example, following code.
my %a;
{ }
%a<b> = 1;
Was parsed like:
my %a;
{ } % a()<b> = 1;
Instead of correct.
my %a;
{ };
%a<b> = 1;
Done more pir:: to nqp:: replacements in order to help JVM port of Rakudo Perl.
Case insensitive matches with strings now work.
my $nonsense = 'asdf';
say "OK" if "ADSF" ~~ m:i/$nonsense/;
Typing else if and elif after if block shows “Please use ‘elsif’” error message.
&?ROUTINE variable is available inside regex foo { ... }.
The named params are optimized in compile time when possible.
X::Method::NotFound is raised even when dealing with "" (empty) method names.
Fixed proto of infix:<ne> in order to require Mu objects.
Stash.at_key method now works.
Postcircumfix calls can be cached now.
LEAVE is now fired on next/last in MapIter.
Exception is thrown when Range endpoint is used to create a Range.
Empty.gist returns nothing.During making this update, I had lots of problems with Internet. I have managed to load commits history for every repository I check, but I haven’t checked commits. Will update this after Internet access will be more stable.
Rat.perl returns decimal number when denominator is normalizable to a power of 10.Nil and ().List.permutations.rat64 type has unsigned denominator.Nil isn’t suggested for empty list in error messages anymore."a" ~~ / <$blah> / is fixed.Rat.perl returns decimal number when denominator is normalizable to a power of 10.pir:: usage in order to help porting Rakudo to JVM.Rat.perl provides angle brackets around fractional forms.<< >> and « »).0.if(1 < 2) { ... } (where mistake is that if is called like a function) give good errors.Nil isn’t suggested for empty list in error messages anymore.Rat.perl returns decimal number when denominator is normalizable to a power of 10.CommonEnum.gist returns (Type) instead of Type() for undefined.infix:<cmp> sorting for different types.Nil.I would put a description, but who seriously cares?
try is considered eager context, unless try is called in sink context, when it’s in sink context.Int, which is null, except Int typed) now have their .gist method show their name within parens to suggest being undefined. For example, (Int), (Mu).Cool.substr doesn’t coerce its first argument to Int anymore.So, well, I have a VPS, and decided to put a webpage on it for lulz. You can see it at mango.uk.to, and the source (sauce) is available on my GitHub profile.
Just mentioning, not that this site is important. I just wanted to run a web server just to run a web server.
By the way, this blog is also open sauce, you can see its source code on GitHub. It’s full of hacks, but that’s Jekyll for you.
Now, I’m back to the your regularly scheduled Perl 6 changes article that isn’t. Well, it is, but it’s not. Or something. Rakudo 2013.02.1 was released (well, 2013.02 was released too). The version bump was caused by the fact that NQP 2013.02 had broken native call support.
Nil, not (Match).Set.powerset. It was removed after 10 hours of existing. Consider it a printing error in my previous article, or something. Not really an incompatible change, as it practically never existed.Int, which is null, except Int typed) now have their .gist method show their name within parens to suggest being undefined. For example, (Int), (Mu).(Match) or (Nil).@a[0], which is treated as any of @a elements followed by 0).int64 native type././ and rx/./ now matches against $_ in sink context.$feature is not yet implemented. Sorry. error message doesn’t have is anymore.Int, which is null, except Int typed) now have their .gist method show their name within parens to suggest being undefined. For example, (Int), (Mu).I’m not sure if anybody noticed, but lately, nothing was happening on my blog. So, I’m going to write an article about friendly interactive shell (fish), the best shell I’ve used ever (it’s my personal opinion, in case you haven’t noticed, see my footer blog). Actually, I think I’ve moved to it half of the year ago or something.
These days, the two popular shells exist - bash and Z shell. I’m aware of that more shells exist - just nobody uses them these days By the way, if you try to find logical fallacy, I agree, cmd.exe and Windows PowerShell are often used, but those aren’t UNIX shells. Oh, and programming language REPLs are often used too (like irb), but they aren’t UNIX shells too.
The bash shell is standard shell, included in many Linux distributions. It will make you bash your head against the brick wall (pun intended).
One of examples of bash code I could have found is this. And trust me, it’s not the worst thing (thanks, Wikibooks).
# print the powers of two, from 1 to 512:
for ((i = 1; i < 1000; i *= 2)); do
echo $i
done
Do you see double parens here? This is really strange math syntax that only supports integers. Why double parenthesis? Well, the answer is compatibility with Bourne shell (really, really old shell, usually called sh (but sometimes sh is actually bash, to make you bash)).
Also, you could have noticed keywords do and done. Bash could easily not require do keyword before for loop body. Yet, it’s required. The other strange quirks is that you aren’t allowed to put semicolon after do keyword. Why? I’ve no idea, really. The done word, while I think it’s needed, differs between blocks. For example, if blocks end with fi.
Bourne again shell has lots of strange syntax you really wouldn’t ever use. For example, bash has $'' syntax. It unescapes escape sequences inside. The strange part is '' in bash doesn’t do any processing at all, yet $'' does. Bash also has $"" syntax, but it doesn’t do escape processing - instead it uses gettext to translate string inside.
# Prints 'Hello world.', with new line in middle.
echo Hello$'\n'world.
# Prints 'Hello\nworld.', literally.
echo Hello$"\n"world.
Consistency in bash is even worse than in languages such as PHP. There are many ways to do something, but none of them are obvious. And I mean that, none. Expanding bash is adding new syntax that totally doesn’t make sense, but was a syntax error in previous versions. $ sign is used for many features that have nothing with variables.
Also, bash integrates many programs in it that really shouldn’t be inside. For example, echo.
[glitchmr@pineapple ~]$ echo --help
--help
[glitchmr@pineapple ~]$ which echo
/bin/echo
[glitchmr@pineapple ~]$ /bin/echo --help
Usage: /bin/echo [SHORT-OPTION]... [STRING]...
or: /bin/echo LONG-OPTION
Echo the STRING(s) to standard output.
...
NOTE: your shell may have its own version of echo, which usually supersedes
the version described here. Please refer to your shell's documentation
for details about the options it supports.
Report echo bugs to bug-coreutils@gnu.org
GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
General help using GNU software: <http://www.gnu.org/gethelp/>
Report echo translation bugs to <http://translationproject.org/team/>
For complete documentation, run: info coreutils 'echo invocation'The /bin/echo on my system is GNU echo. The bash on my system is GNU bash. They were both made by GNU. Yet, they act differently. Is there a better recipe for failure than program that actually isn’t called because your shell is “clever”.
It’s not just echo. Many commands are implemented in shell, when they should be implemented outside shell. For example, pwd. Why exactly? To confuse you when dealing with recursive structures.
[glitchmr@pineapple ~]$ mkdir recursion
[glitchmr@pineapple ~]$ cd recursion/
[glitchmr@pineapple recursion]$ ln -s . recursion
[glitchmr@pineapple recursion]$ cd recursion
[glitchmr@pineapple recursion]$ pwd
/home/glitchmr/recursion/recursion
[glitchmr@pineapple recursion]$ which pwd
/bin/pwd
[glitchmr@pineapple recursion]$ /bin/pwd
/home/glitchmr/recursion
[glitchmr@pineapple recursion]$ The shell outright lies about your location. You’re in /home/glitchmr/recursion. Why shell does that? Well, it does that to not confuse you when typing cd ... And indeed, if you type cd recursion/recursion, and cd .. after that, you will end in recursion directory, not the directory where you created the first recursion directory.
Symbolic links in UNIX are simply redirects. If you made a symbolic link to /usr/share/hell, you shouldn’t expect that cd .. made after following link follow return you anywhere that isn’t /usr/share. Yet, implementation of symbolic links in bash lies.
The lie is obvious after using anything that isn’t bash builtin. For example, ls .. will always show contents of /usr/share, even if you made symbolic link in /tmp/heaven. Yet, cd .. will return to /tmp/heaven.
By the way, in case you ask, cd is also a builtin. But that’s acceptable, because external command cannot change environment of caller (such at PATH). So it has to be a builtin. Yet, somehow, some people are still confused.
Z shell is a shell that is way better than bash. Well, if you configure it properly. It’s a shell that appears to have some compatibility with Bash scripters (for example $'' syntax works, but $"" doesn’t (or rather, it returns literal ’$’ and contents of "")).
Z shell has lots of features. In fact, the author is “not aware of a major interactive feature in any other freely-available shell which zsh does not also have (except smallness)”. Something that would be sane default actually isn’t default. In fact, with default settings it mostly works like bash.
For example, completion. By default, Z shell only completes file names and command names. If you will type sudo apt-get install, press space and then press Tab, it will give you file names. Useful? I don’t think so.
Of course, the option to enable better Tab completion is possible to turn on. It’s just not default. Why the shell would have default that don’t make sense. Simiarly, by default Tab completion cannot expand globs. Yet, it’s possible to enable.
When you start Z shell for first time, you see the configuration wizard (called zsh-newuser-install). The problem is, it’s the most non-user-friendly thing I’ve seen. It asks about minor details you don’t care about, without proposing any useful default. For example, the maximum number of errors you can make for the command to be still proposed in error message. I just have pressed Enter, and the response is “Please enter a number”. Do you think I care about this?
Actually, as far I know, nobody actually uses this wizard. In most cases, zsh is configured using so called oh-my-zsh. What it is actually? Well, it’s a config script with sane things configured by default. Yet, it has got 8,648 stars on GitHub and 3,326 forks as I’m writing it.
Yes, it’s just ZSH config file that has things that should be default, but they aren’t. Oh, and plugins array that contains list of plugins that mostly make aliases and completion adders that aren’t in main zsh (like CoffeeScript). For example git plugin adds aliases like gc for git commit -v.
I don’t know about you, but I don’t like programs which take 4 hours to configure. Z shell is one of these. oh-my-zsh makes the job easier, but I still don’t think it’s worth wasting the time. Perhaps if fish wouldn’t exist, it would be worth it.
Z shell, aside of totally insane configuration isn’t a bad shell (if I would want to talk about bad shells, it would be csh or cmd.exe). friendly interactive shell is as good as Z shell (with good Z shell configuration), except without having to configure it.
In fact, most of things cannot be configured. You cannot configure nonsense like maximal history length (by design). You cannot configure interpretation of numbers starting with 0 as octal (you can in Z shell - I have no idea why Z shell even allows you to type “echo 010” to get “8” when configured to do so - but it does). You cannot disable file globs.
Remember .bashrc/.zshrc configuration file? You won’t need it. The colors and themes can be easily configured using a web service (but if you prefer, you can use set command directly).
For example, if you want to configure your EDITOR to be vim, you can run the following command.
set -Ux EDITOR vimThe -U modifier means that this value is stored between session. The -x means that this variable is exported to programs ran by shell. After you have done that, your variable magically appears in every fish session.
Adding new functions is also easy. It’s enough to type funced function-name. After
Fish also offers features I haven’t seen in other shells, like syntax highlighting. Ommited quote? Syntax highlighting will help you.
In fish, everything is tab-completeable. Even if the program doesn’t have specific tab completion definitions, it’s still tab-completeable, thanks to generating tab completions from man pages. For example, gedit doesn’t have specific tab completions, yet fish managed to create them.
glitchmr@pineapple ~> gedit -
--background (Run gedit in the background.)
--encoding (Set the character encoding to be used for openi… [See Man Page])
--geometry (Set the X geometry window size (WIDTHxHEIGHT+X+Y).)
--help (Prints the command line options.)
--list-encodings (Display list of possible values for the encodin… [See Man Page])
--new-document (Create a new document in an existing instance of gedit.)
--new-window (Create a new toplevel window in an existing instance of gedit.)
--standalone (Run gedit in standalone mode.)
--version (Output version information and exit.)
--wait (Open files and block the gedit process.)
-b (Run gedit in the background.)
-g (Set the X geometry window size (WIDTHxHEIGHT+X+Y).)
-s (Run gedit in standalone mode.)
-w (Open files and block the gedit process.)Of course, just like zsh (with correct configuration), it can expand more stuff. For example, kill command expands process IDs.
glitchmr@pineapple ~> kill
1 (systemd) 127 (systemd-udevd) 479 (gconfd-2)
2 (kthreadd) 132 (systemd-journal) 508 (gvfsd)
3 (ksoftirqd/0) 229 (hd-audio0) 512 (gvfsd-fuse)
5 (kworker/0:0H) 230 (kpsmoused) 527 (cinnamon [tty1])
7 (kworker/u:0H) 299 (irq/46-mei) 528 (colord)
8 (migration/0) 307 (cfg80211) 534 (polkit-gnome-au [tty1])
9 (rcu_preempt) 308 (hci0) 536 (dropbox [tty1])
10 (rcu_bh) 309 (kworker/u:1H) 539 (nm-applet [tty1])
11 (rcu_sched) 310 (scsi_eh_6) 540 (gnome-screensav [tty1])
12 (watchdog/0) 311 (rts5139-control) 558 (gsd-printer [tty1])
13 (watchdog/1) 312 (rts5139-polling) 566 (gvfs-udisks2-vo)
14 (ksoftirqd/1) 314 (ttm_swap) 568 (udisksd)
15 (migration/1) 325 (NetworkManager) 598 (gvfsd-trash)
17 (kworker/1:0H) 329 (dbus-daemon) 728 (firefox [tty1])
18 (cpuset) 331 (systemd-logind) 744 (hexchat [tty1])
19 (khelper) 332 (login) 746 (pxgsettings [tty1])
20 (kdevtmpfs) 335 (polkitd) 797 (dconf-service)
21 (netns) 341 (mysqld) 798 (gnome-terminal [tty1])
22 (bdi-default) 344 (wpa_supplicant) 805 (gnome-pty-helpe [tty1])
23 (kblockd) 348 (nginx) 806 (fish [pts/0])
26 (khungtaskd) 349 (nginx) 1374 (kworker/1:2)
27 (kswapd0) 351 (php-fpm) 5790 (fish [pts/1])
28 (ksmd) 352 (php-fpm) 10502 (gvfsd-metadata)
29 (khugepaged) 353 (php-fpm) 13551 (fish [pts/2])
30 (fsnotify_mark) 373 (dhclient) 13635 (ssh [pts/2])
31 (crypto) 385 (fish [tty1]) 13866 (kworker/1:0)
35 (kthrotld) 387 (fishd) 18892 (gvfsd-http)
38 (deferwq) 412 (startx [tty1]) 20044 (fish [pts/1])
62 (khubd) 429 (xinit [tty1]) 20046 (python [pts/1])
63 (ata_sff) 430 (X) 20405 (vim [pts/0])
64 (scsi_eh_0) 434 (gnome-session [tty1]) 21370 (kworker/0:1)
65 (scsi_eh_1) 437 (dbus-launch [tty1]) 21373 (kworker/u:2)
66 (scsi_eh_2) 438 (dbus-daemon) 22399 (fish [pts/3])
67 (scsi_eh_3) 440 (at-spi-bus-laun) 22472 (vim [pts/3])
68 (scsi_eh_4) 444 (dbus-daemon) 22521 (kworker/u:0)
69 (scsi_eh_5) 447 (at-spi2-registr) 22863 (kworker/0:0)
93 (kworker/0:1H) 455 (gnome-settings- [tty1]) 22945 (kworker/u:1)
95 (kworker/1:1H) 464 (pulseaudio) 23238 (ps [pts/4])
103 (jbd2/sda6-8) 465 (rtkit-daemon) 23239 (grep [pts/4])
104 (ext4-dio-unwrit) 468 (upowerd) 23240 (tail [pts/4])
110 (flush-8:0) 476 (gconf-helper)Of course, fish has some disadvantages. One of disadvantages is the syntax. It’s not POSIX compatible by design. For example, the history substition doesn’t exist. Instead, you’re supposed (if you wanted, let’s say, sudo) to press Up, Home, and type ‘sudo’. Command substitution uses (), not `` or $(). Still, if you will accidentally use $() bashism, the shell will inform you with an error.
Also, the newest stable is really old and slow. Instead I would use version from git, which is usually more stable than stable version. In Arch Linux, it’s fish-shell-git from AUR, on other operating systems (like CentOS I use on my VPS), you have to compile it yourself. It isn’t so difficult. The GitHub repository is fish-shell/fish-shell.
As for why I’m mentioning fish shell, well, I have lately contributed a small patch to hint -C suboptions in perl - like -CSDL. Nothing special, but hey, why not make a blog post, considering I write them rarely.
> my $perl = Date.new: '1987-12-18' # Perl 1 release[1]
1987-12-18
> my $perl6 = Date.new: '2000-07-18' # Perl 6 announcement[2]
2000-07-18
> Date.today - $perl6
4596
> $perl6 - $perl
4596Normally, I wouldn’t put irrelevant snippets of code[citation needed]. But this day is different - we have Perl 6 equidieversary (thanks, moritz). It’s 4596 days since Perl 6 was announced (Wikipedia says it was annouced 2000-07-19, but actually it was earlier). In 2000-07-19, Perl was 4596 days old. But I won’t discuss about this more, as masak already made perfectly fine article about that.
Let’s return to your regularly scheduled program.
Sets and Bags do not flatten in list context.
Metaoperators are treated as normal operators, and aren’t making list of closures. So, for example @array X* * is -> $arg { @array X* $arg }.
Inner classes and roles must be lexically scoped.
Added List.combinations and Set.combinations.
Added Set.powerset. It’s defined like that.
multi method powerset { set ∅, self.combinations }
$_ is writable in -n/-p code (one-liner).eqv is faster for Buf objects.This time without any gimmicks (like five word sentences). This will be simple description of changes I do regularly.
^..^ (infix) and ^ (prefix) operators.Match.gist method.Yet another ignorable self promotion. http://twitter.com/GlitchMr
(perhaps I should have different news feed for Planet Six…)
The changes are so fun. jnthn is working on porting. nqp will be on JVM. And then, Rakudo will be. Java is very, very fast. There are some interesting problems. But nothing impossible to solve. At least, I hope so. I would continue, but well. This is not the topic. This is article about changes. Changes in Perl 6, obviously. If you want, enjoy reading.
Rakudo Star 2013.01 was released. It’s based on Rakudo 2013.01. Those changes aren’t in.
On sidenote, a small note. Five word sentences are interesting. I am not stealing ideas. Well, actually, I am now. I should stop talking now.
any and all are optimized. To be exact, in statements. The if and while statements. And opposites - unless and until.Today, the main features is .delta method in DateTime and Date. And as usually, bug fixes that make language do what you mean.
DateTime.delta and Date.delta to the specification.s/// resets $/ on failure.s/// returns False on failure.$() syntax for arbitrary expressions.DateTime.truncated-to now takes TimeUnit enum as argument.DateTime.delta and Date.delta.--> Type (subroutine return type)./< hello >/ now works correctly (matching hello), just like /< hello world >/ already did.Rakudo lately got an interesting change. Consider following buggy code (for array binary search), written in functional style (I’m using recursion). The bug is that it doesn’t work because of two different identifiers binary-search and binary_search.
Trying to run it shows compile time error message. The compile part is important. If you would remove binary-search call at end, it still would report an error, unlike Python.
===SORRY!===
Undeclared routine:
binary_search used at lines 2, 8, 9. Did you mean '&binary-search'?Now you know what’s wrong and you can easily fix it. Unlike let’s say, Jekyll that I use for my blog. Not only it doesn’t work on my PC for some reason, but also refused to highlight my code - it gave some sort of XML error (it simply said “REXML could not parse this XML/HTML”). I gave up and put it on Gist. And the first attempt was failed, because embed code is <script> and Jekyll self-closed the tag (XML-style, but this is HTML). This is annoying.
It’s another Perl 6 changes article (at this point I wonder why I still do that). But as long the changes are impressive (and the cake is the lie), I guess mentioning changes is worth it.
Rakudo 2013.01 was tagged in the Git repository. It wasn’t yet released, but it’s really close to the releease (and frozen).
** 0 in regexpes works correctly matching nothing.$variabel when you already have $variable declared hints that variable.printf tries to consume more arguments than available.I’m going to show another Perl 6 changes article. I’m so lazy, that I really don’t know what to put here, so I guess I’ll now show the list of new features.
--> (return type) acts more like a normal subroutine parameter.squish method, working like uniq utility in UNIX - it only removes elements if it is duplicate of previous element.require ::($module) 'something' syntax.$socket.read($bytes) now returns $bytes bytes, if possible. Previously it only read only 256 bytes.$object.My::Role::method() works correctly and uses correct self.try with CATCH returns Nil on exception, like it did without explicit CATCH.splice supports whatever star (*).Junction.Str now gives string, instead of junction with every element converted to the string.I have finally updated the number before ‘W’. Well, we have the new year - 2013. And because of that I would like to say ‘Happy new year!’.
This is yet another article in “Perl 6 changes”. I lately don’t put articles other than those, but I don’t have many ideas for those, really.
By the way, I find it interesting that no new posts on Planet Six appeared between my previous Perl 6 changes article and current Perl 6 changes article.
(|) signature (accepting anything), It’s worth handling because it’s commonly used for protos.X::Import::Redeclaration error message.perl6doc documentation.DateTime.Date now works correctly..pick now randomizes better on large ranges.infix:<->(Instant, Instant) now supported.This is last “Perl 6 changes” update in this year. Enjoy.
uniq method/subroutine, existing for long time in implementations is now mentioned in specification (with === semantics).s///, like s////g is now detected.TODO: Insert the description of changes. Also, mention that Rakudo 2012.12 (Warszawa) was released and that Rakudo isn’t Rakudo Star.
$_ variable is used, Rakudo assumes block. This could break your code if you were expecting a hash.my $a; { $a; my $a } is an error.for runs in sink (void) or list context, just like map (actually, for does exactly what map does). If you were depending on it, you can use eager do before for to force eager execution.X::Comp::Group exception. It’s used when compilation can produce multiple issues.my ($a, $a); only causes warnings, not fatal errors.X::Undeclared::Symbols exception for variables that weren’t declared, but used..message on Exceptions..perl output for a Pair that has key that is a Pair.X::Item is thrown for @a[NaN] or @a[Inf]. It isn’t incompatible change because it wasn’t working before anyway.So, this is yet another article in Perl 6 Changes series. (I know, those introductions are really boring, but would you like to see Lorem Ipsum Dolor instead)? As in previous week, Rakudo mainly improves Perl 6 parsing.
By the way, if you don’t know about Perl 6 Coding Contest, check it out. The challenges are rather easy if you had any programming language experience (if you don’t know Perl 6, check out Using Perl 6 book). If you still have questions, people in #perl6 can help you.
uniq has === semantics. It could break your programs if you for example were using uniq to remove identical arrays (previously they were converted to strings which did what you wanted, as long the strings in array didn’t contained space or you didn’t have array in array.“Two terms in a row” error message.
Information about what was expected, if possible.
$ perl6 -e '2 2'
===SORRY!===
Two terms in a row
at -e:1
------> 2 ⏏2
expecting any of:
postfix
infix or meta-infix
infix stopper
statement end
statement modifier
statement modifier loop
for 1..10 { say so 9999 == any(1..2000) } is 30 times faster (huge junctions are faster).
Added Texas versions of the Set and Bag operators, used in Bags and Sets article in Perl 6 Advent Calendar.
Rakudo Perl now informs about obsolete use of . to concatenate strings.
Implemented sub term:<foo>. Now 2 + 2 == 5 can be true for sufficiently huge values of 2 (not like it should be).
qww now works.
slurp now works without arguments.To begin with, I’ve made a post for Perl 6 Advent Calendar. If you were wondering why it was late, I will tell you - it’s actually early. Somebody else has claimed article for eighth day and forgot to upload it, so somebody had to put replacement article. I’ve moved my article from 12th day to 8th day, just so Perl 6 Advent Calendar could be continued. Moritz, to protect against that, put the just-in-case article about exceptions (it’s exceptional), if that would happen again.
Enough talking about Perl 6 Advent Calendar, as obviously this blog post isn’t about it. Every week, I describe changes in Perl 6 and its implementations. This is yet another article about changes.
Jonathan Worthington lately was working on improving syntax errors messages in Rakudo Perl. Now they are better and more accurate, just like they’re already in STD.pm6 or Niecza.
.join method isn’t O(N4) anymore.~ infix operator is faster.Rakudo Star 2012.11 was released with new impressive improvements (check my previous posts for more information). If you’re reading this, please check out the Perl 6 Advent Calendar - new posts are added daily.
~/.perl6/lib from @*INC.Str.indent ignores empty lines.X::Syntax::Regex::UnrecognizedMetachar.X::Syntax::Regex::NullRegex.X::Backslash::UnrecognizedSequence.X::Backslash::NonVariableDollar.--doc option now works.Str.indent ignores empty lines.Signature.ACCEPTS.make install now works.You know, -2 is highly connected to Perl 6. It’s valid syntax for -(2).
So, well, now that my code compiles (well, C code, not Perl 6 code :-)) I’ve time to describe Perl 6 changes, instead of simply doing what XKCD says - I shouldn’t waste time.
Rakudo Perl 2012.11 is now released. The change mentioned in this article is already in.
NativeCall module is now part of specification.trait_mod routines are evaluated in sink context.--> (return type) acts more like a normal subroutine parameter.:($a, $b) := \(1, 2) updates $a and $b instead of doing nothing.I’m already aware that my blog looks spammy because of all those Perl 6 changes posts. I would like to remove all that garbage, so I’m thinking about separate site for those posts (of course with proper redirects of my old URLs).
&foo when sub foo isn’t declared will make CHECK-time exception instead of returning Nil.<infix><prefix><space> sequence appears, user gets warning. This helps avoiding code like $a ~~~ $b which actually means $a ~~ (~$b).sub infix:[""]) isn’t allowed anymore.--optimize isn’t passed by default to Parrot when --parrot-option is specified.Top variable anymore allowing multiple Niecza interpreters running at once. It was being removed for two months.It’s another late Perl 6 changes article. Today the fun parts are adverbs, adverbs and adverbs. Oh, and blocks. And fixing bugs. Have fun playing with new features.
INIT {} block is now rvalue.our ($x, $y) works correctly.take and take-rw have correct return values.SET_FILE_LINE is now called only on exceptions that support it.FIRST, NEXT and LAST blocks are supported on various kinds of loops, previously it only worked for for loops.:exists and :delete adverbs.q:c[] (string with interpolated closures) now works.:p, :kv, :k or :v.I apologize for being late, Gabor Szabo. I simply forgot about writing this. This week, the main attraction is proper quote constructs support.
IO::Path.dir was removed. You’re expected to use IO::Path.directory instead. Also, named parameter in IO::Path constructor was renamed from :dir to :directory..foo-bar take precedence above method calls.rx and m allow delimiters other than // or {}.:w or :x are supported.andthen infix operator.:input-line-separator named argument..foo-bar take precedence above method calls.qw is unsafe and cannot be used in safe (sandbox) mode..foo-bar take precedence above method calls.Rakudo Star 2012.10 will be released soon, but before that will happen, I’ll list changes in Perl 6 specifications and implementations. Not many changes, but many of those are very important. Personally, I find custom operators precedences, << >> quotes and prototypes in core subroutines very impressive improvements - it was all done in one week.
<< >> quotes now support interpolation.eval now sees custom operators.${variable} now makes better error message.read now exists again in IO::Socket.@array.map: &sin.So, you may have heard that Travis is nice build testing service. It is - I even use it for my JavaScript projects. But, guess what will happen if somebody uses Travis incorrectly.
The problem is about one of the most commonly languages made by bad developers for bad developers. But this article isn’t about why this language is bad - we all know it. Technically, I would use PHP instead of Brainfuck if I would have choice between PHP and Brainfuck, but it would be choice between very bad and worse.
6 months ago, Davey Shafik though - everybody uses Travis CI, why PHP source code doesn’t. He wanted to add Travis CI to his projects, but after quick look he noticed he doesn’t have test cases in his code and he was too lazy to add them. So, why not add Travis CI to some project that already has test cases so he could see how Travis CI would work.
And so he did. He decided to ask PHP to add Travis CI to its source code. Of course, the reaction is obvious.
This is awesome, thanks!
If this gets merged in and you guys are interested in pull-request testing then shoot us a note at contact@travis-ci.org. This feature is currently being rolled out manually but we’d love to turn it on for php.
Cool, Travis is awesome.
FYI looking into it. General idea is great, have to read about travis, etc first.
After general “awesome” comments (seriously, do you know other words?) the code review started. For example, David Soria Parra complained about !! usage
define('TRAVIS_CI' , !!getenv('TRAVIS_PHP_VERSION'));
Of course, version below is better. I mean, it’s longer so it’s definitely better. Yeah… is any programmer using Boolean() function anyway in JavaScript (warning: not Boolean constructor - Boolean constructor is something you shouldn’t ever use as it’s always truthy).
define('TRAVIS_CI', (boolean) getenv('TRAVIS_PHP_VERSION'));
I’ve decided to look for explicit booleans. So, I made a search query and I’ve found answer on Stack Overflow.
$test_mode_mail = $string == 'true'? true: false;
I seriously don’t know what to think about this. It got 8 upvotes. It works - but it would be seriously stupid code in any language that isn’t PHP. I mean - $string == 'true' is boolean, so why use ternary operator for it? And WHY use ternary operator for it even if it wouldn’t be ternary operator. I’m not going to mention usage of ==, instead of ===, it doesn’t really matter in this case.
My solution would be like this:
define('TRAVIS_CI', isset($_ENV['TRAVIS_PHP_VERSION']));
But good design should avoid dynamic constants.
Anyway, Davey Shafik has changed !! into (bool)… hey, hasn’t David Soria Parra said him to use (boolean)… check. Those PHP aliases attack again. Why? Why converting to boolean could be done using two casts with only different name? Why converting to float could be done using three casts with only different name - (float), (double) and (real)?
But that isn’t real problem. The Travis CI change was merged. Now README page of PHP contains the “build status: failing”. I’ve decided to click that image - every single change had either “build status: failing” or “build status: unknown” (because of failure while doing git clone (possibly GitHub went down?)). PHP wastes time of Travis CI just to get “build status: failing” again.
After some time, David Soria Parra has decided to add e-mailing about failures to php-qa@lists.php.net.
What went wrong? Well…
notifications:
email:
recipients:
- php-qa@lists.php.net
on_success: change # [always|never|change] default: change
on_failure: always # [always|never|change] default: always
But… PHP always fails - so PHP Quality Assurance would get lots of useless messages. Well, the solution for PHP developers wasn’t to fix PHP issues, definitely not - that would be too clever for programmers that work on PHP. The fix for developers was to disable e-mail notifications.
notifications:
email:
recipients:
- php-qa@lists.php.net
on_success: never # [always|never|change] default: change
on_failure: never # [always|never|change] default: always
Now, I wonder why simply didn’t removed notifications: section. I mean, they gave e-mail and told Travis - whatever happens, don’t e-mail. I’m going to call this brillant.
After some time, David Soria Parra has noticed that he doesn’t have to give e-mail to PHP Quality Assurance. So, he removed it.
notifications:
email: false
Now I wonder why he didn’t removed whole section. He doesn’t want any notifications, so why have this section? So now, Travis CI does nothing and everybody ignores it. I mean, it compiles, but…
It has 1123 compilation warnings. It has 106 test failures (with 43 expected test failures), one expected SIGSEGV (wait…) and 70.4% code coverage. And it’s not about unimplemented features - those are simply SKIPed. No, it isn’t better in PHP 5.4 - I mean, PHP 5.4 has 103 test failures (with 43 expected test failures).
PHP developers - please fix every bug before implementing new features. Having codebase that constantly contains lots of test failures isn’t really fun.
If you are PHP user, I would advice you trying some other language, such as Perl (believe me or not, Perl is way better than PHP) or Python. Those languages are consistent and more structured than PHP. Annoyed by security issues? Those languages make it easier to protect against them.
If you still want to use PHP, use OOP everywhere and never use global variables (with the exception for $_GET, $_POST and $_SERVER of course). PHP is simply unusable without OOP. But still, I would recommend using other langauges. Also, use template engine and prepared SQL queries.
The older version of article was mentioning following syntax.
const TRAVIS_CI = isset($_ENV['TRAVIS_PHP_VERSION']);
Turns out that it doesn’t work. Why? Because constant value isn’t constant - it depends on environment variable existing. All you get is cryptic syntax error. PHP stupidly uses its grammar to annoy developer, even if this syntax would be allowed in other sane languages. For example, you cannot do func()(), just because grammar forbids that. I haven’t heard of other language with similar problems.
PHP Parse error: syntax error, unexpected 'isset' (T_ISSET)Instead, the solution should be more like this.
$travis_ci = isset($_ENV['TRAVIS_PHP_VERSION']);
It’s not constant. It shouldn’t be because it isn’t real constant.
I know I’m early today. It’s always better than being late. Well, Gabor Szabo requested that I should make those articles early Sunday. I’m going to instead write their early version late Saturday and update them with Sunday changes instead - I hope it won’t be too problematic.
Obviously, Perl 6 has changed, otherwise I wouldn’t write this.
Rakudo 2012.10 was released (not star, just normal Rakudo version) - it has code-name Tokyo which is host of YAPC::Asia 2012.
~/.perl6/lib will disappear from default include path in 2012.11. Instead, you will have to use ~/.perl6/$rakudo-version/lib.Str.trim-leading and Str.trim-trailing.Any is a class.s[] in now detected correctly.- in character classes, using \- is also suggested in addition to ...Fixed multi-dispatch segfaults that could happen in certain cases.
Pod tests now pass on Win32.
/ :is / isn’t allowed anymore, before it was parsed as / :i s /.
Importing of custom meta-objects only affects their scope.
<-> (is rw lambdas) now parses correctly.
Nested delimiters like q[ [] ] are parsed correctly - previously Rakudo was thinking that string is q[ ]].
It’s now possible to create class methods using ::("name") syntax.
Rakudo now searches for modules in following locations:
$install-path/lib/parrot/$parrot-version/languages/perl6$install-path/lib/parrot/$parrot-version/languages/perl6/vendor$install-path/lib/parrot/$parrot-version/languages/perl6/site~/.perl6/$rakudo-version/libeval now sees correct context.
Redeclaration of class as role gave confusing “Method 'add_possibility' not found for invocant of class 'Perl6::Metamodel::ClassHOW'” error message. Now it simply informs about redeclaration of name.
< a b c > in regular expressions now respects :i flag.
Parcels and Lists can be converted to Arrays using .Array method.So, I apologize for forgeting about doing this yesterday. It’s another boring Perl 6 changes report. I’m going to make another blog post soon, but as you can see, I’m sort of lazy, so all I have for now is “Perl 6 changes” article. Enjoy.
has $.foo is now allowed to extend method foo { ... } in role, just like it would be real method.:handles trait mod.x in pack..substr now can have Inf as last argument.ByteBuffer now can be serialized when using --target=pir.perl6 -e code can begin with - sign.$*CUSTOM-LIB magic variable.$installpath/lib/parrot/$parrot-version/languages/perl6/custom-lib..gamma, .expm1 and .log1p, .erf methods are now implemented.$*CUSTOM-LIB magic variable.So, well. At beginning of this week, Rakudo Star was released. All changes on this list aren’t in current Rakudo version. So, well. It’s time for another Perl 6 changes report. It’s not revolution, it’s evolution.
:ss now implies :s.:ii now implies :i.:mm now implies :m.(?i) modifier was added.:ii now implies :i.X::NoSuchSymbol typed exception.:ss now implies :s..classify and .categorize now return hashes.Lately, I have made yet another plugin for DuckDuckGo (this time it isn’t connected with Perl 6 - but hey, it’s mine).
So, well, I have seen times like 11:00 EST. The problem is - what hour it is actually. So, I can do query like:
11:00 EST into GMT+1And it will reply me.
11:00 (EST, UTC-5) is 17:00 (GMT+1)Also, you can skip timezone and it will think it’s GMT - it’s rather common today. While fixing GMT is easy, it’s very likely that you meant that.
So, well. It’s likely to be very quickly applied to DuckDuckGo - they already have said they’re ready to deploy the plugin in pull request.
Rakudo Perl 6 still wasn’t released, but likely it will be released soon - currently it isn’t released because of bug in Parrot causing every line while reading files to be got when requesting one - using older Parrot version is considered too. If you’re waiting for Rakudo 2012.09 release, just be patient. Anyways, let’s mention Perl 6 changes for that week.
I’m aware that changes aren’t really impressive, but hey - not every week is impressive. And today it’s more important to make Rakudo Perl work for delayed 2012.09 release than add lots of new features.
eqv now avoids undef warnings.Signature now supports ~~ operator.&trait_mod:<is>.onlystar eqv Truemy (:$a, :$b) := foo() now works.is hidden trait and hides is implemented.:60[23, 59, 59] is now supported - this syntax allows for arbiarily high bases (higher than 36).expmod works on big integers.Another week, another Perl 6 changes report. I hope that changes mentioned on this list will be exciting. Developers still work on Perl 6 - actually they have worked since 2000. Rakudo is still slow, but it’s on average 30 times faster compared to Rakudo Star 2010.07 (but please note that 120% of statistics are made up).
This week is special because Niecza v22 was released - all changes on this list are in current Niecza release.
LAZY statement prefix was removed.chr has prototype of proto sub chr(|) {*}. In 2012.11, it will have proto sub chr($) {*} as prototype.expmod. It’s optimized version of $variable ** $power % modulo.is-prime. As name says, it checks if integer is prime number.q:val// is now parsed.CHECK time.s/has/as/).require to clobber GLOBAL.KeySet (the class itself, not its objects) now can be stringified without following error: “Parameter '' requires an instance, but a type object was passed”.Mu because it has less methods than Any. This way, action methods are less prone to name conflicts. The real fix for the problem will appear in future.expmod.is-prime.IO.flush method to manually flush filehandle.prompt now uses flush on $*OUT.is_dispatcher from Code to Routine. It didn’t worked on Code anyways as it depended on attribute from Routine.hypot subroutine. It implements Pythagorean addition.expmod.is-prime.ln now handles big integers.cmp can compare hashes.Starting with this week, I plan mentioning changes in Perl 6 and its implementations just so you will know what to expect, so you could update your code and use new features in your code to simplify old logic.
@array-of-hashes»<key> which recursively iterated hash values in array.Str.capitalize was deprecated and will be removed in Rakudo 2012.11. You’re expected to use Str.wordcase instead.require now returns module it has imported.List.duckmap. This method evaluates expression for every element. If map function will give undefined value, List.duckmap is applied recursively to every element if it’s list.List.deepmap. It works like List.map, except it’s recursive when element has Iterable role.-foo => 'bar' form is now allowed in Perl 5 part of grammar.${0}, $(-1) is not recommended instead as replacement anymore.$^N now recommends $[*-1] instead of $-1.$|++.Str.wordcase was implemented.
{*} can be used in proto to run actual code.
# Memoize function
proto complex-calculation($argument) {
state %cache;
%cache{$argument} //= {*};
}
multi complex-calculation (Int $argument) {
rand + $argument;
}
The first matching constrained candidate rule for multi-dispatch is now used instead of returning error. This causes is default to be optional in cases like this:
multi sub fizzbuzz(Int $ where * %% 15) is default { 'FizzBuzz' }
multi sub fizzbuzz(Int $ where * %% 5) { 'Buzz' }
multi sub fizzbuzz(Int $ where * %% 3) { 'Fizz' }
multi sub fizzbuzz(Int $number ) { $number }
(1 .. 100)».&fizzbuzz.join("\n").say;
infix:<X> is now somewhat faster.
Perl 5 regexes now can match non-alphanumerics without a meaning as literal characters and \B (not a boundary) is now implemented correctly.
run doesn’t throw exceptions on Windows platforms.
General performance improvements in NQP thanks to implementing lexical natively typed variables.
$variable.Str when $variable is Mu shows “use of uninitialized $variable of type Mu in string context” as it should instead of confusing “Method ‘VAR’ not found for invocant of class ‘Mu’” error message.
pandaSo, do you want to install panda? You have managed to somehow install Rakudo using git. Well, you were doing it wrongly - you should instead have used Rakudo Star which includes it.
Oh, you don’t want to wait again for Parrot, NQP and Rakudo to install. Well, it’s possible. It’s not easiest thing ever, but it sort of works.
What you have to do depends on whatever you have installed panda before (so it worked) or you haven’t.
panda beforeWell, this is rather common. First, run following shell command.
which perl6
It will tell you what perl6 will be used. If it says location in home directory, you should be fine. But if it says stuff like /bin/perl6 or /usr/bin/perl6, you should fix it - in current version panda runs perl6 at certain points. You wouldn’t want panda to run outdated version of Rakudo your system could have (also, remove your system Perl 6 if you want to be safe - you won’t need it).
So, you want to fix. Let’s assume your shell is either bash or zsh - all you have to do is modify either .bashrc or .zshrc and add following line at end, where [bin-path] should be replaced with your path to Rakudo’s /bin directory (on my system it’s ~/rakudo/bin).
export PATH="[bin-path]:$PATH"
Close your shell and run it again. Just to be sure, run which perl6 again. If your perl6 is in correct location you can continue.
Download panda using following command if you haven’t already.
git clone https://github.com/tadzik/panda.git
And run bootstrap script.
cd panda
./bootstrap.pl
Congratulations, you have working panda now! If you want, add panda to your path, by modifying $PATH you have added before. Of course, as said before, modify [panda-bin-path] and [bin-path] with correct paths.
export PATH="[panda-bin-path]:[bin-path]:$PATH"
panda beforeJust install panda like normal module.
panda install panda
Wasn’t that simple?
Four years ago November appeared. I’ve tried to use it. It simply doesn’t work today - Makefile tries to precompile Digest before Digest::SHA causing error (by the way, this module is called Digest::SHA256 when I’ve wrote this post, and it’s likely that it will change name to Sum::SHA256 in future and will use interface of other Sum:: namespace modules).
glitchmr@strawberry ~/g/november> env PERL6LIB=lib make
perl6 --target=pir --output=lib/Digest.pir lib/Digest.pm
===SORRY!===
When pre-compiling a module, its dependencies must be pre-compiled first.
Please pre-compile lib/Digest/SHA.pm
make: *** [lib/Digest.pir] Error 1You would think that compiling Digest::SHA manually would solve the problem? Technically yes, but…
glitchmr@strawberry ~/g/november> perl6 --target=pir \
--output=lib/Digest/SHA.pir \
lib/Digest/SHA.pm
===SORRY!===
pir::load_bytecode missing a signatureSo, what’s wrong with Digest::SHA. Well, that was its source.
class Digest::SHA:auth<thou>:ver<0.01> {
pir::load_bytecode('Digest/sha256.pbc');
multi method sha256_hex (Str $str) {
my $sha256_hex = Q:PIR {
.local pmc f, g, str
str = find_lex '$str'
f = get_root_global ['parrot'; 'Digest'], '_sha256sum'
$P1 = f(str)
g = get_root_global ['parrot'; 'Digest'], '_sha256_hex'
$S0 = g($P1)
%r = box $S0
};
return $sha256_hex;
}
multi method sha256_hex (@strs) {
return self.sha256_hex(@strs.join(""));
}
}
As you can notice, it depends on Digest/sha256.pbc from Parrot. Because of that, this module is Rakudo specific, but in this case it doesn’t matter much (perl6 is Rakudo).
What is the problem? Well, error message explains it - in Rakudo, you have to specify types of input and output every time you call any Parrot function directly. Why it was working before? Well, Rakudo didn’t required you to specify types before, but now it does (Why? I have no idea, NQP doesn’t require you to specify signature in this case). Anyways, the fix would be to type pir::load_bytecode__vS instead (v means void return and S means boxed string as argument).
I could try continuing, but that would be waste of time - November is simply old. The source code is unlikely to work in current Rakudo version (current Rakudo version is simply too modern for November to work).
It’s not just November, many modules in modules list simply won’t work in newest Rakudo version. This is normal - authors are simply too lazy to update their modules or they don’t work on those anymore (by the way, if you’re interested, make a fork of one of those modules, fix them and send pull request - even small help is good for Perl 6 community).
Why? Well, Perl 6 Synopsis is changing to improve language. Most of those changes are minor and usually wouldn’t break any program that wouldn’t try to detect those changes. But in certain cases, Synopsis needs bigger chances which could break more complex programs (Perl 6 is still in development, sometimes design is just wrong enough to justify breaking backwards compatibility). Also, Rakudo developers took lesson from this breakage - since 2012.07 every incompatibility is mentioned.
First of all, I would like to apologize for my rather weak English. It’s not my native language and I still learn it (but, my English is way better than two years ago, so I guess it’s good enough).
So, you may have heard about p6doc, the project which started 2 months ago. According to moritz, it’s intended to be comprehensive place where you can direct people to. It doesn’t yet describe everything (for example Str.indent wasn’t described when I’ve wrote this blog post), but it’s very likely that when you read this blog post it’s already described - everything is added to documentation rather quickly :-). And you can contribute it with ease, just modify a page and send pull request.
But, while the p6doc is already easy to use, finding stuff in it takes time, you have to type doc.perl6.org in your browser bar, press CTRL+F (well, I usually press dot, but this only works in Opera), type name of method and click the method. While it’s fast already, it could be faster.
Of course, there is perl6doc tool activated from command line, but currently it’s rather slow (according to time utility rendering Str.split took 4 seconds). But when Perl 6 implementations will improve their performance, it could be acceptable.
The problem is - HTML page requires effort of entering it and perl6doc is currently too slow to be acceptable for anything. But perhaps there is possibility of nicer way which would combine performance (as in, pages render nearly instantly) of HTML version and performance (as in, you can easily access it) of perl6doc tool.
Lately, I have contributed module for DuckDuckGo (if you aren’t using DuckDuckGo, why not?), to add search for Perl 6 documentation. It shortens the process of entering p6doc to simply typing “perl6 chomp” in search bar (and pressing enter). If this isn’t simple, than what is?
Try it at DuckDuckGo.