DIP10005: Dependency-Carrying Declarations is now available for community feedback

Dominikus Dittes Scherkl via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 14 23:23:39 PST 2016


[about leaving the syntax as it is, only extend the import to 
include the previous (declaration) line]

On Wednesday, 14 December 2016 at 21:21:39 UTC, Jonathan M Davis 
wrote:
> It also doesn't work with function prototypes. With the 
> proposed syntax, you can do
>
>     int foo(SysTime st) import(std.datetime);
>
> but if the compiler has to look into the function body to get 
> at the import, then a prototype like this would be out of luck.

You are right. I think this is the only shortcoming.
But how does that work with imports within the function anyway?
In this case you can't even today determine the dependencies of a 
function from it's prototype.

Also I hate prototypes: .di-files are pretty useless - they make 
not clear what is needed to include and for templates you need 
the whole code anyway. I think we don't loose much if now we have 
even symbols within a .di-file which are not declared there.
The only good thing about prototypes is: they can be 
auto-generated. We only need to modify this generation by adding 
all function-local includes to the top of the .di-file.
This would also improve the usefulness of such files by having a 
whole list of dependencies of a library - but this has nothing to 
do with this change! This is necessary independently, because 
local imports are very common today.




More information about the Digitalmars-d mailing list