Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror

Comment Re:BS (Score 1) 167

Perl 6 has a similar feature: gather / take.
( with Python's yield being roughly the same as take )
The reason for for the gather is that it requires you to be explicit about where the generator is, unlike Python which is implicit.

my @even = gather loop { take $ += 2 };
say @even[^10]; # (2 4 6 8 10 12 14 16 18 20)


Which in this case would be better written as

my @even = 2,4,6 ... *;

Here is another example.

# note that this isn't a generator on it's own like it would be in Python
sub roll-die () { take ("\c[DIE FACE-1]".."\c[DIE FACE-6]").roll }

sub weird-list (){
gather {
take 1;
take my $a = 3;
take ++$a for ^10;
roll-die();
}
}

Comment Re:Ternary Fail: "??", "!!" (Score 2) 167

Considering the Regex code that I see in Perl 6 is easier for me to read than the Perl 5 equivalent. I have more than a decade's worth of experience with the latter, but only a couple years worth in the former. I would definitely say it is worth it.

I would like to see a conventional regex for JSON that is easier to read and understand than JSON::Tiny::Grammar.

Everything that was broken deserved to be broken, and was replaced by a much more generally useful feature.

( That said there is an adverb that you can add to regexes so that you get the Perl 5 semantics )

Comment Re:Perl 6 for Perl 5 developers (Score 1) 281

I wouldn't make any major applications in it just yet, but there are people who have said that they have used it in production in smaller roles.
Really it is a fairly big departure from pretty much all other languages including Perl 5, so I would recommend just tinkering with it for a while.
There is an Inline::Perl5 for Perl 6 and an Inline::Perl6 for Perl 5, so you could write small tools in Perl 6 that integrate with your existing Perl 5 codebase.

Comment Re:what do you think about the perl guy? (Score 1) 281

They aren't bugs in the language they are design decisions made in very early versions of the language, back when it was basically just a combination of sed awk sh and C.
None of those languages has lists of lists, not like modern languages anyway.
It wasn't until Perl 5 that arrays of arrays without using symbolic references was possible, and that came out before the first version of Java in 1994 (It had features even back then that Java didn't, like closures and lambdas).
I find it amazing just how capable it can be and still maintain over 90% compatibility all the way back to Perl 1 from 1987.
I mean there is probably a bigger difference between Perl 5 of 10 years ago, and that of today, than between Python 2&3, but upgrading Perl isn't that big of a deal.

As to calling subroutines or methods inside of a key value argument list, I thought everybody knew that you have to either put scalar in front of it, or do something else to make sure it doesn't clobber the rest of your arguments, like put it in an anonymous array ref.

Also any argument about Perl 5 coming from someone who thinks that @list is a list should be taken with a grain of salt.
I mean I think that was literally the only time I have ever seen a Perl 5 array named @list. ( other than right here of course )

Comment Re:Just one question (Score 1) 281

The problem was that the edges of what was possible to do were starting to show, and some of the design decisions were difficult for new Perl programmers to learn.
None of that could be changed without major backward compatibility breakage.

We're talking changes bigger than that of Python 2amp;3.

The main thing I like about Perl 6 is that it has many features from many languages, but manages to combine them in a way that they all seem like they have always belonged together.
How many other languages have a class based regular expression system that doesn't seem tacked on?
I once came across a Python project that attempted to replicate it, but not only was it tacked on, it wasn't even class based as far as I could tell.
( there didn't appear to be a way to subclass a grammar, and the tokens/rules didn't appear to be methods )

Comment has Perl 6 flopped? (Score 1) 281

How could it have flopped in just 6 months? Especially as I regularly see new people on irc.freenode.net#perl6. (we also had to split up the channel because it was getting difficult to discuss the actual implementation because of all the activity)

I will grant you that the Perl 6 project is a lot older than that. I'm actually glad it wasn't a rush job, just image how bad of a language it would have been as a result <cough>php</cough>.

You're probably one of those people who are deluded into thinking that Perl25 is on its deathbed. In fact there has been more activity on the Perl5 core in the past 5 years than there was on the previous 10 years. ( Actually a similar thing could be said about Perl6 as well )

Comment Re:Perl6 greatest failure (Score 1) 145

Why would you think that is a reference? We're talking about Perl 6 not C. That is a term definition, which is a bit like a constant alias, or static single assignment.
One of the things I really like about Perl is that when you are reading the code you can instantly recognize the variables.
Also you can add new operators by simply adding a subroutine. ( In fact all of the operators except the hyper and meta operators are implemented that way in Rakudo )

sub postfix:<!> ( UInt $n ) is tighter(&[,]) { [*] 2..$n }
say 5! ; # 120
say (0..10)>>! ; # (1 1 2 6 24 120 720 5040 40320 362880 3628800)

say infix:<+> 4, 5; # 9

my &square = &infix:<**>.assuming(*,2);
say square 5; # 25


By allowing you to create new operators it is hoped that you won't do something stupid like use << for IO or + for string concatenation.

Comment Re: PHP vs Perl (Score 1) 145

The most recent version of Perl5 has experimental support for subroutine signatures. ( I doubt it will change incompatibly before it is no longer experimental. )

Slashdot Top Deals

Why won't sharks eat lawyers? Professional courtesy.

Working...