First of all, let's bring your code up to date, and clean it up to something someone might actually write:
while ($s=$n.accept()) {
print $s.gets; } #What's being printed? $_ isn't being set # anywhere. print if f($s+%hf) == $b; $a = "abc"~$b~$c~$d~"def"~getVar($d); #I don't know what construct you think that was, # or why you were making some of the assumptions # you did, but here's how that would really be # written. (I almost used map, but you don't do # that in void context--it's wasteful. This is # a Perl 5 style rule that carries over to 6.) for zip @a, @b -> $a is rw, $b is rw {
$a > $b ?? 1:: ($a, $b):= ($b, $a); } @b = + @c; #Syntax error on the next line. @a = += @b; @b = + @c; #Syntax error. @a = += @b; @a >>+=<< @b; @a >>+=<< @b;
Now, as best as I can figure, here's how a decent Perl 6 hacker would write it:
while ($s=$n.accept()) {
print $s.gets; } print if f($s+%hf) == $b; $a = "abc" ~ $b ~ $c ~ $d ~ "def" ~ getVar($d); # or $a="abc$b$c${d}def&getVar($d)", perhaps. for zip @a, @b -> $a is rw, $b is rw {
($a, $b):= ($b, $a) unless $a > $b; } @b = +@c; #Not touching this till I know what it is. @a = += @b; @b = +@c; #Likewise. @a = += @b; @a >>+=<< @b; @a >>+=<< @b;
Now, if I may demonstrate something a bit more realistic:
#Log analysis script. use Apache::ParseLog <<parse_lines>>;
my(%goodbad) = part {
given (.status ~~/(\d)\d\d/)[0] {
when 2|3 { 'good' }
when 1|4|5 { 'bad' }
'malformed';
} } parse_lines(open "access_log" or die);
say "Successful Requests: ", +%goodbad{'good'}; say "Unsuccessful Requests: ", +%goodbad{'bad'};
The only parts that need much explaining are that (a) part is a built-in that divides a list up into categories; (b) given/when is a switch construct; and (c) say is how Perl 6 spells "printline". While there are some new operators in there, their meaning is fairly intuitive.
The rest should be reasonably clear to a Perl 5 hacker. Note that the weird parts were not the operators--they were new functions, each of which added some new functionality to Perl.
sub postfix:^_^ (Bool $operand) is looser(&infix:or) {
$operand or die "Statement is unhappy: $!"; } my $fh=open "$filename" ^_^;
Yes, that really is perfectly valid Perl 6, and it pretty much does exactly what you think it does. (The 'is looser' specifies the precedence--my new ^_^ operator has a slightly lower precedence than 'or', but a higher one than the next built-in level of precedence.)
Perl 6 has ridiculously powerful macros--they're essentially subs that are run at compile-time, which return either strings of code or fragments of parse trees. I believe that makes them about as powerful as Lisp's.
Actually, in Perl 5, a mechanism called a source filter allowed you to modify the code (in string form) before Perl ever parsed it. It was a pain in the ass to use, but a few really cool things were done with it, like Damian Conway's Switch.pm module. Still, I wouldn't argue that it was anywhere near Lisp's level.
Actually, considering that Perl actually has syntax, and that Perl 6 macros can go anywhere that Perl 6 subs can (e.g. creating new operators), you could argue that Perl 6 macros are more powerful than Lisp ones...
To my knowledge, Perl 6 will only have four variable names consisting entirely of punctuation:
$_ current topic (often, the object a method was invoked on) @_ default argument list for subs %_ extra named arguments on methods &_ current subroutine
On the other hand, there will be a decent number of variables with punctuation in their names:
$.x @.x %.x Object public data member $:x @:x %:x Object private data member $?x @?x %?x "Hypothetical" variable (used mainly for backtracking in grammars) $^x @^x %^x Autodeclared parameter (can be used with map, sort, grep, etc.) $*x @*x %*x True global variable ($*IN, $*OUT, $*ERR, @*ARGV, $*OS...)
Most of the old punctuation variables are becoming true globals. (By the way, you can leave the * out of those if there isn't another variable by that name in scope.)
Even that looks like a lot, but remember:
$.x and $:x are only used by people writing classes. (People using classes others have written won't be exposed to them.)
$?x is only used by people doing fairly advanced parsing, like language grammars.
$^x is completely optional--it can be used like "sort { $^a cmp $^b } @list", but you can also say "sort -> $a, $b { $a cmp $b } @list", or even write a full subroutine and write "sort your_sub_here @list".
The star in $*x is not usually needed--it's only needed if you have a similarly-named variable somewhere in scope.
The holes in the pattern could indicate where more operators will be added. For example, there are multiplication equivalents for numbers, strings, and lists (*, x, and xx), but there are only addition/concatenation operators for numbers and strings (+ and ~). The pattern suggests that there should be a list concat operator, and that it should be ~~ (although that's already taken by smartmatch).
I apologize for my ignorance, but couldn't you just use parentheses to enforce precedence instead of having separate operators?
Certainly--this is the reason we don't have (e.g.) a low-precedence 'add' binary op. However, one of Perl's standard idioms is the use of short-circuiting 'or' for error handling:
#Perl 6 'open' returns a filehandle instead of # taking one as a parameter. $fh=open "$filename" or die "Can't open $filename: $!";
#Perl 6 'system' returns 0 but true on success. # (Perl 5 just returned a plain old zero, so you # had to test it with 'and' instead of 'or'.) system "/bin/ls $dir" or die "Can't start/bin/ls: $!";
In both of the above cases, you could use parens, but the lack of parens plus the 'or' instead of '||' makes the code more readable. (And yes, believe it or not Perl hackers do occasonally worry about readability.)
There's no exact pattern, but in general similar operators are grouped together. For an example take a look at the bitwise/charwise/boolean and/or/xor, and the fact that xx (list repetition), x (string repetition), and * (multiplication--like number repetition) are in the same column. Additionally, True Operators below about the midline of the table tend to be lvalues (able to be assigned to), although that isn't quite consistent.
By the way, there is at least one operator that this table predicts should exist: list concatenation. Well, except that you can just push the elements on to the end of the array, or use an idiom like @c=(@a, @b).
(Hmm...could comma be considered the list concatenation operator?)
Does **= really take up a big slice of brain tissue to remember? It fits an overall pattern perfectly, and is quite clear to anyone familiar with += and **.
Remember, you don't have to use every operator in every Perl program. You should use a subset of the language that you're comfortable with and that allows you to do the work you need to do.
Larry Wall felt that inline if wasn't a common enough operation to lose both question mark and colon to. He also likes to point out that, like || and &&, ??:: is a short-circuiting logical operator.
Why is "&&" different from "and"? Ditto for "||" and "or", etc.
Different precedence levels. This already exists in Perl 5.
"." is now "~"?
Yes. Larry wanted dot to be used for method calls, since objects are becoming much more prevalent in Perl 6. The tilde wasn't being used for anything terribly important (1's complement), so he stole it and made something else do 1's complement; it's supposed to remind you of a little piece of string.
Charwise operators?
Allow you to treat a string as a bit vector and perform bitwise operations on it. You can already do this in Perl 5 with the normal bitwise ops--Larry just split them out into separate operators for Perl 6.
And just to be pedantic, shouldn't all the "op=" operators be described as molecules formed from "op" and "="?
Yes, as should the bool/int/bitstring ops, and a lot of other things. That, IMHO, is the main flaw of this table, although I don't really know how to do it better.
but come on.. different types of compare operators that work on regular variables (one for numbers, one for strings)?
Perl has always had this. All Perl 6 values have a type like Int or Str, but this isn't necessarily useful--I/O in Perl is done exclusively with strings, so without casting (which already exists--the ~, + and ? unary ops, along with the 'as' binary op) all the comparisons would be with strings too.
Basically, you have to have the typing somewhere. Some languages have them in the values; Perl has them in the operators. It's a design trade-off.
If you really want a magical equality that Does The Right Thing, the smartmatch operator (~~) does a lot more than the old Perl 5 regex-binding (=~) ever did. You can pretty much hand it two arbitrary objects and it'll do something appropriate with them.
Perl 6 looks like a big language--and really, it is pretty big. The trick to learning it is to recognize the parallels. For example, throughout the language the question mark is used for boolean operations, plus for numeric ops, and tilde for string ops. (The tilde is supposed to remind you of a little piece of string.) This extends to ANDs, ORs, XORs, and NOTs as well--there are the parallel sets of operators ?&, ?|, ?^, ?!, +&, +|, +^, +!, and ~&, ~|, ~^, ~!, along with logical short-circuting &&, ||, ^^, and !, and junctive operators &, |, and &. (Yeah, there's a break in the parallelism there, for hysterical raisins. Junctive operators, btw, allow you to say things like "$foo == 1|2|3", but they're a fair bit more flexible than just that.)
Makes you wonder what sort of hooks the FBI has into AOL or other ISPs and what hardware identification is being transmitted at login.
If you actually read the article, nothing untoward happened.
Probably, Wells Fargo reported to AOL that computers with those accounts on them had been stolen--perhaps simply to keep them from buying anything on company money or anything. When AOL noticed the login, they notified the FBI, who used normal techniques to get the account information.
This is not a scary Big Brother scenario; rather, it's a great model for how corporations and government can and should cooperate to fight crime. Does anyone here really think that AOL acted improperly by giving them the address of a computer and identity thief?
Re:He says he never deliberately destroyed files
on
Kevin Mitnick Answers
·
· Score: 1
KM said that he never deliberately destroyed information, not files. I read this as meaning "files that have meaning outside of the context of a computer". A customer database contains information on people; a program contains instructions on how to perform a task. Log files only contain information on the performance of a system; they don't have any meaning outside of the context of a computer.
Not yet, at least. Remember, Parrot is still under development. We'll implement the safe interpreter stuff eventually, but it's not a priority right now. We still have more fundamental issues to handle, like subroutines and symbol tables.:^)
He probably means languages with people actively learning and writing all-new stuff in them. FORTRAN probably won't go away, but I expect that it will continue to stagnate as the people who only know it retire.
By that argument, they didn't discriminate aginst blacks in the South because they didn't grant any blacks the same rights as white people.
Believe me, many people thought that discriminating against blacks was for the common good. We realize now that they were wrong, but they thought that they were right. Perhaps the same thing is true of our age limits.
There are rare cases where children have successfully petitioned courts to declare them adults. I don't want that. I just want the government to recognize that I and many other people under 18 are generally capable of making decisions--at least in many cases where there aren't any long-term costs.
OK, they aren't a right. My bad. Still, by their inclusion in the Constitution, they're considered to be on the same level as the rights, and thus can't simply be struck down in favor of rights.
I recall clearly from junior high school that the constitution empowers the congress to make laws, except in those areas where the constitution forbids it.
Oh my God, American society is so fucked.
The exact opposite is true--Congress has no ability to create law on anything it isn't expressly authorized to legislate. Amendment 10 reserves everything else to the states and the people.
In the last eighty years or so, Congress has pulled some dirty tricks to allow itself to legislate on virtually anything. It's decided that if something is in some way (no matter how insignificant) related to interstate commerce or promotes the general welfare they can legislate on it. However, that was clearly not the Founders' intent. One of their main arguments for the Federal government's formation was that it was a government of limited and enumerated powers--it was only allowed to do what the Constitution said it could.
I'm not a legal scholar, but I know this anyway. For evidence, see amendment 10:
The powers not delegated to the United States by the Constitution, nor prohibited by it to the States, are reserved to the States respectively, or to the people.
That's the entire text of the clear, simple amendment.
Do they teach you at school that the Earth may not warm up and thus it is perfectly safe to pump more CO2 and other greenhouse gasses to the atmosphere?
No. The schools have been taken over by environmentalists who teach our kids about how horrible the things we're doing to the environment are. But American society teaches us to think for ourselves instead of just blindly believing whatever somebody tells us.
There still is an ozone hole. The Earth is warming up. Okay, the ozone hole is not so large as it was a few years ago, but this was because ozone-layer eating gasses were banned.
Have you ever thought that maybe the ozone hole was there before--but we didn't see it because we didn't have any satellites before?
Earth is below its average temperature over the last few thousand years. Most of the warming is in the coldest climates. (Tell the people in Siberia that we want to reverse the process that has put the average winter temperature at -38 instead of -40.) Fluctuations in the temperature are normal. Our "changes" to the environment are pretty insignificant. Nobody has ever given any hard evidence that the CO2 we're releasing is a problem.
Even if there is warming, we don't know what its effects will be. It could be bad--things like the ice caps melting--but it could also be good, like winters that are less harsh.
Global warming was invented by the environmental equivalent of Luddites--people who were afraid of any change because it was a change, not because it was a bad change.
Put all these facts together and I'm not willing to spend billions of dollars to combat global warming that may be normal and beneficial--if it even exists.
I haven't had much formal compsci training (yet) but I've always loved the way bottom-up parsers work. It's so counterintuitive at first glance, but when you finally grok it it's so simple.
I'm a sixteen year old Perl and C hacker. I have commit priviages on Parrot, and I've written at least five or ten source files and touched at least half of the files in the distribution.
And I have to lie to do much of anything online.
Within the OS community, I'm completely open with my age. Nobody cares about age--just skills. It's absolutely wonderful. The only other place I get that is in college classes.
But on the rest of the Internet I have to lie. I have to lie to get an instant messaging account, a webmail address, access to a news site, some web space, or a chat room. I have to lie to get API data from Palm, Microsoft and many other companies. Some of these places make it exceedingly easy to lie--for example, one videochat site just has you hit the submit button again, implicitly promising that a parent is submitting th eform this time. In others, you have to jump through hoops to do it. But in most cases it's pretty easy to lie.
It gets on my conscience, though. Every time I lie I feel like a cheat. Every time I pretend I didn't see the "by clicking this button, you agree that you are over eighteen" line, I feel like a bad person. But I do it anyway, because I can't do what I want and need to do otherwise.
I understand that this is necessary because of contract law. However, I think that points to a deficiency in contract law, not in kids.
I haven't thought very long on this issue, but at least one solution comes to mind. It follows the model of child labor laws. Before fifteen (which, incidentally, I think is older than is really necessary) you simply can't work. Between fifteen and eighteen you can work, but with restrictions on what you can do and how long you can do it for. At eighteen, you're free to sell your labor in any way you please.
Perhaps similar provisions should be written into contract law. For example, between age X and eighteen, you can enter contracts unless they obligate you to pay money or do work.
In any case, I believe that the current system is Evil and Wrong. We should fix it instead fo forcing kids to be liars.
First of all, you've gotta finish school--few companies will respect a coder who hasn't finished college. It's stupid, but it's true. While your schoolwork will probably be mind-numbingly boring, that's how schoolwork often is.:^) My suggestion is to find a project and work on it. I was getting pretty burned out until I started working on Perl 6's core--the problems I've faced in that project fascinate me and give me room to think about how to implement things. Building a build system or a regular expression engine from basically scratch are interesting projects, and they've made me like coding again.
I wish you the best of luck in finding happiness in coding again. In the end, that's all that matters.
The rest should be reasonably clear to a Perl 5 hacker. Note that the weird parts were not the operators--they were new functions, each of which added some new functionality to Perl.
Perl 6 has ridiculously powerful macros--they're essentially subs that are run at compile-time, which return either strings of code or fragments of parse trees. I believe that makes them about as powerful as Lisp's.
Actually, in Perl 5, a mechanism called a source filter allowed you to modify the code (in string form) before Perl ever parsed it. It was a pain in the ass to use, but a few really cool things were done with it, like Damian Conway's Switch.pm module. Still, I wouldn't argue that it was anywhere near Lisp's level.
Actually, considering that Perl actually has syntax, and that Perl 6 macros can go anywhere that Perl 6 subs can (e.g. creating new operators), you could argue that Perl 6 macros are more powerful than Lisp ones...
Even that looks like a lot, but remember:
The holes in the pattern could indicate where more operators will be added. For example, there are multiplication equivalents for numbers, strings, and lists (*, x, and xx), but there are only addition/concatenation operators for numbers and strings (+ and ~). The pattern suggests that there should be a list concat operator, and that it should be ~~ (although that's already taken by smartmatch).
Certainly--this is the reason we don't have (e.g.) a low-precedence 'add' binary op. However, one of Perl's standard idioms is the use of short-circuiting 'or' for error handling:
In both of the above cases, you could use parens, but the lack of parens plus the 'or' instead of '||' makes the code more readable. (And yes, believe it or not Perl hackers do occasonally worry about readability.)
There's no exact pattern, but in general similar operators are grouped together. For an example take a look at the bitwise/charwise/boolean and/or/xor, and the fact that xx (list repetition), x (string repetition), and * (multiplication--like number repetition) are in the same column. Additionally, True Operators below about the midline of the table tend to be lvalues (able to be assigned to), although that isn't quite consistent.
By the way, there is at least one operator that this table predicts should exist: list concatenation. Well, except that you can just push the elements on to the end of the array, or use an idiom like @c=(@a, @b).
(Hmm...could comma be considered the list concatenation operator?)
Does **= really take up a big slice of brain tissue to remember? It fits an overall pattern perfectly, and is quite clear to anyone familiar with += and **.
Remember, you don't have to use every operator in every Perl program. You should use a subset of the language that you're comfortable with and that allows you to do the work you need to do.
Perl has always had this. All Perl 6 values have a type like Int or Str, but this isn't necessarily useful--I/O in Perl is done exclusively with strings, so without casting (which already exists--the ~, + and ? unary ops, along with the 'as' binary op) all the comparisons would be with strings too.
Basically, you have to have the typing somewhere. Some languages have them in the values; Perl has them in the operators. It's a design trade-off.
If you really want a magical equality that Does The Right Thing, the smartmatch operator (~~) does a lot more than the old Perl 5 regex-binding (=~) ever did. You can pretty much hand it two arbitrary objects and it'll do something appropriate with them.
Perl 6 looks like a big language--and really, it is pretty big. The trick to learning it is to recognize the parallels. For example, throughout the language the question mark is used for boolean operations, plus for numeric ops, and tilde for string ops. (The tilde is supposed to remind you of a little piece of string.) This extends to ANDs, ORs, XORs, and NOTs as well--there are the parallel sets of operators ?&, ?|, ?^, ?!, +&, +|, +^, +!, and ~&, ~|, ~^, ~!, along with logical short-circuting &&, ||, ^^, and !, and junctive operators &, |, and &. (Yeah, there's a break in the parallelism there, for hysterical raisins. Junctive operators, btw, allow you to say things like "$foo == 1|2|3", but they're a fair bit more flexible than just that.)
Probably, Wells Fargo reported to AOL that computers with those accounts on them had been stolen--perhaps simply to keep them from buying anything on company money or anything. When AOL noticed the login, they notified the FBI, who used normal techniques to get the account information.
This is not a scary Big Brother scenario; rather, it's a great model for how corporations and government can and should cooperate to fight crime. Does anyone here really think that AOL acted improperly by giving them the address of a computer and identity thief?
KM said that he never deliberately destroyed information, not files. I read this as meaning "files that have meaning outside of the context of a computer". A customer database contains information on people; a program contains instructions on how to perform a task. Log files only contain information on the performance of a system; they don't have any meaning outside of the context of a computer.
Checking out books and driving on roads is a privilage, not a right.
Innocent people have nothing to hide. Only the guilty need to hide things
If this guy isn't a troll, we should just surrender to bin Laden now--America is completely f*cked.
Not yet, at least. Remember, Parrot is still under development. We'll implement the safe interpreter stuff eventually, but it's not a priority right now. We still have more fundamental issues to handle, like subroutines and symbol tables. :^)
He probably means languages with people actively learning and writing all-new stuff in them. FORTRAN probably won't go away, but I expect that it will continue to stagnate as the people who only know it retire.
He said the only currently available languages, not the only languages. Undoubtedly there will be other languages invented between now and then.
Believe me, many people thought that discriminating against blacks was for the common good. We realize now that they were wrong, but they thought that they were right. Perhaps the same thing is true of our age limits.
There are rare cases where children have successfully petitioned courts to declare them adults. I don't want that. I just want the government to recognize that I and many other people under 18 are generally capable of making decisions--at least in many cases where there aren't any long-term costs.
OK, they aren't a right. My bad. Still, by their inclusion in the Constitution, they're considered to be on the same level as the rights, and thus can't simply be struck down in favor of rights.
Oh my God, American society is so fucked.
The exact opposite is true--Congress has no ability to create law on anything it isn't expressly authorized to legislate. Amendment 10 reserves everything else to the states and the people.
In the last eighty years or so, Congress has pulled some dirty tricks to allow itself to legislate on virtually anything. It's decided that if something is in some way (no matter how insignificant) related to interstate commerce or promotes the general welfare they can legislate on it. However, that was clearly not the Founders' intent. One of their main arguments for the Federal government's formation was that it was a government of limited and enumerated powers--it was only allowed to do what the Constitution said it could.
I'm not a legal scholar, but I know this anyway. For evidence, see amendment 10:
That's the entire text of the clear, simple amendment.Er, copyrights are a Constitutional right.
No. The schools have been taken over by environmentalists who teach our kids about how horrible the things we're doing to the environment are. But American society teaches us to think for ourselves instead of just blindly believing whatever somebody tells us.
Have you ever thought that maybe the ozone hole was there before--but we didn't see it because we didn't have any satellites before?
Earth is below its average temperature over the last few thousand years. Most of the warming is in the coldest climates. (Tell the people in Siberia that we want to reverse the process that has put the average winter temperature at -38 instead of -40.) Fluctuations in the temperature are normal. Our "changes" to the environment are pretty insignificant. Nobody has ever given any hard evidence that the CO2 we're releasing is a problem.
Even if there is warming, we don't know what its effects will be. It could be bad--things like the ice caps melting--but it could also be good, like winters that are less harsh.
Global warming was invented by the environmental equivalent of Luddites--people who were afraid of any change because it was a change, not because it was a bad change.
Put all these facts together and I'm not willing to spend billions of dollars to combat global warming that may be normal and beneficial--if it even exists.
I haven't had much formal compsci training (yet) but I've always loved the way bottom-up parsers work. It's so counterintuitive at first glance, but when you finally grok it it's so simple.
And I have to lie to do much of anything online.
Within the OS community, I'm completely open with my age. Nobody cares about age--just skills. It's absolutely wonderful. The only other place I get that is in college classes.
But on the rest of the Internet I have to lie. I have to lie to get an instant messaging account, a webmail address, access to a news site, some web space, or a chat room. I have to lie to get API data from Palm, Microsoft and many other companies. Some of these places make it exceedingly easy to lie--for example, one videochat site just has you hit the submit button again, implicitly promising that a parent is submitting th eform this time. In others, you have to jump through hoops to do it. But in most cases it's pretty easy to lie.
It gets on my conscience, though. Every time I lie I feel like a cheat. Every time I pretend I didn't see the "by clicking this button, you agree that you are over eighteen" line, I feel like a bad person. But I do it anyway, because I can't do what I want and need to do otherwise.
I understand that this is necessary because of contract law. However, I think that points to a deficiency in contract law, not in kids.
I haven't thought very long on this issue, but at least one solution comes to mind. It follows the model of child labor laws. Before fifteen (which, incidentally, I think is older than is really necessary) you simply can't work. Between fifteen and eighteen you can work, but with restrictions on what you can do and how long you can do it for. At eighteen, you're free to sell your labor in any way you please.
Perhaps similar provisions should be written into contract law. For example, between age X and eighteen, you can enter contracts unless they obligate you to pay money or do work.
In any case, I believe that the current system is Evil and Wrong. We should fix it instead fo forcing kids to be liars.
I wish you the best of luck in finding happiness in coding again. In the end, that's all that matters.