Skip Menu |
Report information
Id: 122256
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: coke <will [at] coleda.com>
davidnmfarrell [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



To: rakudobug [...] perl.org
From: Will Coleda <will [...] coleda.com>
Date: Wed, 9 Jul 2014 10:10:21 -0400
Subject: Support EVAL(Buf)
Download (untitled) / with headers
text/plain 190b
S29 says that EVAL should work on Buf in addition to Str; There is one test in S29-context/eval.t that tests for this but is skipped. Could probably use more tests. -- Will "Coke" Coleda
Download (untitled) / with headers
text/plain 394b
Quoting the relevant portion of S29 that describes how the buf needs to be processed: Execute C<$code> as if it were code written in C<$lang>. If C<$code> is of type C<Buf>, the same decoding techniques are applied as a compiler for C<$lang> would usually do to input files. The default for C<$lang> is the language in effect at the exact location of the C<EVAL> call.
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 1.6k
On Wed, 09 Jul 2014 07:10:31 -0700, coke wrote: Show quoted text
> S29 says that EVAL should work on Buf in addition to Str; There is one > test in S29-context/eval.t that tests for this but is skipped. > > Could probably use more tests. >
Everything is now implemented[^1] with more tests added[^2], and I unfudged[^3] one of the two pre-existing tests. However, the remaining one tests for existence of Blob.EVAL **method**. Feels like it shouldn't be added at all. I heard people in the past express desire to remove Str.EVAL, especially because it (currently) by-passes[^4] the MONKEY restriction. It's a security-sensitive part of machinery and doesn't feel right to add many places where it's available; especially since subform can even by called as a method via `.&EVAL`; so why add an explicit method? Personally, I'd toss that fudge and not implement the method, but leaving this ticket open as RFC for now. Below is also a diff that adds the EVAL method to Blob. [1] https://github.com/rakudo/rakudo/commit/6c928d61d9 [2] https://github.com/perl6/roast/commit/6949cb13ad [3] https://github.com/perl6/roast/commit/60f4bd7850 [4] https://rt.perl.org/Ticket/Display.html?id=128684#ticket-history diff --git a/src/core/Buf.pm b/src/core/Buf.pm index eca050e..faf7ead 100644 --- a/src/core/Buf.pm +++ b/src/core/Buf.pm @@ -101,6 +101,10 @@ my role Blob[::T = uint8] does Positional[T] does Stringy is repr('VMArray') is ) } + method EVAL(*%opts) { + EVAL(self, context => CALLER::, |%opts); + } + multi method Bool(Blob:D:) { nqp::p6bool(nqp::elems(self)) } multi method elems(Blob:D:) { nqp::p6box_i(nqp::elems(self)) }


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org