Skip to content

Conversation

ghost
Copy link

@ghost ghost commented Sep 19, 2013

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

Note that this doesn't break existing code even though the actual type was changed. Well, it /shouldn't/, but if there are any reports of a regression we can turn it back into a string. In that case it will still work with the new LinkageType since these string<=>enum conversions are implicit when the template is called.

@monarchdodra
Copy link
Collaborator

LGTM

C = "C", ///
Windows = "Windows", ///
Pascal = "Pascal", ///
Cpp = "C++" ///
Copy link
Collaborator

Choose a reason for hiding this comment

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

You need to mark all these with ditto. If you don't, you'll generate an empty paragraph for each entry, rather than a paragraph that holds everything.

EG compare:
http://dlang.org/phobos/std_traits.html#.FunctionAttribute
http://dlang.org/phobos/std_traits.html#.Variadic

@monarchdodra
Copy link
Collaborator

I think the template "SetFunctionAttributes" would also need some migrating.

@ghost
Copy link
Author

ghost commented Sep 24, 2013

I think the template "SetFunctionAttributes" would also need some migrating.

The tests for this function use functionLinkage internally, it seems to pass the tests. Could you be more specific?

@monarchdodra
Copy link
Collaborator

The tests for this function use functionLinkage internally, it seems to pass the tests. Could you be more specific?

It was mostly the line of code

        enum linkages = ["D", "C", "Windows", "Pascal", "C++", "System"];

I was thinking about.

But I'm not sure it's actually related.

C = "C", /// ditto
Windows = "Windows", /// ditto
Pascal = "Pascal", /// ditto
Cpp = "C++" /// ditto
Copy link
Collaborator

Choose a reason for hiding this comment

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

Strange, I thought I had left a message about this before, but I can't find it anymore. Maybe someone deleted it? There's no un-delete in git-hub, AFAIK?

Anyways, this mostly looks good to me, and I would have pulled this earlier, but I do have a reservation: It's the:

Cpp = "C++",

What troubles me is that:

void main()
{
    auto a = LinkageType.Cpp;
    assert(a == "C++");
    writeln(a);
}

Prints

Cpp

In particular, I could see this potentially breaking code generating code, that does things such as

mixin(format("extern (%s) foo()", functionLinkage!foo));

Do you think this might be a problem?

Copy link
Collaborator

Choose a reason for hiding this comment

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

https://d.puremagic.com/issues/show_bug.cgi?id=11571

I've been wanting to file this for a while, you just gave me the excuse :)

Copy link
Author

Choose a reason for hiding this comment

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

Good catch. I think we can close the pull and the enhancement, it's almost guaranteed that functionLinkage is mostly used during code-generation, and this pull would break code.

Copy link
Author

Choose a reason for hiding this comment

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

As for comment deletions, for my own comments I use a <del>text</del> section rather than delete them.

@ghost ghost closed this Nov 22, 2013
This pull request was closed.
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.

2 participants