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

Add TypeInfo functions analogs #928

Closed

Conversation

denis-sh
Copy link
Contributor

@denis-sh denis-sh commented Nov 6, 2012

It is needed for various Phobos functions.

Requires pull #924.

This was referenced Nov 6, 2012
@alexrp
Copy link
Member

alexrp commented Nov 6, 2012

What functions need these, though?

@denis-sh
Copy link
Contributor Author

denis-sh commented Nov 7, 2012

What functions need these, though?

move, destruct, and emplace (when I will finish its incredibly complicated final version).

@denis-sh denis-sh mentioned this pull request Nov 9, 2012
@denis-sh
Copy link
Contributor Author

Tweaked setInitialState (primary for CTFE): do not call mem* functions if there is postblit but no destructor. Added comment about it.

@denis-sh
Copy link
Contributor Author

Rebased and moved to std.conv.

This was referenced Nov 15, 2012

/** Templated setter to object's `init` state.

Use this function instead of dealing with tricky $(D typeid(T).init()).
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't say what the function does, only how it can be useful to advanced programmers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Phobos' programmers must be advanced.

Copy link
Member

Choose a reason for hiding this comment

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

I would add that »dealing with tricky xyz« doesn't strike me as particularly descriptive (if you are just reading the docs, what tricky aspects of .init does it avoid)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All tricky aspects as TypeInfo has lots of them.

* add `std.conv.setToInitialState`
* add `std.conv.callPostblits`
* add `std.conv.callDestructors`
@denis-sh
Copy link
Contributor Author

Fixed terrible name bug: renamed callCopyConstructors to callPostblits as it calls postblits, not copy constructors (big thanks to David).
Also other changes requested by David.

@@ -3642,6 +3642,238 @@ unittest
assert(i is k);
}


/** Sets the passed object to its `init` state.
Copy link
Member

Choose a reason for hiding this comment

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

Since this is non-public, ddoc should not be generated for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. And where is the problem?

Copy link
Member

Choose a reason for hiding this comment

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

Don't use a ddoc comment if it's not supposed to end up in the documentation. Use a regular comment.

@DmitryOlshansky
Copy link
Member

So it's been a year. Some stuff changed. Druntime already contains templates no problem.

@andralex
Should it put these primitives into druntime? What are other objections?

As this goes in connection to other @denis-sh pull I'll let him judge on whether or not to pursue this on its own.


/** Sets the passed object to its `init` state.

Use this function instead of dealing with tricky $(D typeid(T).init()).
Copy link
Member

Choose a reason for hiding this comment

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

tricky? If a user doesn't know why, this comment doesn't help them at all. Oh, it's package anyway, so doc comment quality doesn't matter that much.

@monarchdodra
Copy link
Collaborator

Druntime already contains templates no problem.

That's a misguided comment. druntime can have templates, and has some trivial templates. However, It has no access to traits or typetuple, making anything that does any kind of introspection, virtually impossible.

Currently, there is (afaik) nothing in druntime that has a behavior dependent on introspection: This why we have the whole fiasco with "Is array appending safe or nothrow? Who knows!?".

@DmitryOlshansky
Copy link
Member

Closing as there is no activity for a whole year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants