general questions about static this() at module level
ggdc via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Oct 31 04:58:02 PDT 2016
On Monday, 31 October 2016 at 04:35:35 UTC, WhatMeWorry wrote:
> I am fascinated with D's module static this.
>
> I have shamelessly stolen Ali's code directly from his book.
>
> module cat;
>
> static this() {
> // ... the initial operations of the module ...
> }
> static ~this() {
> // ... the final operations of the module ...
> }
>
>
> First, are there any other languages that has this feature?
> The few I know, certainly don't.
>
Object Pascal has them:
========================
unit foo; // like a D module.
interface
// declarations...,
// like the content of a C/C++ *.h/*.hpp
implementation
// implementation like the content of a C/C++ *.c/*.cpp
initialization
// statements...
// like in a D static this(){}
finalization
// statements...
// like in a D static ~this(){}
end.
========================
Actually without them a lot of stuffs wouldn't work properly.
They are more used than their D equivalent, particularly to
register classes for the object streaming system but not only.
More information about the Digitalmars-d-learn
mailing list