Is there a list of the statement control items that are implemented as
such vs. implemented in another way?
Thanks,
Rob
&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
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
Luke Palmer wrote:
> On 11/21/05, Ingo Blechschmidt <ibl...@web.de> 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 ;)
--
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
Actually, I said that backwards. It starts out false and gets truified
if anyone says "Yes, we gotta have a block around us."
Larry
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
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
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
> 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.
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
> 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 <pdca...@bofh.org.uk>
http://www.bofh.org.uk/
Er, please append this to your program:
system "perl -i.bak -pe 's/to be machine/to be a machine/' quotefile";
:-)
Larry
> $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