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. :-) T -- There is no gravity. The earth sucks.