peczenyj
Moderador
![[Avatar]](/images/avatar/299dc35e747eb77177d9cea10a802da2.jpg)
Membro desde: 26/03/2006 23:25:37
Mensagens: 3191
Localização: Rio de Janeiro
Offline
|
Se vc sabe Perl 5, este link é delicioso
http://perlgeek.de/en/article/5-to-6
senão conhece, vale ler
http://www.perl6.org/documentation/
A evolução da linguagem faz sentido. É claro que, se vc acha estranho preceder variáveis por um $ (ou arrays de @ e hashes de %) porém se no passado isso ajudou o interpretador hoje faz parte do idioma. O fato é que a linguagem ousa unir todos os paradigmas além de prover mecanismos para alterar a sua própria linguagem, lazyness, e por ai vai.
Vou colocar alguns exemplos interessantes. A linguagem tem MUITO ruído e isso não vai mudar (comparando com ruby, que é perfeito para alguns tipos de DSLs) porém basta pratica.
Basic Control Structures
You can also use more than one loop variable:
Multi Subs - coisa que sinto falta em algumas linguagens
Objects and Classes:
Apresentando as Roles, que lembram as Interfaces/Modulos/Classes Abstratas
Regexes
Junctions - inspirado na mecanica quantica!!
Ja citada Laziness
Em especial
Controlling Laziness
Laziness has its problems (and when you try to learn Haskell you'll notice how weird their IO system is because Haskell is both lazy and free of side effects), and sometimes you don't want stuff to be lazy. In this case you can just prefix it with eager.
On the other hand only lists are lazy by default. But you can also make lazy scalars:
Custom Operators
Subset types
Por fim, a sub MAIN
Se alguem quiser se aventurar, sugiro entrar nas listas de perl, baixar o Rakudo que é a implementação mais completa até o momento e usar, por exemplo, a IDE chamada PADRE.
De fato Perl sempre abusou de operadores (não seria de admirar que ampliaram as expressões regulares), por outro lado a evolução para a versão 6 é absurda. Uma linguagem imperativa que tem suporte a laziness, por exemplo, é fantástico. Some ao fato que a linguagem suporta 3 formatos de goto
The first form causes the current execution point to jump to the point referred to as LABEL. A goto in this form cannot be used to jump into a loop or external function.you can only jump to a point within the same scope.
The second form expects EXPR to evaluate to a recognizable LABEL. In general, you should be able to use a normal conditional statement or function to control the execution of a program, so its use is deprecated.
(minha favorita) The third form substitutes a call to the named subroutine for the currently running subroutine. The new subroutine inherits the argument stack and other features of the original subroutine; it becomes impossible for the new subroutine even to know that it was called by another name.
Se com C é fácil dar tiros no pé, com Perl vc faz uso do próprio Darth Vader.
Agora, isto é divertido++
Perl 6 embraces the idea of multi threading, and in particular automated parallelization. To make sure that not all threads suffer from the termination of a single thread, a kind of "soft" exception was invented.
When a function calls fail($obj), it returns a special value of undef, which contains the payload $obj (usually an error message) and the back trace (file name and line number). Processing that special undefined value without check if it's undefined causes a normal exception to be thrown.
In this example the hyper operator tells map to parallelize its actions as far as possible. When the opening of the nonexisting file fails, an ordinary die "No such file or directory" would also abort the execution of all other open operations. But since a failed open calls fail("No such file or directory" instead, it gives the caller the possibility to check the contents of @handles, and it still has access to the full error message.
If you don't like soft exceptions, you say use fatal; at the start of the program and cause all exceptions from fail() to be thrown immediately.
Lembra alguma coisa? Hehe.
This message was edited 1 time. Last update was at 02/02/2010 23:34:17
|