New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allomorphic numerics should probably be accepted as literals in signatures #1828
Comments
|
perhaps .trim the result of parsing what is between < > before further processing?
… On 14 May 2018, at 18:12, Zoffix Znet ***@***.***> wrote:
We have some funky rules regarding when angle brackets produce a numeric literal vs. when they produce a numeric allomorph, so it could be hard for a beginner to figure out which makes what.
We currently accept numeric literals in signature, however, allomorphic numerics produce a rather LTA error. IMO we should accept RatStr and other allomorphic numerics just as we accept plain numeric literals.
$ perl6 -e '-> <1/2> {say "in"}(<1/2>)'
in
$ perl6 -e '-> < 1/2> {say "in"}(< 1/2>)'
===SORRY!=== Error while compiling -e
Missing block
at -e:1
------> ->⏏ < 1/2> {say "in"}(< 1/2>)
expecting any of:
formal parameter
$ perl6 -v
This is Rakudo version 2018.04-20-g7847768 built on MoarVM version 2018.04-34-g25f165a
implementing Perl 6.c.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
That would lose the information on whether it's supposed to be an allomorph or a plain numeric, wouldn't it? |
Err. It'd be passed fine, but typing will be wrong. |
|
Actually, I'm gonna self-close this. Changed my mind. If The alternative YAGNI. |
|
FWIW, I thought that |
|
The current rule (modulo some bugs) is if it's an expression without spaces then you get a numeric literal, otherwise you get an allomorph. So If you make all of them allomorphs, then there'd be no way to specify, for example, a -> <1/42> { say "you gave me a Rat literal" }(1/42) |
Did a bit of digging. It's been documented for a year. IIRC I wrote it down when bdfoy was doing research for the LP6 book so it might be documented in that book too. And it was TimToady who told me about it, stating the reasoning for it was pragmatism. |
|
Aha, ok, get it now: we're in fact abusing the So you're saying that |
Pretty much.
Right, before static optimizer constant folds it, it's just an infix # --target=ast
- QAST::Op(call &infix:</>) <wanted> /
- QAST::Want <wanted> 1
- QAST::WVal(Int)
- Ii
- QAST::IVal(1) 1
- QAST::Want <wanted> 2
- QAST::WVal(Int)
- Ii
- QAST::IVal(2) 2
# --target=optimize
- QAST::WVal(Rat)
Not an expert on this, but wouldn't both of those happen after the decision about whether constant foo = 1;
constant bar = 2;
sub (foo/foo+foo+foo+foo-bar) {}And I'd say such rules a lot more complex to understand than the current |
|
Thanks for the enlightening answer! Closing again now |
We have some funky rules regarding when angle brackets produce a numeric literal vs. when they produce a numeric allomorph, so it could be hard for a beginner to figure out which makes what.
We currently accept numeric literals in signatures, however, allomorphic numerics produce a rather LTA error. IMO we should accept
RatStrand other allomorphic numerics just as we accept plain numeric literals.The text was updated successfully, but these errors were encountered: