Set global immutables from main/getopt?

Andrew Klaassen clawsoon at yahoo.com
Tue Jan 28 12:07:24 PST 2014


On Tuesday, 28 January 2014 at 19:02:41 UTC, Stanislav Blinov 
wrote:
> On Tuesday, 28 January 2014 at 18:56:35 UTC, Ali Çehreli wrote:
>
>> On a side note, dpaste is not associated with newsgroups. It 
>> can disappear at any time in the future. I like seeing and 
>> showing code in message bodies both for convenience and future 
>> availability. :)
>
> Awww, but it is so much more convenient. No spurious 
> linebreaks, nice syntax highlighting, built-in compiler... :P
>
> But I agree, sometimes it's a real pain when you've searching 
> for something and all you find is dead links.

Cutting and pasting for posterity... :-)


import std.stdio;
import core.runtime;

immutable string abc;

void main() {
	writeln(abc);
}

shared static this() {
	alias args = Runtime.args;
	if (args.length > 1)
		abc = args[1];
}


Fascinating.  Any chance someone would be able to add this to 
http://dlang.org/module.html as an example for people like me 
who'd have no clue otherwise?

Andrew




More information about the Digitalmars-d-learn mailing list