Other language features you'd want in D

Robert Fraser fraserofthenight at gmail.com
Sat Feb 23 03:13:45 PST 2008


Denton Cockburn wrote:
> On Fri, 22 Feb 2008 15:25:24 -0800, Robert Fraser wrote:
> 
>> Denton Cockburn wrote:
>>> What are some features found in other languages that you believe would be
>>> really good to have in D?
>>>
>>> These can be language features or library features.
>>>
>>> It shouldn't be any of the general items found in the comparison FAQ (like
>>> Multiple inheritance).  Something that's relatively nice and specific.
>>>
>>> e.g.
>>> I miss multiple value returns found in Lisp.  Out parameters are not
>>> nearly as nice.
>>>
>>> P.S. Has anyone thought to write a document on some of the struct tricks
>>> that I've been seeing mentioned?  They exploit struct features, but I
>>> think only a select few understand them.
>> Initializing runtime constants without a static this() a la Java,
>>
>> class C
>> {
>>      static int x = someRuntimeInitializer(10);
>>      int y = someRuntimeInitializer(20);
>> }
> 
> I don't mind the static this() thing much.  It puts all the initialization
> in one place.
> 
> I hated having to read this in java:
> 
> class Foo {
> 	/* variables with inits */
> 	/* some functions */
> 	/* some variables with inits that were added to the class later */
> }
> 
> I will admit that it's quite a bit more typing though, especially with
> many defaulted variables.

Constant initialization can already be paired with declaration for 
non-class types:

const(int) HTTP_PORT = 80;

But it can't be for class types at global scope:

const(Port) HTTP_PORT = new Port(80);


How is making it valid for (primitives, arrays, structs, anything with a 
constant initializer) but not for classes "keeping initialization in one 
place"?



More information about the Digitalmars-d mailing list