in reply to On the Improvement of Exegesis 12
I mentioned this to Larry when he was drafting A12, but I don't like the indirect syntax. I never have, primarily because I don't understand what the reason is, given that new() is a multimethod.
To me, it is just an unnecessary addition, with a postfix sigil to boot! It doesn't pass Occam's Razor, imho.
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
Re: Get rid of the Indirect Syntax, please!
by adrianh (Chancellor) on Apr 18, 2004 at 16:51 UTC
|
I don't understand what the reason is, given that new() is a multimethod
So instead of doing:
print $*OUT: "Howdy, world!\n";
in Perl 6 you'd prefer
$*OUT->print( "Howdy, world!\n" );
? | [reply] [d/l] [select] |
|
If I created $*OUT as an object, then yes, I would prefer to call the method on it. I don't want to have to remember that I need a colon after it an object reference just because the Perl6 parser needs it to disambiguate between a multimethod and a multisub.
Personally, I always felt that print() (and friends) has a difficult syntax to work with, given that it is different than every other other CORE function.
Frankly, if that syntax is important enough to you, you could just do something like (in Perl5 syntax):
multisub print
{
my $invocant = shift;
if (UNIVERSAL::can( $invocant, 'print')
{
return $invocant->print(@_);
}
print ($invocant, @_);
}
Now, you treat it just like a regular function, if necessary.
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
| [reply] [d/l] |
|
If I created $*OUT as an object, then yes, I would prefer to call the method on it.
That's fair enough. You can of course do it that way. However some people do like the indirect syntax. I'm not such a person myself, but I can understand those who do like it. It can make slotting objects into a more procedural style of coding easier.
I don't want to have to remember that I need a colon after it an object reference just because the Perl6 parser needs it to disambiguate between a multimethod and a multisub.
Isn't it the difference between a subroutine call and a method call, rather than multimethod vs. multisub - the colon is just an indicator that the method (multi or otherwise) is being called in an indirect style?
I admit I have only skimmed A12 so I may be getting the wrong end of the stick.
Personally, I always felt that print() (and friends) has a difficult syntax to work with, given that it is different than every other other CORE function.
But it's not just print. Is close $fh a subroutine call or a method call? I think that forcing the dot syntax for method invocation everywhere would result in something unperlish.
Frankly, if that syntax is important enough to you, you could just do something like (in Perl5 syntax):
Yes you could, but why should you if it can be well supported by the core? The indirect calling style has many problems in Perl 5, but in Perl 6 we have Class objects and an explicit colon syntax to disambiguate the nasty cases - so I don't really see the problem?
| [reply] [d/l] |
|
|
|
|
|
The syntax you just printed is the preferred method for some languages like Java (i.e. there are no barewords you can use, you have to be very explicit about everything -- unless the method is in schope, which it never is). Personally, I don't like going overboard on Object Orientedness, but I can understand why some people like it, and how it can make the language clearer for some people. All in all, I think it's mostly a matter of personal preference.
Want to support the EFF and FSF by buying cool stuff? Click here.
| [reply] |
|
|