-
-
Notifications
You must be signed in to change notification settings - Fork 609
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 trait for function callgraph extraction, to allow "builtin attribute"-style UDA semantic checks #18665
Labels
Comments
andrej.mitrovich (@AndrejMitrovic) commented on 2013-09-06T08:14:30ZAnyway this will likely need a lot more thought and discussion before an implementation is even considered. E.g. the first problem I can think of, is what happens when a function in the graph is private? Can we still call __traits on it? It probably warrants a NG discussion. |
andrej.mitrovich (@AndrejMitrovic) commented on 2013-09-06T08:15:07ZAlso, credit to the idea goes to Adam D. Ruppe. |
bearophile_hugs commented on 2013-09-11T13:43:24ZExtending the type system like this possibly my main use case for UDAs. A successive step is to make the tests more automatic, calling templates/functions like CheckNoMalloc for all the functions tagged @NoMalloc in the compilation unit. |
bus_dbugzilla commented on 2013-10-08T14:07:06Z(In reply to comment #1)
> Anyway this will likely need a lot more thought and discussion before an
> implementation is even considered. E.g. the first problem I can think of, is
> what happens when a function in the graph is private? Can we still call
> __traits on it? It probably warrants a NG discussion.
Reflection normally bypasses visibility restrictions such as private. Maybe I just haven't paid enough attention, but I've never seen a case in any language where privates were hidden from reflection. |
destructionator commented on 2013-10-08T16:10:32ZI just wrote this on the newsgroup and want it to be here too:
Though, my proposed __traits could perhaps be improved to just
offer two things:
__traits(getFunctionsCalled, function)
returns a tuple of all functions called. These would ideally be
in the form of symbols.
__traits(functionBodyAvailable, function)
true if the source was available to the compiler.
And that's it: the rest is done in the library using existing
language features. Then we can decide in library code if a
missing attribute is a problem based on if the body was available
or not.
Note that this isn't specific to the gc: it would provide the
necessary foundation for all kinds of library extensions in the
same vein as @safe, with the possibility of automatic inference
from the prototype + presence of body.
* * *
To get the entire call graph, your helper library function would do getFunctionsCalled recursively. It would be a pain to actually build a big return tuple since you can't ~= a symbol.... but you could easily enough pass a visitor template to the helper function which is instantiated with each thingy.
But anyway, recursive templates are a solved problem, so however we decide to do it, we can keep the compiler simple. |
maxhaton commented on 2021-01-24T07:22:00Zkeep an eye out for typefunctions (to anyone reading this for some reason) |
destructionator commented on 2021-01-24T14:16:14ZType functions aren't a substitute for this at all. Even if you had them, they'd still need a way to introspect the function's calls which is what this enhancement is requesting. |
boris2.9 commented on 2021-01-25T16:01:47ZReopening. There is no reason to close it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Andrej Mitrovic (@AndrejMitrovic) reported this on 2013-09-06T08:07:47Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=10979
CC List
Description
The text was updated successfully, but these errors were encountered: