Re: EVAL?

2018-06-14 Thread Norman Gaywood
On Fri, 15 Jun 2018 at 06:13, Trey Harris  wrote:

Thanks for the nice examples of IntStr and friends.

I was intrigued with this statement at the end:

> Also note that using s/printf at all is not encouraged

Could you expand on that?

> ​
>


-- 
Norman Gaywood, Computer Systems Officer
School of Science and Technology
University of New England
Armidale NSW 2351, Australia

ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062

Please avoid sending me Word or Power Point attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html


Re: EVAL?

2018-06-14 Thread ToddAndMargo

On 06/14/2018 01:13 PM, Trey Harris wrote:

Just a small stylistic thing to mention:

On Thu, Jun 14, 2018 at 1:59 AM Todd Chester > wrote:


p6
        if not $dir.IO.d.bool {}
        for  slice  "\n", $WebStr   ->  $Line { }

   and on and on and so forth.  I know a lot of them by heart now.

By |.bool|, I assume you meant |.Bool|, but in any case, it isn’t 
necessary since the context of a |not| forces it to be boolean.


Indeed!

Exists (directory):
   DIRPATH.IO.d.Bool;
   if not $WorkingDir.IO.d.Bool { mkdir $WorkingDir, 0o766; }




If you want the opposite—a boolean without the sense-negation, you can 
use |so|, but in the context of an |if|, it should rarely, if ever, be 
necessary.


In the same way that |so| is used to explicitly truthify, unary |+| is 
used to explicitly numify.


E.g., once you know that an |IntStr| 
 dual value gives a result 
reminiscent of Perl 5’s string numbers (except that without going to 
crazy lengths, you can easily supply exactly the number and string you 
want):


|my $x = IntStr.new(42, "The Answer"); my $y = IntStr.new(0, "Nothing"); 
for ($x, $y) -> $z { printf "\$z: '%s', so \$z: '%s', +\$z: '%s'\n", $z, 
so $z, +$z; say " Double it: ", $z * 2; say " or 'double' it: ", $z x 2; } |


gives results:

|$z: 'The Answer', so $z: 'True', +$z: '42' Double it: 84 or 'double' it: 
The AnswerThe Answer $z: 'Nothing', so $z: 'False', +$z: '0' Double it: 
0 or 'double' it: NothingNothing |


In case you’re wondering, you’ll usually have no reason to explicitly 
construct a dual value like that; you generally get a NumStr or its 
counterparts like IntStr when reading input or expecting command-line 
arguments.


(Also note that the stringification equivalent to |so| and unary |+| is 
|~|, but it wasn’t necessary above since the |%s| template to |sprintf| 
forces stringification. Also note that using s/printf at all is not 
encouraged—but it was useful above, just to make things explicit.)


​



Thank you!  Wonderful exposition! I am going to write it down
for later use.

I use "if not" a lot because it is human readable for
me and assists in maintaining the code.


Re: EVAL?

2018-06-14 Thread ToddAndMargo

On 06/14/2018 11:10 AM, Elizabeth Mattijsen wrote:

We are all maintainers of the glossary.  Patches / Pull Requests are welcome.


Hi Elizabeth,


My favorite definition I found was:

   http://www.yourdictionary.com/pragma

   (computing, programming) A compiler directive; data embedded
   in source code by programmers to indicate some intention to
   the compiler.

   This pragma stops the compiler from generating those
   warnings we don't care about.

You could use this and add "In Perl, "Pragma" specifically means ..."

-T


Re: EVAL?

2018-06-14 Thread Trey Harris
Just a small stylistic thing to mention:

On Thu, Jun 14, 2018 at 1:59 AM Todd Chester  wrote:

p6
>if not $dir.IO.d.bool {}
>for  slice  "\n", $WebStr   ->  $Line { }
>
>   and on and on and so forth.  I know a lot of them by heart now.
>
By .bool, I assume you meant .Bool, but in any case, it isn’t necessary
since the context of a not forces it to be boolean.

If you want the opposite—a boolean without the sense-negation, you can use
so, but in the context of an if, it should rarely, if ever, be necessary.

In the same way that so is used to explicitly truthify, unary + is used to
explicitly numify.

E.g., once you know that an IntStr 
dual value gives a result reminiscent of Perl 5’s string numbers (except
that without going to crazy lengths, you can easily supply exactly the
number and string you want):

my $x = IntStr.new(42, "The Answer");
my $y = IntStr.new(0, "Nothing");
for ($x, $y) -> $z {
  printf "\$z: '%s', so \$z: '%s', +\$z: '%s'\n",
$z,so $z,+$z;
  say "  Double it: ", $z * 2;
  say "  or 'double' it: ", $z x 2;
}

gives results:

$z: 'The Answer', so $z: 'True', +$z: '42'
  Double it: 84
  or 'double' it: The AnswerThe Answer
$z: 'Nothing', so $z: 'False', +$z: '0'
  Double it: 0
  or 'double' it: NothingNothing

In case you’re wondering, you’ll usually have no reason to explicitly
construct a dual value like that; you generally get a NumStr or its
counterparts like IntStr when reading input or expecting command-line
arguments.

(Also note that the stringification equivalent to so and unary + is ~, but
it wasn’t necessary above since the %s template to sprintf forces
stringification. Also note that using s/printf at all is not encouraged—but
it was useful above, just to make things explicit.)
​


Re: EVAL?

2018-06-14 Thread Elizabeth Mattijsen
We are all maintainers of the glossary.  Patches / Pull Requests are welcome.

> On 14 Jun 2018, at 20:03, Brandon Allbery  wrote:
> 
> I'm trying to not second-guess whoever maintains the glossary. And by that 
> message also pointing up the omission.
> 
> On Thu, Jun 14, 2018 at 2:01 PM The Sidhekin  wrote:
> On Thu, Jun 14, 2018 at 7:57 PM, Brandon Allbery  wrote:
> You can never be certain in *any* case. Check if you're not sure what it 
> means. Because sometimes languages use some term in a way you don't expect, 
> whether because they drew it from some specific discipline (Haskell uses a 
> lot of terminilogy from abstract mathematics, for example) or for some reason 
> (I've hit a few cases where the language author didn't know the actual 
> meaning of some term and used it "oddly" as a result).
> 
> https://docs.perl6.org/language/glossary
> 
> Which doesn't have "pragma" in it, probably because it's not specific to 
> Perl. It's been around, and used in this sense, since at least the 1960s and 
> probably earlier.
> 
>   ... but does have "whitespace" and "variable" in it, neither of which is 
> specific to Perl. :-P
> 
>   Isn't the lack of "pragma" there an omission to be corrected?
> 
>   Particularly if the term is required for the reading of error messages?
> 
> 
> Eirik
> 
> 
> -- 
> brandon s allbery kf8nh   sine nomine associates
> allber...@gmail.com  ballb...@sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: EVAL?

