Re: Metaprogramming

2002-12-15 Thread Simon Cozens
Randal L. Schwartz: That's what I expect code2text to do. Dump the coderef so that I can restore it. And for closures, it must dump the state of the closure variables. There isn't a current state. What would you like { my $start = halting_problem_to_detect_at_compile_time();

Re: Metaprogramming

2002-12-15 Thread Yitzchak Scott-Thoennes
On Sat, 14 Dec 2002 19:09:43 -0500, [EMAIL PROTECTED] wrote: On 14 Dec 2002, at 21:45, Rafael Garcia-Suarez wrote: What do you expect B::Deparse::coderef2text to do here ? Output something equivalent to { 42 + shift } ? or produce an error (can't deparse a closure without complete lexical

Re: Metaprogramming

2002-12-15 Thread Rafael Garcia-Suarez
Simon Cozens wrote in perl.fwp : Randal L. Schwartz: At the time I can possibly execute coderef2text, there *is* a current state. Deny that. OK, I'll deny that; B modules are typically executed during the CHECK phase, when none of the code has been executed. At that time there is no

Re: Metaprogramming

2002-12-15 Thread Yitzchak Scott-Thoennes
On Sat, 14 Dec 2002 21:09:38 -0800, [EMAIL PROTECTED] wrote: I certainly can't see any point in conditionally giving an error based on where the coderef2text aktescalp e. ^^^ anagram of takes place

Re: Metaprogramming

2002-12-14 Thread Randal L. Schwartz
Bernie == Bernie Cosell [EMAIL PROTECTED] writes: Bernie In fact, unless I'm misunderstanding how the closure works, $constant Bernie is exactly correct and '42' would be incorrect... No, that's wrong. Read my other post. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1

Re: Metaprogramming

2002-12-14 Thread Bernie Cosell
On 14 Dec 2002, at 16:32, Randal L. Schwartz wrote: Rafael == Rafael Garcia-Suarez [EMAIL PROTECTED] writes: Rafael What do you expect B::Deparse::coderef2text to do here ? Output Rafael something equivalent to { 42 + shift } ? Yes. Because that would be a serialization of the current

Re: Metaprogramming

2002-12-13 Thread Simon Cozens
Steffen Mueller: So any code that uses closures is pathological? Hmm, let's see: perl -MO=Deparse -e 'my $x; {my $foo = Hello!; $x=sub{print $foo};}; $x-()' my $x; { my $foo = 'Hello!'; $x = sub { print $foo; } ; } $x(); Nope, seems not. -- Citizen_X I detest

Re: Metaprogramming

2002-12-13 Thread Steffen Mueller
Simon Cozens wrote: Steffen Mueller: I've been wondering whether it is possible to implement some kind of mechanism that allows a Perl script to modify itself at runtime. B::Generate's been doing this for ages. Okay, I read up on it, but: You are expected to have read the Perl and XS

Re: Metaprogramming

2002-12-13 Thread Simon Cozens
Steffen Mueller: Okay, I read up on it, but: You are expected to have read the Perl and XS sources to this module before attempting to do anything with it. I cannot read XS :) Yeah, it was just a long-term plot to sell more books. -- IBM: It may be slow, but it's hard to use.

Re: Metaprogramming

2002-12-13 Thread Randal L. Schwartz
Michael == Michael G Schwern [EMAIL PROTECTED] writes: Nope, I've given examples of subroutines that cannot currently be accurately deparsed. Michael Because of the nature of Perl or because of a mistake in B::Deparse? Not completely sure. The problem is closures, because you end up having

Re: Metaprogramming

2002-12-13 Thread Randal L. Schwartz
Steffen == Steffen Mueller [EMAIL PROTECTED] writes: Steffen Okay, I admit to have relied on an overgeneralized interpretation of Steffen Randal's post about closures being a problem for B::Deparse. Steffen I *do*, however, remember B::Deparse failing to deparse some entries Steffen to the

Re: Metaprogramming

2002-12-12 Thread Michael G Schwern
On Wed, Dec 11, 2002 at 09:23:22PM +0100, Steffen Mueller wrote: I've been wondering whether it is possible to implement some kind of mechanism that allows a Perl script to modify itself at runtime. Using B::Deparse you can get the source of any running subroutine. Using eval you can replace