Shop OBEX P1 Docs P2 Docs Learn Events
Spin2 Method Defining/Calling — Parallax Forums

Spin2 Method Defining/Calling

JonnyMacJonnyMac Posts: 8,918
edited 2019-12-10 21:33 in Propeller 2
I am wondering if there is any support for defining and calling Spin2 methods that don't use arguments with an empty set of parenthesis (as other languages do). To me, this allows someone reading my code (which is mostly lowercase) to easily differentiate between a method name and a variable name.

Of course, Chip will make the final decision -- I'm hoping he supports the idea.

Comments

  • cgraceycgracey Posts: 14,133
    John, Spin2 could allow 'method()' or just 'method', but I don't want to force 'method()'. How do you feel about that?
  • (warning: threadjacking afoot)

    Speaking of methods, can we get ? as a valid character to end a method name or would that mess something up?
    So one can name a method that would usually be called something like "is_active" as just "active?", like in Ruby.
    A small thing, but I think it's nice.
  • cgracey wrote: »
    John, Spin2 could allow 'method()' or just 'method', but I don't want to force 'method()'. How do you feel about that?

    I think that should be pretty easy to support in fastspin too.
    Wuerfel_21 wrote: »
    (warning: threadjacking afoot)
    Speaking of methods, can we get ? as a valid character to end a method name or would that mess something up?
    So one can name a method that would usually be called something like "is_active" as just "active?", like in Ruby.
    A small thing, but I think it's nice.

    Please, let's not. ? is already used in the Spin2 conditional operator ( e.g. (x < y) ? x : y ) and in Spin1 for random numbers; adding yet another overloaded use for it seems dangerous.
  • cgracey wrote: »
    John, Spin2 could allow 'method()' or just 'method', but I don't want to force 'method()'. How do you feel about that?

    That would be okay with me -- I'm very deliberate about style, so I would use it.

    Thanks, Chihp.
  • I would certainly like it to be possible, since I always type it that way by default (because of other languages requiring it).
  • kwinnkwinn Posts: 8,697
    JonnyMac wrote: »
    cgracey wrote: »
    John, Spin2 could allow 'method()' or just 'method', but I don't want to force 'method()'. How do you feel about that?

    That would be okay with me -- I'm very deliberate about style, so I would use it.

    Thanks, Chihp.

    LOL, you are a bit touchy about that. My first name is kurt and I have been called kirk and koot, and numerous other variations over the years, including having an n in place of the r on a letter from a dealership where I purchased a car. A bit annoying, and bothered me a bit as a kid, but I got over it pretty quick. It just did not seem worth worrying about.
Sign In or Register to comment.