Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Issue 8635 - Allow postfix expressions for new #1111

Merged
merged 4 commits into from Jun 9, 2013

Conversation

Projects
None yet
9 participants
Contributor

tgehr commented Sep 9, 2012

http://d.puremagic.com/issues/show_bug.cgi?id=8635

This pull implements the proposed grammar change. It turns NewExpressions into
PrimaryExpressions, so that they support postfix expressions.

I will make a pull request to update the documentation as soon as this gets merged.

Member

alexrp commented Sep 9, 2012

Looks reasonable, and as far as I can tell, it won't break any code since it merely lifts a restriction in the grammar.

Member

yebblies commented Oct 7, 2012

Please name the test case after the bug report number, don't just increment.
Please squash the commits together, and prefix the commit message with 'Fixes Issue XXXX'.

As this is a language change, it requires the approval of @WalterBright and/or @andralex.

Member

9rnsr commented Oct 13, 2012

In current, nested class construction with new is chain-able with dot. So, this is reasonable language fix to me.

class C {
    class N { int foo(){ return 1; } }
    void foo(){ return 10; }
}
void main() {
    auto x = new C().foo();     // fails

    auto c = new C();
    auto n = c.new N().foo();   // OK
}

@andralex , please give comment us.
@tgehr , this pull request now cannot be merged automatically. Please rebase.

Contributor

deadalnix commented Nov 24, 2012

This behavior is consistent with what exists in java for instance. Unless a reason exists for this difference it have to be removed.

The code look sane to me, so I advocate for including this change into the language.

AndrejMitrovic and others added some commits Nov 28, 2012

Merge pull request #1338 from rainers/win64_cpp_mangle
fix issue 9093: C++ symbol mangling for Win64
Merge pull request #1330 from AndrejMitrovic/Fix8802
Issue 8802 - Lookup problem with void* enum base type
@ghost

ghost commented Dec 3, 2012

This needs a rebase

@9rnsr 9rnsr commented on an outdated diff Dec 5, 2012

test/runnable/test19.d
@@ -422,6 +422,22 @@ void test8128()
/* ================================ */
+class C8635{
+ int x;
+ this(int x)
+ {
+ this.x = x;
+ }
+}
+void test2(8635
@9rnsr

9rnsr Dec 5, 2012

Member

This line is broken.

@ghost

ghost commented Dec 8, 2012

This doesn't work:

class C
{
    int x;
    this() { this.x = 2; }
}

void main()
{
    // Error: C.x is used as a type
    assert(new C.x == 2);
}

It works if you put the parens:

assert(new C().x == 2);

Is this behavior ok? I guess this makes sense to disambiguate what is being new-ed.

Member

alexrp commented Dec 8, 2012

Well, it probably thinks that C.x is an inner class/struct. I don't think new without parens can be unambiguous in that case.

@ghost

ghost commented Dec 8, 2012

Then this gets a LGTM from me.

@ghost

ghost commented Dec 8, 2012

(Though we may have to notify WB and AA to get approval for the language change)

Member

quickfur commented Dec 21, 2012

LGTM.

@ghost ghost assigned WalterBright May 12, 2013

Owner

andralex commented May 12, 2013

Assigning to Walter. Not sure whether this helps much. I'd be convinced if it supports some compelling idioms. Thoughts?

WalterBright added a commit that referenced this pull request Jun 9, 2013

Merge pull request #1111 from tgehr/master
 Issue 8635 - Allow postfix expressions for new

@WalterBright WalterBright merged commit 44fdd81 into dlang:master Jun 9, 2013

1 check was pending

default Pass: 4, Pending: 6
Details

@9rnsr 9rnsr referenced this pull request in dlang/dlang.org Jun 9, 2013

Merged

Issue 8635 - Allow postfix expressions for new #337

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment