Talk:Perl/Archive 3

message: :Perl has a context-free grammar; however, it cannot be parsed by a straight Lex/Yacc lexer/parser combination. Instead, it implements its own lexer, which coordinates with a modified GNU bison parser to resolve ambiguities in the language.
No it does not, in anything close to the strict definition of context-free.
Actually, very few languages have context-free grammars (for example C doesn't, as a (b); may be either function call or variable declaration in some contexts).
Quick draft of a proof: function prototypes. Whether foo bar 1,2 parses as foo(bar(1,2)) or foo(bar(1),(2)) depends on earlier prototypes of foo and bar. Because of infinite numbers of possible functions, you can't encode this information in a context-free grammar. It's not the only Perl construct that's provably non-context-free. Taw 09:06, 3 December 2005 (UTC)
replies: text: You are right that Perl does not have a context-free grammar. The regex syntax isn't even context-free, since even backreferences introduce context-sensitivity. Besides the problem you pointed out, the function itself can behave differently if it is called in scalar v. list context. Your changes look good, although explicit reference to Lex and Yacc may not be the best thing; maybe it should just say "cannot be parsed by a standard lexer/parser combination" instead of "cannot be parsed by a straight Lex/Yacc lexer/parser combination". Mike Dillon 15:23, 3 December 2005 (UTC)
thread_title:  Context-free 

message: no mention of perlscript? Gflores Talk 05:58, 16 December 2005 (UTC)
thread_title:  Perlscript 

message: I condensed the lead.
The lead should be like a headline: very short,
with just enough info to tell the reader what the article is about,
and help them decide if they want to read further.
Avoid adding anything to the lead that either is--or should be--somewhere else in the article.
Swmcd 17:11, 16 December 2005 (UTC)
thread_title:  The lead 

message: I've seen one liners with and without semicolons in the article. For example, there's:
my $x = shift;
and there's:
$x =~ m/abc/
I suggest that semicolons be used consistently. The problem is that I encountered a line that I'm not sure can be a valid line of Perl code or whether it's a snippet of a line, so someone more advanced than me better take care of it.  -Barry- 21:57, 17 December 2005 (UTC)
replies: text: You only need semicolons to separate statements. Most of the examples in the article aren't one-line scripts, they are just code fragments. The first example above would typically be a complete statement in a program, so it gets a semicolon. The second example is an expression that might be part of a larger statement, so it doesn't have a semicolon. Swmcd 13:43, 19 December 2005 (UTC)
thread_title:  Semicolons used inconsistently in one line scripts 

message: Is there any reason why this is listed as a .Net language? I have heard rumours that Perl.Net may be on the cards but no mention is made of it in the article and so I am not sure why it is categorized as such. Enigmatical 01:51, 12 April 2006 (UTC)
thread_title:  Listed as a .Net Language? 

message: From the article:
:Perl is not efficient at processor-bound tasks, and Perl data structures generally use more memory than comparable data structures in languages like C and C++.
This is true of any scripting language, so why is it nessesary to list it specifically as a criticism of Perl? Perl also isn't good for, say, creating an operating system like one would do with C and C++, but that's hardly worth mentioning. 209.92.136.131 20:53, 19 April 2006 (UTC)
thread_title:  processor-bound tasks???