2018-06-14 Thread Brandon Allbery
I'm trying to not second-guess whoever maintains the glossary. And by that
message also pointing up the omission.

On Thu, Jun 14, 2018 at 2:01 PM The Sidhekin  wrote:

> On Thu, Jun 14, 2018 at 7:57 PM, Brandon Allbery 
> wrote:
>
>> You can never be certain in *any* case. Check if you're not sure what it
>> means. Because sometimes languages use some term in a way you don't expect,
>> whether because they drew it from some specific discipline (Haskell uses a
>> lot of terminilogy from abstract mathematics, for example) or for some
>> reason (I've hit a few cases where the language author didn't know the
>> actual meaning of some term and used it "oddly" as a result).
>>
>> https://docs.perl6.org/language/glossary
>>
>> Which doesn't have "pragma" in it, probably because it's not specific to
>> Perl. It's been around, and used in this sense, since at least the 1960s
>> and probably earlier.
>>
>
>   ... but does have "whitespace" and "variable" in it, neither of which is
> specific to Perl. :-P
>
>   Isn't the lack of "pragma" there an omission to be corrected?
>
>   Particularly if the term is required for the reading of error messages?
>
>
> Eirik
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: EVAL?

2018-06-14 Thread The Sidhekin
On Thu, Jun 14, 2018 at 7:57 PM, Brandon Allbery 
wrote:

> You can never be certain in *any* case. Check if you're not sure what it
> means. Because sometimes languages use some term in a way you don't expect,
> whether because they drew it from some specific discipline (Haskell uses a
> lot of terminilogy from abstract mathematics, for example) or for some
> reason (I've hit a few cases where the language author didn't know the
> actual meaning of some term and used it "oddly" as a result).
>
> https://docs.perl6.org/language/glossary
>
> Which doesn't have "pragma" in it, probably because it's not specific to
> Perl. It's been around, and used in this sense, since at least the 1960s
> and probably earlier.
>

  ... but does have "whitespace" and "variable" in it, neither of which is
specific to Perl. :-P

  Isn't the lack of "pragma" there an omission to be corrected?

  Particularly if the term is required for the reading of error messages?


Eirik


Re: EVAL?

2018-06-14 Thread Brandon Allbery
Not to mention "language designer isn't from your culture, and the word has
different connotations in theirs". The eastern (or for that matter western)
US does not define the world.

On Thu, Jun 14, 2018 at 1:57 PM Brandon Allbery  wrote:

> You can never be certain in *any* case. Check if you're not sure what it
> means. Because sometimes languages use some term in a way you don't expect,
> whether because they drew it from some specific discipline (Haskell uses a
> lot of terminilogy from abstract mathematics, for example) or for some
> reason (I've hit a few cases where the language author didn't know the
> actual meaning of some term and used it "oddly" as a result).
>
> https://docs.perl6.org/language/glossary
>
> Which doesn't have "pragma" in it, probably because it's not specific to
> Perl. It's been around, and used in this sense, since at least the 1960s
> and probably earlier.
>
> So also check various CS glossaries.
> Such as FOLDOC: http://foldoc.org/pragma
>
> On Thu, Jun 14, 2018 at 1:52 PM ToddAndMargo 
> wrote:
>
>> On 06/14/2018 10:49 AM, Brandon Allbery wrote:
>> > That's actually the origin of it: pragmatic / real-world behavior, as
>> > opposed to idealized situations.
>>
>> I can't always tell when things are English and when
>> things are Perl.
>>
>
>
> --
> brandon s allbery kf8nh   sine nomine
> associates
> allber...@gmail.com
> ballb...@sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: EVAL?

2018-06-14 Thread The Sidhekin
On Thu, Jun 14, 2018 at 7:46 PM, ToddAndMargo  wrote:

> On 06/14/2018 10:43 AM, The Sidhekin wrote:
>
>>
>>More relevant, Perl 6 documentation: https://docs.perl6.org/languag
>> e/pragmas
>>
>
> You are presuming I knew the word was a Perl word.
> I though it was English, as in pragmatic
>

  Not my intention.  This was just informing you where it is documented,
not presuming any prior knowledge.

  (The next line may be more presumptuous: "Now, I'm not sure how I would
have responded to such an error message if I wasn't already familiar with
the term.  Search the web for Perl6 + pragma, perhaps?"

  ... but also uncertain ... and in any case referring to my own self
specifically.)


Eirik


Re: EVAL?

2018-06-14 Thread Brandon Allbery
You can never be certain in *any* case. Check if you're not sure what it
means. Because sometimes languages use some term in a way you don't expect,
whether because they drew it from some specific discipline (Haskell uses a
lot of terminilogy from abstract mathematics, for example) or for some
reason (I've hit a few cases where the language author didn't know the
actual meaning of some term and used it "oddly" as a result).

https://docs.perl6.org/language/glossary

Which doesn't have "pragma" in it, probably because it's not specific to
Perl. It's been around, and used in this sense, since at least the 1960s
and probably earlier.

So also check various CS glossaries.
Such as FOLDOC: http://foldoc.org/pragma

On Thu, Jun 14, 2018 at 1:52 PM ToddAndMargo  wrote:

> On 06/14/2018 10:49 AM, Brandon Allbery wrote:
> > That's actually the origin of it: pragmatic / real-world behavior, as
> > opposed to idealized situations.
>
> I can't always tell when things are English and when
> things are Perl.
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: EVAL?

2018-06-14 Thread ToddAndMargo

On 06/14/2018 10:49 AM, Brandon Allbery wrote:
That's actually the origin of it: pragmatic / real-world behavior, as 
opposed to idealized situations.


I can't always tell when things are English and when
things are Perl.


Re: EVAL?

