[Israel.pm] Fwd: [Telux] Next Meeting: "High-Level Programming Concepts Using Perl 6" on 22-March

Shlomi Fish shlomif at iglu.org.il
Sat Mar 14 09:35:15 PDT 2009


On Saturday 14 March 2009 17:42:28 Evgeny wrote:
> Thanks Shlomi,
> From the previous reply by Gabor I already understand that when I pass an
> array into a function then I can just use "shift" multiple times and it
> will give me that array's members. Like you said, because perl clobbers it
> into @_.

Yes. In Perl (as opposed to Common Lisp, Scheme, Python and other languages - 
not sure about Ruby), lists are not references, but rather directly supported 
and manipulated by the syntax of the language. So you can say ($x, $y) to 
create a list of two elements, which can later be assigned to an array, or 
<< my ($x, $y, $z) = {EXPR returning List}; >>> to assign from it. And 
functions accept lists and return lists.

I showed one perceived advantage of that, in a previous post to Perl-IL and 
Ruby-IL by using it to flat-concatenate a list of arrays like so:

{{{
my @total = (map { @$_ } @LIST);
}}}

>
> So it's great, removed the bad code smell. And I already fixed it, so it's
> like the way you show in the code.

Nice.

>
> Regarding the DSL, I think that it is good enough for now. And since at the
> end the people who will be using it to write matchers (code) are perl
> programmers, then they are already used to writing all those extra salty
> characters :)

Heh. :-)

>
> And I agree that every good programmer should know how to write parsers,
> even though I think that times have changed a bit and yacc/bison are likely
> replaced with the likes of antlr and treetop (ruby lib) and the likes,
> which are somewhat easier to use to build those AST forests.

Well, I mentioned Yacc because it was the granddaddy of all parser generators 
on UNIX, and the first one I think about. But I've been experimenting with 
other parser generators including ANTLR, Parse::Yapp, Parse::RecDescent and 
others. I recently tried to create a Perl 5 backend to GNU bison, but gave up 
(at least temporarily) because that involved hacking some incredibly 
complicated m4 code. I always found m4 to be an abomination, and am kept 
amazed at how many projects are becoming dependent on it for all kinds of 
uses. I'll look more closely at ANTLR, and see if I can adapt it to generate 
Perl code more easily. This page claims that Perl support is in its "Early 
prototyping" stage:

http://www.antlr.org/wiki/display/ANTLR3/Code+Generation+Targets

I worked with ANTLR a bit, back when I tried to write a simple parser for the 
C#/Mono-based F-Spot. It wasn't such a good experience, but that may have been 
more C#'s fault than it was ANTLR's. ANTLR seemed pretty capable, though.

> Has been an extremely productive weekend for me, can't wait to show off the
> new polished and minimized and cleaner code to those who will (maybe) use
> it for writing acceptance testing scenarios.
>

That's Good. I'm glad I could have been of help.

Regards,

	Shlomi Fish

> - evgeny
>
> -------------------------
> p5-cucumber
> http://github.com/kesor/p5-cucumber
>
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
> "Israel.rb - the Israel Ruby & Rails Developers group" group. To post to
> this group, send email to israelrb at googlegroups.com
> To unsubscribe from this group, send email to
> israelrb+unsubscribe at googlegroups.com For more options, visit this group at
> http://groups.google.com/group/israelrb?hl=en
> -~----------~----~----~----~------~----~------~--~---

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Why I Love Perl - http://xrl.us/bjn88

God gave us two eyes and ten fingers so we will type five times as much as we
read.




More information about the Perl mailing list