-
-
Notifications
You must be signed in to change notification settings - Fork 701
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
[REG2.065a] Issue 12098 - libcurl bad argument on handle null #1920
Conversation
If this change silently broke Phobos, it may silently break user code. Posted my concerns here: |
I have the same concern. |
@CyberShadow @monarchdodra To prevent silent braking, I opened dlang/dmd#3240. From its auto-tester result, you can see the effect of the diagnostic enhancement. |
So, how about this change? |
This series of cascading changes makes me nervous. It suggests we are not thinking these things through, and rewriting rules for static opCall at the last minute seems terribly dangerous. |
Constructor taking the url as parameter. | ||
*/ | ||
this(const(char)[] url) | ||
static HTTP opCall(const(char)[] url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the comment disappearing here and in the other edits?
Looking at the curl.d, it seems the problem is that curl is trying to have default construction that is not the simple .init property. Trying to fudge how the language is supposed to work is going to cause problems, and we're seeing that effect. It's like stepping on a bulge in a rug - it just shifts the bulge to another place. |
Which is a problem people run into all the time, being desperate for a default ctor. If people are trying all means necessary to be able to define default construction then maybe the language should start supporting that. I really don't think people are going to get used to the missing default ctor (it's been like that for years..), they're just going to keep asking for it. |
I've yet to hear a solid explanation for why D doesn't have default construction. All I've heard so far was vague hand-waving about "generic code and .init", but no actual explanation why and when this is a good thing, and how it outweighs the benefits of default construction. |
It's about having all Types having a statically known initial state. I seem to remember that it helps for "initializing" statics.
Please keep in mind that it may not be "default" construction, but simply "explicit runtime-initialization with no specified argument", which is also something D doesn't support. And I think there is no good argument to not support that. The "static opCall trick" is the "recommended" way to emulate that. We should be very careful about changing its behavior. Or if not, provide a real way to say: "Please runtime initialize. Arguments: None." |
I think it's frivolous syntax sugar over what it really is: a static constructor method (although a free function works nicely too). edit: That is to say, I think it's just a deceptive case of operator overload abuse. |
Maybe, but there is still little support for it. The issue with "named" constructors is that they aren't constructors: they are just functions that return a new instance. It wouldn't work with, say, structs with disabled postblits (because it may or may not postblit). It would also create problems for "emplace", which only knows about constructors, not "constructor-like functions". EDIT: As a matter of fact, I "recently" changed emplace to explicitly NOT use A "simple" workaround would be to use a |
I'm pretty sure any function that returns a struct by value and has only one return statement (or several that return the same named local variable) are guaranteed to move, which does not call postblit. As you pointed out, the latter problem is shared with
Yeah, a standard way to nullary-construct a struct sounds beneficial. |
That's right. Therefore so, this is legitimate change to me.
Today, by relying on the full CTFE feature, it might be possible.
I think supporting it will introduce more confusion for both C++ experienced programmers (With
But first, we should not recommend to use
I'm continuously working to add NRVO to language specification. It's important feature in semantic level. |
I'll pull this after the comments are fixed, even though I think the code is fundamentally broken in providing for non-trivial default construction. The reason is, of course, for backwards compatibility.
I agree. All those forms (including
The problem with a default ctor is then what does Having a statically known There's always a price to pay, but I strongly disagree that it is a 'desperate' issue. It's at worst a minor issue, easily solved with an initialize or factory function. |
OK, I reverted comment removing. |
All green. |
[REG2.065a] Issue 12098 - libcurl bad argument on handle null
Thanks. |
[REG2.065a] Issue 12098 - libcurl bad argument on handle null
I'm not sure what this means.
And why is this important? If construction fails, it fails.
Known at compile-time? I don't see what this buys us.
Again I don't see what this buys us. You keep listing things that |
Actually, it is a very regular source of bugs and issues for any value type with reference semantics. Objects are passed "non-initialized", then lazilly initialized in the called function, but the caller never sees the change. Learn is riddled with the question, and they are regularly filed in the bug reports. For example: AA's. The damn things still can't be initialized to a state that references an empty payload. You claim "confusion between Also, have you looked at what the code for things such as Every time anybody tries to write a struct with a pointer to a payload, he faces the issue of "How am I going to initialize the damn thing? Am I really going to have to lazily instantiate in every function?" It's an absolute nightmare.
Maybe, but I feel it's our responsibility to promote an easy and reusable solution. Hand waving it away as "trivial" and acting like it doesn't exist won't make the problem go away. While I'm not requesting we have default constructors, the language does a very poor job at supporting types that do need initialization. And I know for a fact it's on a lot of people's "List of things I don't like in D". |
https://d.puremagic.com/issues/show_bug.cgi?id=12098
Don't mix opCall and regular constructor for
Type(...)
syntax!