Comments (7)
OIC it thinks its a block. Patch on the way.
from method-signatures.
Hrm. I can special case an empty hash, but what about hashes in general? I don't think there will be much call for checking for anything but an empty hash, so I'm inclined to just special case it. Anything more complicated can be done as a full block.
from method-signatures.
Hashes in general are already supported.
PPI uses the usual perlish guesswork to determine
whether a pair of curlies are a hash or a block.
Empty curlies are arguably a useless special case
as an empty hash will never smartmatch anything.
Of course, treating {} as an empty block would be
equally useless, so special casing them as empty
hash is probably for the best (i.e. least surprising).
from method-signatures.
Well, we should probably special-case it as whatever-doesn't-generate-a-syntax-error. :-D
This fix will go into the next dev release. Just waiting now for CPANTesters to throw up some reports for me to look at ...
from method-signatures.
@thoughtstream PPI might have that guesswork, but inject_for_sig() isn't using it. It's using a regex. I'll look at switching it to PPI, but this fix to the existing regex should go in.
And an empty hash ref smart matches, surprise, an empty hash ref.
perl -wle '$h = {}; print $h ~~ {} ? "Match" : "No Match" '
Match
perl -wle '$h = { foo => 23 }; print $h ~~ {} ? "Match" : "No Match" '
No Match
This is handy for providing a default if the user passes in an empty hash ref, similar to using when ""
for a string parameter.
from method-signatures.
Very good point re empty hashref matching empty hashes.
This definitely should be special-cased.
from method-signatures.
Fixed in version 20121201.
from method-signatures.
Related Issues (20)
- Allow bare sigils as placeholders HOT 1
- Benchmarks vs 5.20
- Type checks should be done after default is applied. HOT 3
- Line numbers offset when signature has spaces in it HOT 9
- Type checking of defaults
- Multi-line defaults are broken HOT 1
- ($a, $b?, $c) should be a compile error HOT 1
- Type error in earlier Perl versions on Windows
- Anonymous functions which are a key in a hash will get the line number of the hash declaration. HOT 2
- Become a wrapper around Function::Parameters HOT 10
- Change Any::Moose for Moo HOT 4
- Getting "The type is unrecognized" if spaces are added HOT 1
- libmethod-signatures-perl: depends on libdata-alias-perl, broken with Perl 5.24
- support Type::Tiny HOT 33
- Support 'method BUILD' for Moo.* HOT 7
- Data::Alias is still required in 20131010 HOT 3
- t/thread-bug.t crashes on Mac OS X with threading enabled HOT 4
- Deprecate `@_` in favor of `...` HOT 1
- Move to evalEmpire org HOT 4
- Allow attributes between sub name and signature HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from method-signatures.