2018-06-14 Thread Brandon Allbery
That's actually the origin of it: pragmatic / real-world behavior, as
opposed to idealized situations.

On Thu, Jun 14, 2018 at 1:47 PM ToddAndMargo  wrote:

> On 06/14/2018 10:43 AM, The Sidhekin wrote:
> >
> >More relevant, Perl 6 documentation:
> > https://docs.perl6.org/language/pragmas
>
> You are presuming I knew the word was a Perl word.
> I though it was English, as in pragmatic
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: EVAL?

2018-06-14 Thread ToddAndMargo

On 06/14/2018 10:43 AM, The Sidhekin wrote:


   More relevant, Perl 6 documentation: 
https://docs.perl6.org/language/pragmas


You are presuming I knew the word was a Perl word.
I though it was English, as in pragmatic


Re: EVAL?

2018-06-14 Thread Brandon Allbery
That's just a different variant of an old shell "hack": drop a program
named "test" somewhere where root might run a shell script.

Which is why root's path no longer includes the current directory, and
these days nothing outside the system directories.

On Thu, Jun 14, 2018 at 1:37 PM ToddAndMargo  wrote:

> On 06/14/2018 10:30 AM, Brandon Allbery wrote:
> > In short, pragmas are all-same-case "use" names; instead of loading
> > code, they tell the compiler to change its behavior.
> >
> > The MONKEY-* pragmas generally control various kinds of unsafe or
> > dangerous behavior, including direct access to the mechanisms underneath
> > / "supporting" Rakudo and things like EVAL. Other all-uppercase names
> > also generally represent "dangerous" actions or options.
> >
> > There are a few pragmas that are all lowercase instead of all uppercase;
> > they also change the compiler's behavior, but are safer than the
> > all-uppercase ones. "use lib" is one of them. (This is why modules are
> > generally mixed-case names.)
>
>
> Thank you!
>
> Speaking of dangerous, go find a perl program being run by root,
> inject some code into one of its modules, and ...
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: EVAL?

2018-06-14 Thread The Sidhekin
On Thu, Jun 14, 2018 at 7:21 PM, ToddAndMargo  wrote:

> 2) what the heck is a "pragma"?  Way to obscure.
>

  I thought you knew.  From the Perl 5 documentation: "A pragma is a module
which influences some aspect of the compile time or run time behaviour of
Perl, such as strict or warnings."

  More relevant, Perl 6 documentation:
https://docs.perl6.org/language/pragmas

  Now, I'm not sure how I would have responded to such an error message if
I wasn't already familiar with the term.  Search the web for Perl6 +
pragma, perhaps?

  Just thinking out loud: This hint ("use the MONKEY-SEE-NO-EVAL pragma to
override this error, but only if you're VERY sure your data contains no
injection attacks") is rather terse for those who need it ... might it be
better if the error message instead referenced documentation?


Eirik


Re: EVAL?

2018-06-14 Thread ToddAndMargo

On 06/14/2018 10:30 AM, Brandon Allbery wrote:
In short, pragmas are all-same-case "use" names; instead of loading 
code, they tell the compiler to change its behavior.


The MONKEY-* pragmas generally control various kinds of unsafe or 
dangerous behavior, including direct access to the mechanisms underneath 
/ "supporting" Rakudo and things like EVAL. Other all-uppercase names 
also generally represent "dangerous" actions or options.


There are a few pragmas that are all lowercase instead of all uppercase; 
they also change the compiler's behavior, but are safer than the 
all-uppercase ones. "use lib" is one of them. (This is why modules are 
generally mixed-case names.)



Thank you!

Speaking of dangerous, go find a perl program being run by root,
inject some code into one of its modules, and ...


Re: EVAL?

2018-06-14 Thread Brandon Allbery
In short, pragmas are all-same-case "use" names; instead of loading code,
they tell the compiler to change its behavior.

The MONKEY-* pragmas generally control various kinds of unsafe or dangerous
behavior, including direct access to the mechanisms underneath /
"supporting" Rakudo and things like EVAL. Other all-uppercase names also
generally represent "dangerous" actions or options.

There are a few pragmas that are all lowercase instead of all uppercase;
they also change the compiler's behavior, but are safer than the
all-uppercase ones. "use lib" is one of them. (This is why modules are
generally mixed-case names.)

https://docs.perl6.org/language/pragmas for more information.

On Thu, Jun 14, 2018 at 1:22 PM ToddAndMargo  wrote:

> On 06/13/2018 12:27 PM, Brandon Allbery wrote:
> > Exactly what it says: eval is a code injection attack waiting to happen.
> > If you actually need it, you get to do your own data sanitization, and
> > you tell Perl 6 you did so with "use MONKEY-SEE-NO-EVAL;".
>
> Hi Brandon,
>
> Thank you for clarifying.  My hand up with the error message
> was its wording:
>
> "use the MONKEY-SEE-NO-EVAL pragma to override this error"
>
> 1) I did not realize the the word "use" mean the Perl "use".
> I though it meant the English usages as in go do something.
>
> 2) what the heck is a "pragma"?  Way to obscure.
>
> Your response cleared up the misunderstanding nicely.
>
> -T
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: EVAL?

2018-06-14 Thread ToddAndMargo

On 06/13/2018 12:27 PM, Brandon Allbery wrote:
Exactly what it says: eval is a code injection attack waiting to happen. 
If you actually need it, you get to do your own data sanitization, and 
you tell Perl 6 you did so with "use MONKEY-SEE-NO-EVAL;".


Hi Brandon,

Thank you for clarifying.  My hand up with the error message
was its wording:

   "use the MONKEY-SEE-NO-EVAL pragma to override this error"

1) I did not realize the the word "use" mean the Perl "use".
I though it meant the English usages as in go do something.

2) what the heck is a "pragma"?  Way to obscure.

Your response cleared up the misunderstanding nicely.

-T


Re: EVAL?

2018-06-14 Thread ToddAndMargo

On 06/14/2018 09:11 AM, Timo Paulssen wrote:

If it's literally just the name of a sub that you'll immediately invoke,
you can side-step EVAL completely

     ::('&' ~ $RunSpecific)()

should do the trick.

::("") will give you the sub object, and putting () after it will
immediately call it.

