-
Notifications
You must be signed in to change notification settings - Fork 284
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
Deprecate the usage of shared static this
for initialization
#2370
Comments
@s-ludwig : This is itching me. I'm thinking of starting the (quite long process) of transitioning it, by first slightly changing Before I get started on this rather large task, any chance I can get an ACK on the idea ? |
@Geod24 I'm with you on this, I don't like the One suggestion -- before approaching this:
... let's make sure that we do have well documented, front and centre, what one would consider the "right" way(s) to set up an application. That should probably be a precursor to all other changes. I'd be happy to touch base some time on this topic to try to see if I can helpfully contribute. |
I agree that we should go this route.
What do you have in mind? Can this be an additive change?
I'd prefer to explicitly mark it as deprecated in the documentation, ideally mentioning the date of removal. |
I would have to re-visit the topic, since this issue has been opened a while ago. TBF after what you mentioned in the vibe-core issue, it might actually be much simpler than I expected.
Okay, let me rephrase this: First step is to change all the examples to call |
I think experience has shown that
shared static this
for initialization causes many problems.The root of the cause is IMO that (shared) module constructors in D are second-class citizens, and are best used only for module-specific initialization. And while circular imports are well supported in D, it is only thanks to the fact that the compiler is involved and can figure out dependencies on the symbol level.
E.g. something as trivial as:
Will result in:
Additionally, some symbols might not be ready, for example see Phobos issue 17564, order might be unpredictable among build tools / configurations and various level of scoping, for example #371 , and the original convenience is lost to the fact that one needs to define
VibeDefaultMain
in thedub
file nowadays.Thus, I propose to gradually deprecate the use of them.
The first step in doing so would be to remove any piece of documentation mentioning it.
Besides that, there doesn't seem to be too much specific code geared toward supporting it. One thing one could do is issue a message if certain (common) routines are called before
main
(e.g.listen{TCP,HTTP}
,runTask
, timers...).@s-ludwig Does it fit into your vision for Vibe.d ?
The text was updated successfully, but these errors were encountered: