Re: some thing odd in macro

2014-01-04 Thread Carl Mäsak
I understand what's happening. See
https://rt.perl.org/Ticket/Display.html?id=120928. I'm not convinced
it's a bug.

Explaining again here just in case I was too vague in the bug report.

1. Variables lead double lives. There's the ghost world static
version of a variable, that existed since the beginning of time and is
the final fallback during variable lookup (instead of the runtime
dying). Then, there's one live copy of the variable for every time a
code block is entered. In the case of the mainline and %h, there's one
such copy.

2. By the time the macro is called, the program hasn't started yet.
Hence only the ghost world %h exists. It is to that one the
assignment is made. (As evidenced by the diag macro in the bug
report.)

3. Then the program starts. The live %h is created. It is inspected
and found empty, because no-one has ever assigned to it.

I agree that the behavior is surprising. Unfortunately, it's fairly
consistent too. Instead of taking sides, I'm going to think deeply
about it, and maybe blog about it too.

It does remind me of a similar problem with roles. Not sure we have a
reference for that problem anywhere (so maybe that deserves a blog
post too), and I'm too un-coffee'd to write it up, but it's
essentially the same difficulty, solved through a hack. In the short
term, maybe the %h problem needs to be solved through a hack, too. In
the long term, we should round up all these similar problems and find
some common way to solve them all.

// Carl

On Sun, Dec 29, 2013 at 2:25 AM, Richard Hainsworth
rnhainswo...@gmail.com wrote:
 I was trying out macros and run into an anomaly. Not sure what is happening.

 I tried a macro snippet as a standalone script, then tested exactly the same
 in REPL. It worked in REPL, as in the hash variable was changed. But the
 hash variable stayed the same in the stand alone. What am I missing?

 Here is a paste from my terminal.

 $ cat macro-test.p6
 my %o;
 macro attr ( $nm, $val ) { quasi { %o{ {{{$nm}}} } = {{{$val}}}  } }
 %o.say;
 attr 'fst', 42;
 %o.say;
 $
 $ perl6
 my %o
 ().hash
 macro attr ( $nm, $val ) { quasi { %o{ {{{$nm}}} } = {{{$val}}}  } }
 Nil
 %o.say
 ().hash
 attr 'fst', 42
 42
 %o.say
 (fst = 42).hash
 ^C
 $ perl6 macro-test.p6
 ().hash
 ().hash
 $
 $ perl6 -v
 This is perl6 version 2013.11 built on parrot 5.9.0 revision 0




[perl6/specs] c358c1: [S05] Remove redundant word

2014-01-04 Thread GitHub
  Branch: refs/heads/master
  Home:   https://github.com/perl6/specs
  Commit: c358c192b6718ec71a56f1d1ce23daefe7791574
  
https://github.com/perl6/specs/commit/c358c192b6718ec71a56f1d1ce23daefe7791574
  Author: lue rnd...@gmail.com
  Date:   2014-01-03 (Fri, 03 Jan 2014)

  Changed paths:
M S05-regex.pod

  Log Message:
  ---
  [S05] Remove redundant word




[perl6/specs] ec8445: [S05] Fix redundant [alpha|_] examples.

2014-01-04 Thread GitHub
  Branch: refs/heads/master
  Home:   https://github.com/perl6/specs
  Commit: ec844594bf51f1cc7375204c97a20e38012e7ba5
  
https://github.com/perl6/specs/commit/ec844594bf51f1cc7375204c97a20e38012e7ba5
  Author: lue rnd...@gmail.com
  Date:   2014-01-03 (Fri, 03 Jan 2014)

  Changed paths:
M S05-regex.pod

  Log Message:
  ---
  [S05] Fix redundant [alpha|_] examples.

In addition to being redundant, they carry the unfortunate implication
that alpha does not match underscore, which it in fact does. The
underscore has been replaced with \- (match a hyphen) in these
situations. newbie_Perl6++ for noticing.