Skip to content
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

Issue 3659 & others - Relax opEquals signature #373

Merged
merged 9 commits into from
Sep 30, 2011

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Sep 9, 2011

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

requires: druntime git://github.com/9rnsr/druntime.git relax_opEquals_sig

Points:

  • Remove opEquals signature restriction.

    We can define any signatures of opEquals, even if it is template funciton.

  • Make stub for TypeInfo_Struct.xopEquals

    (Needs druntime fix, see Supplemental changes of dmd/pull/373 druntime#70)

    TypeInfo.equals gets two lvalue through in void*.
    So we should make stub for calling user opEquals.

    xopEquals = bool function(in void* p, in void* q) {
        return ( *cast(const S*)p ).opEquals( *cast(const S*)q );
    };
    

    // If user opEquals is qualified const, and gets ref const S, and returns bool,
    // we can set its function pointer to xopEquals directly.
    // But it is not yet implemented.

    If this stub couldn't compile, stub code is replaced with follows:

    xopEquals = bool function(in void* p, in void* q) {
        throw Error("TypeInfo.equals is not implemented")
    };
    

    TypeInfo.equals should not break both objects constness, so we cannot call
    the opEquals that breaks objects constness. Instead throws Error at runtime.

  • If no user opEquals (and need opEquals definition), compiler builds following opEquals automatically.

    const bool opEquals(const S rhs) { ... }

    This signature can receive rvalue of S, and const copy of lvalue.

@yebblies
Copy link
Member

The requires line says phobos but points to druntime.git !

Also you probably mean 'stub' not 'stab'.

@9rnsr
Copy link
Contributor Author

9rnsr commented Sep 11, 2011

Thanks for your pointing out, yebblies!

@yebblies
Copy link
Member

This now seems to be causing a linker failure.

@9rnsr
Copy link
Contributor Author

9rnsr commented Sep 14, 2011

@yebblies
This patch includes copy-constructor signature changing (it is only used for internal code generation), so it is necessary to rebuild phobos.

@yebblies
Copy link
Member

If this works for you then it's probably a problem with having another version of phobos on the linker path. I'll have a look, it wouldn't be the first time.

@yebblies
Copy link
Member

Yep, using the wrong dmd.conf. Should be correct the run after next.

WalterBright added a commit that referenced this pull request Sep 30, 2011
Issue 3659 & others - Relax opEquals signature
@WalterBright WalterBright merged commit f52dac9 into dlang:master Sep 30, 2011
@@ -1,7 +1,5 @@

import core.vararg;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removal of this import broke this test on 64 bit platforms

braddr pushed a commit to braddr/dmd that referenced this pull request Oct 22, 2012
Add a function for reconnect in TcpSocket, used by server high performance socket programming
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants