-
Notifications
You must be signed in to change notification settings - Fork 571
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
foo()() should be valid syntax (no arrow between argument lists) #10334
Comments
From @maukeCreated by @maukeHello, I'd really like for foo()() to be valid syntax (equivalent to foo()->()). Rationale: I think it would make the language more regular. (In fact, I was surprised to Perl Info
|
From zefram@fysh.orgl.mai@web.de wrote:
foo() isn't a subscript. Crucially, unlike in $foo[0] or $foo->(), -zefram |
The RT System itself - Status changed from 'new' to 'open' |
From @ap* Zefram <zefram@fysh.org> [2010-04-20 23:55]:
How so? |
From zefram@fysh.orgA. Pagaltzis wrote:
Currently, "$x = f();" means the same thing as "$x = f;", where f is a -zefram |
From ajs@ajs.comOn Tue Apr 20 15:09:30 2010, aristotle wrote:
For sake of example assume that these calls all return references to my $a = foo; How you dereference now: my $a = foo->(); How you dereference if we used bare parens: my $a = foo()(); Note that you have to first add the previously unrequired parens to Me, I think this is a trivial concern and doesn't impede the change, but |
From @ikegamiOn Tue, Apr 20, 2010 at 6:14 PM, Zefram <zefram@fysh.org> wrote:
f() and f g() are not of the form f(...)(). You didn't describe an Mind you, I think the proposed syntax is ugly. |
From ben@morrow.me.ukQuoth ikegami@adaelis.com (Eric Brine):
Should f () be interpreted as (f()) or as (f())->() ? (The whitespace is for effect, it's obviously not significant.) It may f g() () be parsed as f( g()->() ) or as f( g() )->() or indeed as g->f()->() ?
IMHO it's slightly less ugly than f()->(), but not by much. Ben |
From @ikegamiOn Tue, Apr 20, 2010 at 8:19 PM, Ben Morrow <ben@morrow.me.uk> wrote:
f () *is* interpreted as (f()) It may be obvious how to resolve the ambiguity, but it's still there. "f ()" is not of the form "f()()", so it was not covered by the proposal.
other, less clear, cases as well: for instance, should
Just as clear. "f g() ()" (as a whole) is not of the form "f()()", so it was Mind you, you are free to expand to scope of the proposal. *That* could open |
From @ap* Zefram <zefram@fysh.org> [2010-04-21 00:20]:
This is not what the proposal is about. As Eric has already covered, nothing should change, except that * Ben Morrow <ben@morrow.me.uk> [2010-04-21 02:20]:
Is $f {foo} interpreted as $f{foo} or as $f->{foo} ? If you want the `f()->()` parse, you simply write it that way: f->() much like you’d write either `$f{foo}` or `$f->{foo}`, but you That’s not ambiguous, and neither would this syntax be. Oh, and of course, `f->()` already *does* work that way.
There is no such ambiguity. The proposal concerns only cases
Not at all; by all I can tell, it’s very, very simple.
How would f g() -> () parse? That’s how f g() () should parse as well. There is, I repeat, absolutely no ambiguity in this proposal as Paging Abigail… Regards, |
1 similar comment
From @ap* Zefram <zefram@fysh.org> [2010-04-21 00:20]:
This is not what the proposal is about. As Eric has already covered, nothing should change, except that * Ben Morrow <ben@morrow.me.uk> [2010-04-21 02:20]:
Is $f {foo} interpreted as $f{foo} or as $f->{foo} ? If you want the `f()->()` parse, you simply write it that way: f->() much like you’d write either `$f{foo}` or `$f->{foo}`, but you That’s not ambiguous, and neither would this syntax be. Oh, and of course, `f->()` already *does* work that way.
There is no such ambiguity. The proposal concerns only cases
Not at all; by all I can tell, it’s very, very simple.
How would f g() -> () parse? That’s how f g() () should parse as well. There is, I repeat, absolutely no ambiguity in this proposal as Paging Abigail… Regards, |
From @AbigailOn Thu, Apr 22, 2010 at 05:45:06PM +0200, Aristotle Pagaltzis wrote:
I don't think 'f () ()' going to mean 'f () -> ()' is going to cause a problem. *However*, making the arrow optional should also mean making the arrow f (a, b, c) -> [1]; Currently, f (a, b, c) [1]; is a syntax error. But there's room for some kind of executive decision here. f (a, b, c) -> [1]; or f (b); ? I'd go for the first meaning, after all, the second meaning can easily f +(a, b, c) [1]; # Pre-declaring f may be needed or f ((a, b, c) [1]); Of course, since it's currently a syntax error, picking either meaning Personally, I don't care that much for '() ()' going to mean '() -> ()'. $$array_ref [1]; instead of $array_ref -> [1]; But that also means writing ${f ()} [1]; which is a lot uglier than f () -> [1]; It would be a lot nicer if I could just write f () [1]; Oh, and to answer your question, as already pointed out in this thread: f -> () (); *is* valid. The proposal doesn't change this meaning, but it's an occurance Abigail |
From @ap* Abigail <abigail@abigail.be> [2010-04-22 18:20]:
In this case I would say mu. There is a third possible parse: (f (a, b, c)) [1] And that is almost *always* the parse I want, eg. my $inode = stat ($fh) [1]; or my $firstname = split (/ *, */, $fullname) [1];
The regularity between `()[]` and `(){}` is of course a nice
Oh wow: $ perl -MO=Deparse,-x7,-p -e'f->()()' Learn something new every day. How does that even work? I suppose Regards, |
Migrated from rt.perl.org#74540 (status was 'open')
Searchable as RT74540$
The text was updated successfully, but these errors were encountered: