Re: statement_controlfoo()
On Wed, 30 Nov 2005, Piers Cawley wrote: $fh = open '', 'quotefile' or fail; $fh.print 'EOQ' Hmmm... 1/sqrt(2) * ( |Perl5 + |Perl6 ) ? ;-) (I thought '' C. were gone...) Michele -- We can only see a short distance ahead, but we can see plenty there that needs to be done. - Alan Turing
Re: statement_controlfoo()
Larry Wall [EMAIL PROTECTED] writes: On Tue, Nov 22, 2005 at 10:12:00AM +0100, Michele Dondi wrote: : Oh, I'm not the person you were responding to, and probably the less : entitled one to speak in the name of everyone else here, but I feel like : doing so to say that in all earnestness I'm quite sure no one took any : offense out of your words. Despite the slight harshness, they're above all : witty. Just as usual: and that's the style we all like! $fh = open '', 'quotefile' or fail; $fh.print 'EOQ' I like witty sayings as much as the next guy, but wit can hurt when misdirected. If people want me to be machine for cranking out quote file fodder, I'll do my best. But I also care about my friends. Larry EOQ -- Piers Cawley [EMAIL PROTECTED] http://www.bofh.org.uk/
Re: statement_controlfoo()
On Wed, Nov 30, 2005 at 06:36:22PM +, Piers Cawley wrote: : $fh = open '', 'quotefile' or fail; : $fh.print 'EOQ' : I like witty sayings as much as the next guy, but wit can hurt when : misdirected. If people want me to be machine for cranking out quote : file fodder, I'll do my best. But I also care about my friends. Er, please append this to your program: system perl -i.bak -pe 's/to be machine/to be a machine/' quotefile; :-) Larry
Re: statement_controlfoo() (was Re: lvalue reverse and array views)
On Mon, 21 Nov 2005, Larry Wall wrote: I would like to publicly apologize for my remarks, which were far too harsh for the circumstances. I can only plead that I was trying to be far too clever, and not thinking about how it would come across. No, to be perfectly honest, it was more culpable than that. I had a niggling feeling I was being naughty, and I ignored it. Shame on me. I will try to pay better attention to my conscience in the future. Oh, I'm not the person you were responding to, and probably the less entitled one to speak in the name of everyone else here, but I feel like doing so to say that in all earnestness I'm quite sure no one took any offense out of your words. Despite the slight harshness, they're above all witty. Just as usual: and that's the style we all like! Michele -- La vita e' come una scatola di cioccolatini: un regalo banale. - scritta su un muro, V.le Sabotino - Milano.
Re: statement_controlfoo() (was Re: lvalue reverse and array views)
On Tue, Nov 22, 2005 at 10:12:00AM +0100, Michele Dondi wrote: : Oh, I'm not the person you were responding to, and probably the less : entitled one to speak in the name of everyone else here, but I feel like : doing so to say that in all earnestness I'm quite sure no one took any : offense out of your words. Despite the slight harshness, they're above all : witty. Just as usual: and that's the style we all like! I like witty sayings as much as the next guy, but wit can hurt when misdirected. If people want me to be machine for cranking out quote file fodder, I'll do my best. But I also care about my friends. Larry
Re: statement_controlfoo() (was Re: lvalue reverse and array views)
Hi, Rob Kinyon wrote: On 11/20/05, Ingo Blechschmidt [EMAIL PROTECTED] wrote: Yep. Also note that for is not a special magical construct in Perl 6, it's a simple subroutine (statement_control:for, with the signature ([EMAIL PROTECTED], Code *code)). (Of course, it'll usually be optimized.) Example: { my sub statement_control:for ([EMAIL PROTECTED], Code *code) { map code, reverse @array; } for a b c - $item { say $item } # c\nb\na\n } # for restored, as the modified for went out of scope: for a b c - $item { say $item } # a\nb\nc\n Is there a list of the statement control items that are implemented as such vs. implemented in another way? statement_control:if, statement_control:unless, statement_control:for, statement_control:while, statement_control:until, and statement_control:loop come to my mind. ??!! is proably defined as sub ternary:?? !! ($cond, $then is lazy, $else is lazy) { if $cond { $then } else { $else } } (Assuming that ternary is the correct grammatical category and is lazy DWIMs.) Of course, the compiler is free to optimize these things if it can prove that runtime's statement_control:if is the same as the internal optimized statement_control:if. --Ingo
Re: statement_controlfoo() (was Re: lvalue reverse and array views)
On 11/21/05, Ingo Blechschmidt [EMAIL PROTECTED] wrote: Of course, the compiler is free to optimize these things if it can prove that runtime's statement_control:if is the same as the internal optimized statement_control:if. Which it definitely can't without some pragma. I wonder if they should be macros. (Macros that would by default expand to things that aren't expressible in Perl 6) Luke
Re: statement_controlfoo() (was Re: lvalue reverse and array views)
HaloO, Luke Palmer wrote: On 11/21/05, Ingo Blechschmidt [EMAIL PROTECTED] wrote: Of course, the compiler is free to optimize these things if it can prove that runtime's statement_control:if is the same as the internal optimized statement_control:if. Which it definitely can't without some pragma. Isn't the question just 'when'? I think at the latest it could be optimized JIT before the first execution, or so. The relevant AST branch stays for later eval calls which in turn branch off the sourrounding module's version from within the running system such that the scope calling the eval sees the new version. And this in turn might be optimzed and found unchanged in its optimized form. Sort of code morphing of really first class code. Everything else makes closures second class ;) --
Re: statement_controlfoo() (was Re: lvalue reverse and array views)
On Mon, Nov 21, 2005 at 03:51:19PM +, Luke Palmer wrote: : On 11/21/05, Ingo Blechschmidt [EMAIL PROTECTED] wrote: : Of course, the compiler is free to optimize these things if it can prove : that runtime's statement_control:if is the same as the internal : optimized statement_control:if. : : Which it definitely can't without some pragma. But remember that on some level or other, all declarations function as pragmas. So the absence of a redeclaration of if could be taken as a kind of pragma, if we require control redefinition to be lexically scoped, which we probably should. : I wonder if they should be macros. (Macros that would by default : expand to things that aren't expressible in Perl 6) Which is another way of saying that control redefinitions should be lexically scoped, since macros are required to do lexically scoped syntax modification unless they're Preluditudinous. Another issue in if optimization is whether the blocks in fact do anything blockish that have to be scoped to the block. This is a determination that Perl 5 makes when it's compiling blocks. It's basically an attribute that migrates up the tree from the leaves, which are mostly true, but anyone in the block can falsify the attribute for the block as a whole. Arguably, when you use ??!! and friends, it should also be doing such analysis on the lazy bits and telling you that your my is badly scoped if it's in conditional code. That also catches my $x = 0 if rand 2; Larry
Re: statement_controlfoo() (was Re: lvalue reverse and array views)
On Mon, Nov 21, 2005 at 10:45:56AM -0800, Larry Wall wrote: : Another issue in if optimization is whether the blocks in fact do : anything blockish that have to be scoped to the block. This is a : determination that Perl 5 makes when it's compiling blocks. It's : basically an attribute that migrates up the tree from the leaves, which : are mostly true, but anyone in the block can falsify the attribute : for the block as a whole. Actually, I said that backwards. It starts out false and gets truified if anyone says Yes, we gotta have a block around us. Larry
Re: statement_controlfoo() (was Re: lvalue reverse and array views)
On 11/21/05, TSa [EMAIL PROTECTED] wrote: HaloO, Luke Palmer wrote: On 11/21/05, Ingo Blechschmidt [EMAIL PROTECTED] wrote: Of course, the compiler is free to optimize these things if it can prove that runtime's statement_control:if is the same as the internal optimized statement_control:if. Which it definitely can't without some pragma. Isn't the question just 'when'? I think at the latest it could be optimized JIT before the first execution, or so. The relevant AST branch stays for later eval calls which in turn branch off the sourrounding module's version from within the running system such that the scope calling the eval sees the new version. And this in turn might be optimzed and found unchanged in its optimized form. Sort of code morphing of really first class code. Everything else makes closures second class ;) This is very close to a proposal I made to the ruby-dev mailing list (which was Warnocked). I proposed a very basic engine that would work with the parser/lexer to determine what action to take instead of using the huge case statements that are the heart of both P5 and Ruby. It would look something like: TOKEN: while ( my $token = get_next_token(params) ) { for my $length ( reverse length($token) .. 1 ) { if ( my $actions = find_actions( substr( $token, 0, $length ) ) ) { $action-[-1]-( params, if necessary ); } next TOKEN; } throw SyntaxError; } The for-loop + substr() would be to handle longest-token-first rules. So, ... is correctly recognized instead of handled as .. and .. The key would be that the $actions arrayref would get push'ed/pop'ed as you enter/leave a given lexical scope. Obviously, this could be optimized to an extremely large degree, but it -should- work. Rob
Re: statement_controlfoo() (was Re: lvalue reverse and array views)
On Mon, Nov 21, 2005 at 02:05:31PM -0500, Rob Kinyon wrote: : This is very close to a proposal I made to the ruby-dev mailing list : (which was Warnocked). I proposed a very basic engine that would work : with the parser/lexer to determine what action to take instead of : using the huge case statements that are the heart of both P5 and Ruby. : It would look something like: : : TOKEN: : while ( my $token = get_next_token(params) ) { : for my $length ( reverse length($token) .. 1 ) { : if ( my $actions = find_actions( substr( $token, 0, $length ) ) ) { : $action-[-1]-( params, if necessary ); : } : next TOKEN; : } : throw SyntaxError; : } : : The for-loop + substr() would be to handle longest-token-first rules. : So, ... is correctly recognized instead of handled as .. and .. : The key would be that the $actions arrayref would get push'ed/pop'ed : as you enter/leave a given lexical scope. : : Obviously, this could be optimized to an extremely large degree, but : it -should- work. Let's see, where did I put my stash of generic quotes? Ah, there is is. Those who do not understand XXX are doomed to reinvent it, poorly. ~~ s/XXX/the Perl 6 grammar engine/; In particular, you've just reinvented the magic hash semantics mandated by P6 rules, except that P6 has some hope of optimizing the lookups to a cached trie or whatever. Larry
Re: statement_controlfoo() (was Re: lvalue reverse and array views)
On Mon, Nov 21, 2005 at 11:43:21AM -0800, Larry Wall wrote: : Let's see, where did I put my stash of generic quotes? I would like to publicly apologize for my remarks, which were far too harsh for the circumstances. I can only plead that I was trying to be far too clever, and not thinking about how it would come across. No, to be perfectly honest, it was more culpable than that. I had a niggling feeling I was being naughty, and I ignored it. Shame on me. I will try to pay better attention to my conscience in the future. Larry
statement_controlfoo() (was Re: lvalue reverse and array views)
On 11/20/05, Ingo Blechschmidt [EMAIL PROTECTED] wrote: [snip] Yep. Also note that for is not a special magical construct in Perl 6, it's a simple subroutine (statement_control:for, with the signature ([EMAIL PROTECTED], Code *code)). (Of course, it'll usually be optimized.) Example: { my sub statement_control:for ([EMAIL PROTECTED], Code *code) { map code, reverse @array; } for a b c - $item { say $item } # c\nb\na\n } # for restored, as the modified for went out of scope: for a b c - $item { say $item } # a\nb\nc\n Is there a list of the statement control items that are implemented as such vs. implemented in another way? Thanks, Rob