It will allow access to all subs, even from the core, so subs like "die"
and "exit" are reachable, but it's less dangerous than accepting any
random code. For one, it will only work with subs that don't take arguments.

HTH
   - Timo




Perfect!  Thank you!


Re: EVAL?

2018-06-14 Thread Elizabeth Mattijsen



> On 14 Jun 2018, at 18:19, The Sidhekin  wrote:
> 
> On Thu, Jun 14, 2018 at 6:11 PM, Timo Paulssen  wrote:
> If it's literally just the name of a sub that you'll immediately invoke,
> you can side-step EVAL completely
> 
> ::('&' ~ $RunSpecific)()
> 
> should do the trick.
> 
>   I haven't been much into Perl 6 lately, but isn't this just the same as
> 
> &::($RunSpecific)()
> 
> ... which is easier on these old eyes?

Indeed it is.


Re: EVAL?

2018-06-14 Thread The Sidhekin
On Thu, Jun 14, 2018 at 6:11 PM, Timo Paulssen  wrote:

> If it's literally just the name of a sub that you'll immediately invoke,
> you can side-step EVAL completely
>
> ::('&' ~ $RunSpecific)()
>
> should do the trick.
>

  I haven't been much into Perl 6 lately, but isn't this just the same as

&::($RunSpecific)()

... which is easier on these old eyes?


Eirik


Re: EVAL?

2018-06-14 Thread Timo Paulssen
If it's literally just the name of a sub that you'll immediately invoke,
you can side-step EVAL completely

    ::('&' ~ $RunSpecific)()

should do the trick.

::("") will give you the sub object, and putting () after it will
immediately call it.

It will allow access to all subs, even from the core, so subs like "die"
and "exit" are reachable, but it's less dangerous than accepting any
random code. For one, it will only work with subs that don't take arguments.

HTH
  - Timo


Re: EVAL?

2018-06-14 Thread ToddAndMargo

> wrote:



On 06/13/2018 12:27 PM, Brandon Allbery wrote:

use MONKEY-SEE-NO-EVAL;


Thank you.  Someone had fun with that name!

Do I presume there is not other way around the issue?



On 06/14/2018 05:21 AM, The Sidhekin wrote:

On Thu, Jun 14, 2018 at 8:01 AM, Todd Chester    That depends on your use case.  EVAL/eval is powerful enough it could 
be pretty much anything, so bird's-eye view here:


   If $RunSpecific is sufficiently non-generic (i.e. couldn't be any 
code whatsoever), an approach with dispatch tables or similar (dynamic 
method lookup, giant switch ...) might be an alternative.  Optionally 
parsing the code (Perl subset, DSL?) yourself.


   For use with any code whatsoever though, you need that kind of power, 
and as Brandon wrote: You get to do your own data sanitization, and you 
tell Perl 6 you did so with "use MONKEY-SEE-NO-EVAL;".



Eirik


Hi Eirik,

The program goes out and checks for new updates to programs I carry
with me to support my customers.  To debug a sub individually,
I place the sub's name on the command line.  This way I don't
have to run them all at once to debug one sub.  $RunSpecific
is the name of a particular sub.  (If I misspell the sub name, I
get ignored.)

This is especially useful when adding a new program to check or
when someone changes their web page.

Chuckle: I catch a lot of boo-boos when they change their
web pages.

On one program, I can't get the vendor to place the program's
revision on the web.  But he does place a check sum to for
the download.  So, I download the checksum and compare it to
the previous checksum, if they don't match, I download the
actual program.  Then do an unzip list and find the revision
from one of the files inside the zip.  With the revision,
I name the zip file properly.  And yes, I have caught boo-boos
in his zip file before.

-T


Re: EVAL?

2018-06-14 Thread The Sidhekin
On Thu, Jun 14, 2018 at 8:01 AM, Todd Chester  wrote:

>
>
> On 06/13/2018 12:27 PM, Brandon Allbery wrote:
>
>> use MONKEY-SEE-NO-EVAL;
>>
>
> Thank you.  Someone had fun with that name!
>
> Do I presume there is not other way around the issue?
>

  That depends on your use case.  EVAL/eval is powerful enough it could be
pretty much anything, so bird's-eye view here:

  If $RunSpecific is sufficiently non-generic (i.e. couldn't be any code
whatsoever), an approach with dispatch tables or similar (dynamic method
lookup, giant switch ...) might be an alternative.  Optionally parsing the
code (Perl subset, DSL?) yourself.

  For use with any code whatsoever though, you need that kind of power, and
as Brandon wrote: You get to do your own data sanitization, and you tell
Perl 6 you did so with "use MONKEY-SEE-NO-EVAL;".


Eirik


Re: EVAL?

2018-06-14 Thread Todd Chester




On 06/13/2018 12:27 PM, Brandon Allbery wrote:

use MONKEY-SEE-NO-EVAL;


Thank you.  Someone had fun with that name!

Do I presume there is not other way around the issue?


Re: EVAL?

2018-06-13 Thread Todd Chester
  On Wed, 13 Jun 2018 15:23:56 -0700 yary  wrote 
  > Pet peeve, "$RunSpecific" with the quotes on either side is 
exactly the same as $RunSpecific without the quotes. Perl isn't shell.

 >  > -y

Hi Yary,

Chuckle.  Missed one.  What??  Or two or three ...

This program that I have been converting from P5 to P6 has been
a real learning experience.  I been removing quotes, dots, parentheses,
reference pointers (you have to pass reference pointers to P5's
weird subroutine headers if you want to pass anything other than a
simple $ variable) ...

p5
  if ( ! -d "$dir" ) {}
  while ( slice ( "\n", "$WebStr" )) { my $Line = $_; }

p6
  if not $dir.IO.d.bool {}
  for  slice  "\n", $WebStr   ->  $Line { }

 and on and on and so forth.  I know a lot of them by heart now.

And yes, my P5 code could be cleaned up a bit too, but as
soon as I get this last one over into p6, I will be mostly
done with p5.  I figure the good habit learning effort will
be best put to p6

-T


Re: EVAL?

2018-06-13 Thread Elizabeth Mattijsen
It is in this situation, but not necessarily always:

“$foo” is equivalent to $foo.Str

$foo is exactly what $foo is.

my $foo = 42;:wq
dd $foo;  # Int $foo = 42
dd “$foo” # “42"

