How do you declare manifest constants?

H. S. Teoh hsteoh at
Thu Nov 4 20:48:06 UTC 2021

On Thu, Nov 04, 2021 at 01:17:02PM -0700, Ali Çehreli via Digitalmars-d-learn wrote:
> On 11/4/21 10:36 AM, H. S. Teoh wrote:
> > 	import __stdin : myversion;
> Where can we learn more of that magic? :)

I kinda cheated, because I was the one who implemented dmd's stdin
feature, so I knew that dmd implicitly creates a specially-named module
to contain the code read from stdin.  I had actually forgotten what the
name of this module was, but that was no problem since it was easily
found by:

	echo 'pragma(msg, __MODULE__);' | dmd -c -

which revealed the module name to be `__stdin`.

Next, thanks to D's module system, is the realization that you could
import this implicit module from somewhere else and pull symbols from
it.  From there, the everything else followed. :-)


There is no gravity. The earth sucks.

More information about the Digitalmars-d-learn mailing list