Fix t/begin.t to report failure at the right location.
Demonstrate that we can compile methods at compile time without BeginLift.

Rather than using Devel::BeginLift or declaring things with a BEGIN block,
we simply rewrite "func foo {...}" to be "sub foo {...}" and the rest
happens magically.

The one caveat is Devel::Declare expects `func` and `method` to get
the code ref being generated.  Rather than fight this, we go along
with it.

Only four tests fail.  Fixes on the way.
Fix attributes.

Devel::Declare::MethodInstaller::Simple will add "sub $attrs" to
$before in inject_if_block() if it sees attributes.  This messes with
our custom inject_if_block().  So just ignore anything already on
$before and handle attributes ourselves.
Turn off compile at BEGIN for Method::Signatures::Modifiers, again.

Method::Signatures::Modifiers always defines methods at runtime.  It
was doing this by overriding code_for(), but the compile time logic
has moved.  Overriding _do_compile_at_BEGIN() is safer.
Eliminate reference to Devel::BeginLift.
Improve t/larna.t

Check that the resulting list is what we expect it to be.
Otherwise func() might swallow everything in the list.
Don't need a copy of inject_scope() any more.

This was necessary when we were doing more complicated things to
work around Devel::BeginLift.  Now its just a copy of the one
from Devel::Declare::Context::Simple.
Test attributes with anonymous functions.

Juuuust to make sure.
Fix t/larna.t

For some odd reason I don't understand, Devel::Declare only wants you to
inject "sub" for named routines.  Anon routines don't get a sub nor
do they need to pass attributes.  *shrug*
Add "signature_error_handler".

Subclasses can override signature_error_handler to do something
other than just die() with the message generated by signature_error.
first cut at adding a //= default

It adds a second kind of default to Method::Signatures,
so that instead of:

    func foo ($opt_arg?) {
        $opt_arg //= $DEFAULT;
        ...
    }

you can just write:

    func foo ($opt_arg //= $DEFAULT) {
        ...
    }

I submit it for your consideration, with the full disclosure that we
have not approved such a mechanism for Perl 6. And that Larry may well
never allow it. Personally, I find it natural and obvious, but I leave the
decision entirely up to you both. >;-)
prettied up formatting for is_optional a bit
switched test file from no_plan to done_testing
changing //= default to "when undef"

The "when * < 0" syntax is borrowed from Perl 6, where it's a standard and
widely used feature. But I agree that it might be a little too funky for
MS. See the attached next-generation patch, which uses a Perl 5
compatible block-and-$_ syntax instead. Much more appropriate, I think.

Note that, compared to the previous submission, the attached patch also
has more robust parsing of 'when' modifiers.
patched up new test files to use done_testing style
vast improvements to signature parsing

It provides the following enhancements (some as previously discussed,
others as fixes to problems encountered along the way):

    * Implements '= $DEFAULT when $CONDITION'
      (with default and condition parsed via PPI)

    * Implements '= $DEFAULT when {BLOCK}'
      (with default and block parsed via PPI)

    * Implements '//= $DEFAULT'
      as a short-cut for '= $DEFAULT when undef'

    * Documents these new default mechanisms

    * Improves parsing of explicit method invocants
      (specification errors like '\:$param' no longer treat '\' as invocant)

    * Improves parsing of disjunctive type specifications
      (no longer restricted to a maximum of two alternatives)

    * Improves parsing of parameterized type specifications,
      which may now be nested: func foo(ArrayRef[HashRef[Int]] $array)

    * Improves error messages issued during signature parsing
      (and refactors that code to reuse it for run-time error messages as well)

    * Improves documentation of signature syntax slightly
      (via ASCI art!)

    * Fixes a minor bug in t/named.t
      (traits specifications must precede defaults)

    * Adds test cases for all new features and most other fixes

In testing, I can detect no measurable difference in performance under these
changes, except that a couple of tests involving more complex signatures
actually seem to compile a percent or two faster.
patched up new test file to use done_testing style
changing // to || so it will work on Perls < 5.10
clarified a confusing bit in the ASCII art picture
now can do where constraints

I realized that (a) I really need the 'where CONSTRAINT' feature *now*,
and (b) the previous PPI-based parameter parsing patch makes that
extension extremely straightforward.