> On 14 Jun 2018, at 00:23, yary  wrote:
> 
> Pet peeve, "$RunSpecific" with the quotes on either side is exactly the same 
> as $RunSpecific without the quotes. Perl isn't shell.
> 
> -y
> 
> On Wed, Jun 13, 2018 at 12:27 PM, Brandon Allbery  wrote:
> Exactly what it says: eval is a code injection attack waiting to happen. If 
> you actually need it, you get to do your own data sanitization, and you tell 
> Perl 6 you did so with "use MONKEY-SEE-NO-EVAL;".
> 
> On Wed, Jun 13, 2018 at 3:22 PM ToddAndMargo  wrote:
> Hi All,
> 
> I am converting a program from Perl5 to Perl 6.
> 
> This line
> 
>  else { eval "$RunSpecific"; }
> 
> became this line
> 
>  else { EVAL "$RunSpecific"; }
> 
> And threw this error
> 
> $ perl6 -c GetUpdates.pl6
> ===SORRY!=== Error while compiling /home/linuxutil/GetUpdates.pl6
> EVAL is a very dangerous function!!! (use the MONKEY-SEE-NO-EVAL pragma 
> to override this error,
> but only if you're VERY sure your data contains no injection attacks)
> at /home/linuxutil/GetUpdates.pl6:6016
> --> else { EVAL "$RunSpecific"⏏; }
> 
> 
> Any words of wisdom?
> 
> 
> Many thanks,
> -T
> 
> 
> -- 
> ~~~
> Serious error.
> All shortcuts have disappeared.
> Screen. Mind. Both are blank.
> ~~~
> 
> 
> -- 
> brandon s allbery kf8nh   sine nomine associates
> allber...@gmail.com  ballb...@sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
> 


Re: EVAL?

2018-06-13 Thread yary
Pet peeve, "$RunSpecific" with the quotes on either side is exactly the
same as $RunSpecific without the quotes. Perl isn't shell.

-y

On Wed, Jun 13, 2018 at 12:27 PM, Brandon Allbery 
wrote:

> Exactly what it says: eval is a code injection attack waiting to happen.
> If you actually need it, you get to do your own data sanitization, and you
> tell Perl 6 you did so with "use MONKEY-SEE-NO-EVAL;".
>
> On Wed, Jun 13, 2018 at 3:22 PM ToddAndMargo 
> wrote:
>
>> Hi All,
>>
>> I am converting a program from Perl5 to Perl 6.
>>
>> This line
>>
>>   else { eval "$RunSpecific"; }
>>
>> became this line
>>
>>   else { EVAL "$RunSpecific"; }
>>
>> And threw this error
>>
>> $ perl6 -c GetUpdates.pl6
>> ===SORRY!=== Error while compiling /home/linuxutil/GetUpdates.pl6
>> EVAL is a very dangerous function!!! (use the MONKEY-SEE-NO-EVAL pragma
>> to override this error,
>> but only if you're VERY sure your data contains no injection attacks)
>> at /home/linuxutil/GetUpdates.pl6:6016
>> --> else { EVAL "$RunSpecific"⏏; }
>>
>>
>> Any words of wisdom?
>>
>>
>> Many thanks,
>> -T
>>
>>
>> --
>> ~~~
>> Serious error.
>> All shortcuts have disappeared.
>> Screen. Mind. Both are blank.
>> ~~~
>>
>
>
> --
> brandon s allbery kf8nh   sine nomine
> associates
> allber...@gmail.com
> ballb...@sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>


Re: EVAL?

2018-06-13 Thread Brandon Allbery
Exactly what it says: eval is a code injection attack waiting to happen. If
you actually need it, you get to do your own data sanitization, and you
tell Perl 6 you did so with "use MONKEY-SEE-NO-EVAL;".

On Wed, Jun 13, 2018 at 3:22 PM ToddAndMargo  wrote:

> Hi All,
>
> I am converting a program from Perl5 to Perl 6.
>
> This line
>
>   else { eval "$RunSpecific"; }
>
> became this line
>
>   else { EVAL "$RunSpecific"; }
>
> And threw this error
>
> $ perl6 -c GetUpdates.pl6
> ===SORRY!=== Error while compiling /home/linuxutil/GetUpdates.pl6
> EVAL is a very dangerous function!!! (use the MONKEY-SEE-NO-EVAL pragma
> to override this error,
> but only if you're VERY sure your data contains no injection attacks)
> at /home/linuxutil/GetUpdates.pl6:6016
> --> else { EVAL "$RunSpecific"⏏; }
>
>
> Any words of wisdom?
>
>
> Many thanks,
> -T
>
>
> --
> ~~~
> Serious error.
> All shortcuts have disappeared.
> Screen. Mind. Both are blank.
> ~~~
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: eval and try should be separate

2011-06-30 Thread Carl Mäsak
+1

It's been up for discussion before in #perl6 (with a quick search, I
find http://irclog.perlgeek.de/perl6/2011-06-03#i_3851753 and
http://irclog.perlgeek.de/perl6/2011-05-07#i_3688404), but so far
no-one has acted on the idea. Kudos for picking it up.

// Carl

On Wed, Jun 29, 2011 at 10:44 PM, Stefan O'Rear stefa...@cox.net wrote:
 I intend to change the definition of eval such that it does not catch
 exceptions.  String eval's role as the catcher of exceptions is a legacy of
 Perl 1, which had no block eval, and I feel it has no place in Perl 6.

 The exception catching and associated unwinding makes it impossible to use
 resumable exceptions across eval boundaries.  This includes warn.

 Given an eval that does not catch exceptions, it is very easy to add catching,
 using the new blockless form of try, try eval $code.  However, given an eval
 which does catch, it is impossible to synthesize one that passes exceptions
 faithfully.

 Catching exceptions in an eval causes the eval frame to be different from the
 calling frame, which makes tail call optimization through evals impossible.

 With the catching eval, it is very easy to write code which accidentally
 discards exceptions.  For the goal of safety it seems best to make discarding
 exceptions hard by default.

 Does anyone have objections?  Is there general consensus that this change
 should be made?

 -Stefan

 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.10 (GNU/Linux)

 iEYEARECAAYFAk4LjqQACgkQFBz7OZ2P+dIKVQCfXaqXIo7JWJOpUNB1jtIOhGS/
 sgMAoLu2HjlHMZth8U/7el4XKymLX6Qu
 =1ywK
 -END PGP SIGNATURE-




Re: eval and try should be separate

2011-06-30 Thread Larry Wall
Given that try can be used with a statement as well as a block, I'm
fine with this.  We want to discourage people from using eval anyway, 
so forcing people to use 'try eval' to get p5 behavior is okay too.

Larry


Re: eval and try should be separate

2011-06-29 Thread Darren Duncan
I agree with the change.  Let try be for exceptions and eval be for runtime 
compile+run of code.  These are very distinct concepts and should be separate. 
-- Darren Duncan


Stefan O'Rear wrote:

I intend to change the definition of eval such that it does not catch
exceptions.  String eval's role as the catcher of exceptions is a legacy of
Perl 1, which had no block eval, and I feel it has no place in Perl 6.

The exception catching and associated unwinding makes it impossible to use
resumable exceptions across eval boundaries.  This includes warn.

Given an eval that does not catch exceptions, it is very easy to add catching,
using the new blockless form of try, try eval $code.  However, given an eval
which does catch, it is impossible to synthesize one that passes exceptions
faithfully.

Catching exceptions in an eval causes the eval frame to be different from the
calling frame, which makes tail call optimization through evals impossible.

With the catching eval, it is very easy to write code which accidentally
discards exceptions.  For the goal of safety it seems best to make discarding
exceptions hard by default.

Does anyone have objections?  Is there general consensus that this change
should be made?




Re: eval should throw an exception on compile error

2011-05-07 Thread Stefan O'Rear
On Sat, May 07, 2011 at 03:45:02PM +1000, Michael G Schwern wrote:
 I was just playing around with eval, trying to figure out if you can define an
 operator overload at runtime (seems you can't, good) and noticed this in the
 spec... [1]
 
 Returns whatever $code returns, or fails.
 
 How does one get the compile error from an eval?  What's the equivalent to $@?
  I don't see anything in the eval tests [2] that's checking for the error,
 just that it returned false.

The error goes into $!, which is automatically lexical.

What you're seeing is a bug-of-omission in Rakudo; if $! is not checked by
the end of the scope, Perl 6 is supposed to raise an immediate exception.

 In addition, I'm surprised that eval doesn't throw an error when it fails.
 
 try { eval $code; CATCH { ... } }
 
 Using eval STRING in Perl 5 is pretty rare, and should hopefully be rarer in
 Perl 6 than Perl 5.  While it can be used as a does this compile check, it's
 overwhelmingly used with the expectation that the code will compile and so it
 is an exception if it does not.  More pragmatically, this resolves the problem
 of $@ by putting it into an exception rather than a side global.
 
 It also resolves this trap:
 
 if eval $code {
 say code returned true;
 }
 else {
 # this will also happen if $code fails to compile
 say code returned false;
 }
 
 While Perl 6 probably has some sort of magic I failed value you can check
 for separate from boolean false, folks aren't going to go through the extra
 convolutions.

Larry doesn't like immediate exceptions very much, citing something about
parallel processing.  fail() is much preferred for stuff in the specs.

-Stefan


signature.asc
Description: Digital signature


Re: eval should throw an exception on compile error

2011-05-07 Thread Moritz Lenz
On 05/07/2011 07:45 AM, Michael G Schwern wrote:
 I was just playing around with eval, trying to figure out if you can define an
 operator overload at runtime (seems you can't, good) and noticed this in the
 spec... [1]
 
 Returns whatever $code returns, or fails.
 
 How does one get the compile error from an eval? 

It's in $!, like all other errors.

 I don't see anything in the eval tests [2] that's checking for the error,
 just that it returned false.
 
 In addition, I'm surprised that eval doesn't throw an error when it fails.

I agree that eval shouldn't be catching errors, that's what try { } /
CATCH are for (and i know that other #perl6 regulars things similarly).

I dimly recall that Larry had an objection, but I can't remember what it
was :(

Cheers,
Moritz


Re: eval() and lexical introspection in Parrot

2007-12-19 Thread Mehmet Yavuz Selim Soyturk
 One temporary workaround that I considered for this problem
 would be to have eval() use introspection on its caller to
 create a wrapper sub that duplicates the lexical environment of
 the caller, and then use that as the target of an :outer()
 flag when it's passed to imcc.  For example, the code
 passed to imcc would end up looking something like:

That workaround will not solve the problem for an assignment to a
lexical variable from evaluated code. Maybe it's not a problem for
Perl6 tests, though.

It would be good if there was an opcode Cset_outer inner_sub,
outer_sub to set the outer of a sub at runtime. I don't know if it's
possible/straightforward to implement though. Just assigning a new
value to Csub-outer_sub did not work for me before (segfault).


Mehmet Soyturk


Re: eval() and lexical introspection in Parrot

2007-12-19 Thread Patrick R. Michaud
On Wed, Dec 19, 2007 at 11:15:46PM +0100, Mehmet Yavuz Selim Soyturk wrote:
  One temporary workaround that I considered for this problem
  would be to have eval() use introspection on its caller to
  create a wrapper sub that duplicates the lexical environment of
  the caller, and then use that as the target of an :outer()
  flag when it's passed to imcc.  For example, the code
  passed to imcc would end up looking something like:
 
 That workaround will not solve the problem for an assignment to a
 lexical variable from evaluated code. Maybe it's not a problem for
 Perl6 tests, though.

Actually, it would.  The evaluated code would set the (outer)
lexical variable the same way that inner blocks currently do.

Pm


Re: eval() and lexical introspection in Parrot

2007-12-19 Thread Patrick R. Michaud
On Wed, Dec 19, 2007 at 10:57:27PM -0600, Patrick R. Michaud wrote:
 On Wed, Dec 19, 2007 at 11:15:46PM +0100, Mehmet Yavuz Selim Soyturk wrote:
   One temporary workaround that I considered for this problem
   would be to have eval() use introspection on its caller to
   create a wrapper sub that duplicates the lexical environment of
   the caller, and then use that as the target of an :outer()
   flag when it's passed to imcc.  For example, the code
   passed to imcc would end up looking something like:
  
  That workaround will not solve the problem for an assignment to a
  lexical variable from evaluated code. Maybe it's not a problem for
  Perl6 tests, though.
 
 Actually, it would.  The evaluated code would set the (outer)
 lexical variable the same way that inner blocks currently do.

On second thought, if you mean that evaluated code would not
be able to rebind an outer lexical variable, then you're
correct.  Simple assignment would continue to work, however.

Pm


Re: eval

2006-05-25 Thread David Romano

Hi Michael,
On 5/24/06, Michael Mathews [EMAIL PROTECTED] wrote:

Oh try! I like that! But is CATCH implemented in pugs? Anyone care
to give a working example of try/CATCH?

I don't think CATCH is implemented in pugs yet:
#!/usr/local/bin/pugs
catcher;

sub catcher {
   say here;
   try {
   fail_trying;
   say tried;
   CATCH {
   say catch;
   }
   }
   if $! {
   say error;
   }
   say there;
}

sub fail_trying {
   fail_ failed;
}

OUTPUT:
here
tried
error
there

I used fail_ instead of die because I saw it somewhere, but don't
really know the reason to use it instead of die. Anyway, hope that is
at least some help.

David


Re: eval

2006-05-24 Thread Yuval Kogman
On Wed, May 24, 2006 at 19:54:53 +0300, Gabor Szabo wrote:
 if eval command fails, where can I get the error message ?
 
 aka  $@ in P5 ?

$!

http://dev.perl.org/perl6/doc/design/syn/S04.html#Exception_handlers

-- 
  Yuval Kogman [EMAIL PROTECTED]
http://nothingmuch.woobling.org  0xEBD27418



pgppQvQgJzFPq.pgp
Description: PGP signature


Re: eval

2006-05-24 Thread Larry Wall
On Wed, May 24, 2006 at 06:54:53PM +0300, Gabor Szabo wrote:
: if eval command fails, where can I get the error message ?
: 
: aka  $@ in P5 ?

All error variables have been unified into $!, so it should show up there.

Larry


Re: eval (was Re: New S29 draft up)

2005-03-21 Thread Juerd
Paul Seamons skribis 2005-03-18  9:46 (-0700):
  eval slurp foo;

That requires foo to have an #line directive (or whatever its Perl 6
equivalent will be) in order to be useful when debugging.

See also http://tnx.nl/include (I want Perl 6 to have this function that
evals a file such that in it, lexical variables are visible).


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html


Re: eval (was Re: New S29 draft up)

2005-03-20 Thread Rod Adams
Larry Wall wrote:
On Fri, Mar 18, 2005 at 10:28:18AM -0500, Aaron Sherman wrote:
: Thus:
: 
: 	eval read :file(foo);
: 
: There you have it.

The problem being that it will now report errors in some random
temporary string rather than at some line number in a file.  Not good.
Orthogonality strikes again.
I've renamed Cdo EXPR to Cevalfile in S29. (new post soon)
-- Rod Adams




Re: eval (was Re: New S29 draft up)

2005-03-18 Thread Aaron Sherman
On Fri, 2005-03-18 at 05:42, Rod Adams wrote:

 Hmm. maybe we just need a function that loads an entire file and returns 
 a string of it, then feeds that to eval.

Well, I wasn't getting into the IO stuff, but since you said it, this
crosses a line with many related IO operations. I would call that
function read.

Given no parameters the read method on a filehandle (or procedural read
function, given a filehandle) is a convenient getrecord, so given:

read :file(foo)

you have your read a whole file (assuming that the default
record-separator for such an operation would be undef).

Thus:

eval read :file(foo);

There you have it.

-- 
Aaron Sherman [EMAIL PROTECTED]
Senior Systems Engineer and Toolsmith
It's the sound of a satellite saying, 'get me down!' -Shriekback




Re: eval (was Re: New S29 draft up)

2005-03-18 Thread Aaron Sherman
On Fri, 2005-03-18 at 10:28, Aaron Sherman wrote:
 On Fri, 2005-03-18 at 05:42, Rod Adams wrote:
 
  Hmm. maybe we just need a function that loads an entire file and returns 
  a string of it, then feeds that to eval.
 
 Well, I wasn't getting into the IO stuff, but since you said it, this
 crosses a line with many related IO operations. I would call that
 function read.
[...]
 Thus:
 
   eval read :file(foo);

Oh, and

$fh1.read undef, :into($fh2); # sendfile maybe
$fh.read undef, :intofile(foo); # copy via sendfile

is a nice little toy too (that is, read an undefined number of
somethings into $fh2 or file foo from $fh1). sendfile(2) can be used
if the IO layers of $fh1 and $f2 match, but I think it can always be
used in the second case. Much of the dirty work may be handled by
Parrot, which I think supports sendfile already.

This also nicely obsoletes File::Copy and IO::SendFile, thus reducing
the number of modules to be ported ;-)

-- 
Aaron Sherman [EMAIL PROTECTED]
Senior Systems Engineer and Toolsmith
It's the sound of a satellite saying, 'get me down!' -Shriekback




Re: eval (was Re: New S29 draft up)

2005-03-18 Thread Paul Seamons
   eval read :file(foo)

How about:

 eval slurp foo;

Paul Seamons 


Re: eval (was Re: New S29 draft up)

2005-03-18 Thread Dave Whipp
Larry Wall wrote:
On Fri, Mar 18, 2005 at 10:28:18AM -0500, Aaron Sherman wrote:
: Thus:
: 
: 	eval read :file(foo);
: 
: There you have it.

The problem being that it will now report errors in some random
temporary string rather than at some line number in a file.  Not good.
Orthogonality strikes again.
Larry

This reminds of me of an idea I floated a few months ago: 
http://www.codecomments.com/message238291.html.

I don't see any reason (other than performance) why strings shouldn't be 
tagged with their source. For taint-checking, we might even want to 
record the trustworthyness of that source at the same time.

If a string were analagous to an mmap of a file, then many other 
orthogonalities might become available.


Re: eval (was Re: New S29 draft up)

2005-03-18 Thread James Mastros
Larry Wall wrote:
On Fri, Mar 18, 2005 at 10:28:18AM -0500, Aaron Sherman wrote:
: Thus:
: 
: 	eval read :file(foo);
: 
: There you have it.

The problem being that it will now report errors in some random
temporary string rather than at some line number in a file.  Not good.
Orthogonality strikes again.
...unless read returns a Str but source(foo).
	-=- James Mastros


Re: eval {} or carp blah: $@

2002-05-02 Thread Luke Palmer

On Thu, 2 May 2002, Jim Cromie wrote:

 
 with p5, Ive often written
 
 eval {} or carp $ blah;
 
 it seems to work, and it reads nicer (to my eye) than
 
 eval {}; if ($) {}
 
 but I surmise that it works cuz the return-value from the block is non-zero,
 for successful eval, and 0 or undef when block dies, not cuz of magical 
 treatment of $@.

The first one works because the return-value from the eval is undef if the 
block fails.  The second one is because $ is true if it failed, and false 
if it succeeded.

 I gather that ';' is unneeded in p6, and given that $! is the 
 'exception'al topicalizer,
 is this construct no longer reliant on the last value in the eval block ?

I would imagine that you would do it this way:

try {
...
CATCH { }
}

Only inside the CATCH does $! topicalize; I believe $_ becomes aliased to 
that.  Remember, Ctry is Perl 6's eval{}.

 put another way, does the 'topicalizer' reflect the exit condition of 
 the closure ?

It represents the exception that was thrown, and whatsoever might be 
contained in that exception.


Or am I wrong?

Luke




Re: eval {} or carp blah: $@

2002-05-02 Thread Dave Mitchell

On Thu, May 02, 2002 at 02:33:42PM -0600, Jim Cromie wrote:
 
 with p5, Ive often written
 
 eval {} or carp $ blah;

You generally Don't Want To Do That.
If the eval succeeds, but the last statement in the eval happens to come
out as false, then it'll still carp:

$a = 0; eval { 1  $a } or carp 
$a = 0; eval { 1 / $a } or carp 

will both carp

-- 
My get-up-and-go just got up and went.



Re: eval {} or carp blah: $@

2002-05-02 Thread Peter Scott

At 02:33 PM 5/2/02 -0600, Jim Cromie wrote:
eval {} or carp $ blah;

it seems to work, and it reads nicer (to my eye) than

eval {}; if ($) {}

% perl -le 'eval { print No exceptions here; 0 } or warn $ blah'
No exceptions here
  blah at -e line 1.


--
Peter Scott
Pacific Systems Design Technologies




Re: eval {} or carp blah: $@

2002-05-02 Thread Damian Conway

Jim Cromie wrote:

 with p5, Ive often written
 
 eval {} or carp $ blah;
 
 it seems to work,

modulo any block that returns false :-(


 and it reads nicer (to my eye) than
 
 eval {}; if ($) {}
 
 but I surmise that it works cuz the return-value from the block is non-zero,
 for successful eval, and 0 or undef when block dies, not cuz of magical
 treatment of $@.

No. Ceval return the last evaluated value in the block, unless an
exception is thrown, in which case it returns Cundef. The problem with
the Ceval {...} or whatever approach is that there are situations in
which the block can evaluate successfully but still return Cundef.

On failure, Ceval sets C$, so careful programmers test it separately.
Of course, you *can* do that in a single statment if you want:

eval {} or ! and carp $ blah;


 I gather that ';' is unneeded in p6,

Err...no.


  and given that $! is the 'exception'al topicalizer,

Only inside an explicit CATCH block.


 is this construct no longer reliant on the last value in the eval block ?

In Perl 6 Ceval BLOCK becomes Ctry BLOCK and you'll still be able to write:

try { ... } // carp $!;

but that will trip up if the final value of the Ctry block is Cundef.

What you want is:

try {
...
CATCH { carp $! }
}


 put another way, does the 'topicalizer' reflect the exit condition of
 the closure ?

Only in a CATCH block.

Damian



Re: 'eval' odd thought

2000-09-15 Thread Bart Lateur

On Thu, 14 Sep 2000 18:14:49 -0400, Mark-Jason Dominus wrote:

The perl 5 - perl 6 translator should replace calls to 'eval' with
calls to 'perl5_eval', which will recursively call the 5-6 translator
to translate the eval'ed string into perl 6, and will then eval the
result.

Blech, no. eval should stay eval. People are responsible for generating
Perl6 compatible code, if they construct code as strings on the fly.

Warning people when converting a script from perl5 to perl6, that a eval
STRING has been found, is a good idea.

-- 
Bart.



Re: 'eval' odd thought

2000-09-15 Thread Dave Storrs



On Fri, 15 Sep 2000, Bart Lateur wrote:

 On Thu, 14 Sep 2000 18:14:49 -0400, Mark-Jason Dominus wrote:
 
 The perl 5 - perl 6 translator should [recursively handle eval]
 
 Blech, no. eval should stay eval. People are responsible for generating
 Perl6 compatible code, if they construct code as strings on the fly.

I would disagree.  If I'm using a program to translate my code
from one version of Perl to another, I don't want to have to go in and
hand-fix (possibly large) sections of it...it should just _work_.  I'm
with MJD on this one.

Dave




Re: 'eval' odd thought

2000-09-15 Thread Mark-Jason Dominus


 eval should stay eval.

Yes, and this is the way to do that.  

When you translate a script, the translator should translate things so
that they have the same meanings as they did before.  If it doesn't
also translate eval, then your Perl 5 scripts will be using the Perl 6
eval, which isn't what you wanted.




Re: 'eval' odd thought

2000-09-15 Thread Bart Lateur

On Fri, 15 Sep 2000 12:01:55 -0400, Mark-Jason Dominus wrote:

When you translate a script, the translator should translate things so
that they have the same meanings as they did before.  If it doesn't
also translate eval, then your Perl 5 scripts will be using the Perl 6
eval, which isn't what you wanted.

Er... are we talking of the same thing? I should think that P5-P6 would
be a one time operation. A Perl 6 eval that turns a Perl 5 code string
into a Perl 6 code string every time, helps in quickly getting a working
"Perl6" script out of the door, but it's fake. It's takes a pretty hefty
conversion stage every single time. If your P5-P6 translator is slow,
i.e. written in Perl, this would imply a pretty big performace hit. It
also doesn't really help you in *really* converting the eval string to
Perl6. What would help is a debugging mode that prints out the converted
code string, so that the programmer can modify his script so that it
does indeed directly produce this (or a similar) string. From there on,
you no longer need the Perl5-Perl6 translation.

-- 
Bart.