Comments (7)
The feature isn't really that ':' can be in a method name -- it is that ANYTHING can be in a method name. An illustrative example is using ' ' (a single space) as a method name.
class CrayCray {
my $method = method (|args) { 42 };
$?CLASS.^add_methmethod(' ', $method);
}
say CrayCray.new." "() # outputs "42"
You can see here that I wasn't able to declare this method using the normal syntax. So maybe another question is why we are able to use the ":" in the method name without having to go out of our way to make it look fancy. I guess... because it's not ambiguous because you can't put namespaces in normal method declarations.
from old-design-docs.
I'm actually for allowing as much as possible in method names. Not so much for Perl 6 code as method names that have to be quoted all the time aren't that useful, but for interop with other languages which may have strange naming conventions.
from old-design-docs.
@niner I'm all for allowing any kind of character in method names but I think it's a bit confusing to just let colons occur in method declarations without needing to add them via a special method (ala the space method @awwaiid posted). At the very least, somewhere along the way, a warning/error should be issued as the ::
syntax is meant to be a specific syntactic/semantic operator/sigil in a few different contexts (all of them revolving around names of things).
from old-design-docs.
:: is a required feature in method names because of the way coercions work.
http://docs.perl6.org/language/functions#Coercion_Types
A single ':' is even more necessary because of method foo:sym in
grammar actions.
On Mon, Jan 18, 2016 at 5:44 AM Jake Russo [email protected] wrote:
@niner https://github.com/niner I'm all for allowing any kind of
character in method names but I think it's a bit confusing to just let
colons occur in method declarations without needing to add them via a
special method (ala the space method @awwaiid https://github.com/awwaiid
posted). At the very least, somewhere along the way, a warning/error should
be issued as the :: syntax is meant to be a specific syntactic/semantic
operator/sigil in a few different contexts (all of them revolving around
names of things).—
Reply to this email directly or view it on GitHub
#106 (comment).
from old-design-docs.
@LLFourn thanks for the linkage! So in that situation they are allowed because they need to match how the type is written. Could you provide a link or explanation wrt to grammar actions, I don't see anything like that in the grammar actions section.
It still feels like some discussion could be had regarding whether they should be declared the same or if maybe there could be a pertinent error message given if you tried to call one, e.g.,
"Cannot locate &bar, this method call contains
::
perhaps you meant to enclose the call in quotes."
from old-design-docs.
https://github.com/rakudo/rakudo/blob/nom/src/Perl6/Actions.nqp#L1570
I haven't tried but it probably works in vanilla Perl 6 too. (btw we truely need to work on the grammar docs).
If you mean that error messages could be improved when invoking methods with "::" that don't exist I can agree with you. Keep in mind that qualified method calls are a thing:
Lloyds-iMac:~ llfourn$ p '"foo".Mu::say()'
foo
Lloyds-iMac:~ llfourn$ p '"foo".Mu::sa()'
Cannot find method 'sa'
in any find_method_qualified at gen/moar/m-Metamodel.nqp line 1101
in block <unit> at -e line 1
from old-design-docs.
Thanks everyone for clearing this up for me!
from old-design-docs.
Related Issues (20)
- In Synopsis S05 <sp> should probably be updated to <space>
- S07: `@a.push: @b` pushes one, not @b.elems values HOT 6
- Shorthand Notation for Private Method Calls HOT 1
- Multiple same-named arguments
- Add warning noting these are now historical documents
- Documentation for &infix:<andthen> versus "with" is incorrect
- S05: backslash+<alpha> in regexes should never be literal. HOT 2
- sprintf needs clarification
- Numbered list/head in Pod (S26) HOT 8
- <:Foo> syntax in regexes ambiguous HOT 5
- RFC: Replace unibool with uniprop-bool in S15 HOT 3
- 29-os/system.t fails when no perl6 is installed HOT 1
- Website is down
- S02: ordering of hash entries in the .perl method HOT 4
- Do we want quotemeta or not?
- t/spec/S32-str/sameaccent.t HOT 1
- S03: 42 x *, 42 xx *, 42 x Inf, 42 xx Inf
- Multiple ws rules HOT 3
- $() and $( ) should be the same thing
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 old-design-docs.