Git Product home page Git Product logo

Comments (7)

awwaiid avatar awwaiid commented on July 17, 2024

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.

niner avatar niner commented on July 17, 2024

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.

MadcapJake avatar MadcapJake commented on July 17, 2024

@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.

LLFourn avatar LLFourn commented on July 17, 2024

:: 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.

MadcapJake avatar MadcapJake commented on July 17, 2024

@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.

LLFourn avatar LLFourn commented on July 17, 2024

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.

MadcapJake avatar MadcapJake commented on July 17, 2024

Thanks everyone for clearing this up for me!

from old-design-docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.