Does D have too many features?

Era Scarecrow rtcvb32 at yahoo.com
Sat Apr 28 18:39:51 PDT 2012


On Sunday, 29 April 2012 at 01:06:54 UTC, bearophile wrote:
>> * I hate C style struct initializers and would really like to 
>> see them go, but
>> for reasons that I don't understand, people actually use them 
>> rather than using a proper constructor call,
>
> For single structs I prefer D-style initialization.
> But take a look at this code, if you replace those C-style 
> initializers with D-style, even using aliases to shorten the 
> code to single letters, that data section becomes more noisy:
> http://rosettacode.org/wiki/Ray-casting_algorithm#D

  I have one source file called staticdata.d; Here immutable 
global data is stored. It's literally pages and pages of data and 
i only using static this() when building an AA.

//excerpt: /NP and VT aliases.
immutable SubRecordParts subParts[] = [
	{"AADT", "", 16, [		//alchemy (apparatus)
		NP(VT.ranged_32, "Apparatus"),
		NP(VT.float_32, "Quality"),
		NP(VT.float_32, "Weight"),
		NP(VT.i_32, "uses")]},		
	{"AODT", "", 24, [		//armor
		NP(VT.ranged_32, "Armor Body Type"),
		NP(VT.float_32, "Weight"),
		NP(VT.i_32, "Value"),
		NP(VT.i_32, "Health"),
		NP(VT.i_32, "Enchant Points"),
		NP(VT.i_32, "Armour")]},	
	{"BKDT", "", 20, [		//book
		NP(VT.float_32, "Weight"),
		NP(VT.i_32, "Value"),
		NP(VT.i_32, "isScroll"),
		NP(VT.ranged_32, "Skill ID"),
		NP(VT.i_32, "Enchantment points")]}];

  Would you really force me to use fully named and qualified for 
every element? More verbose but helps not at all.

immutable SubRecordParts subParts[] = [
	SubRecordParts("AADT", "", 16, [		//alchemy (apparatus)
		NotePart(ValueType.ranged_32, "Apparatus"),
		NotePart(ValueType.float_32, "Quality"),
		NotePart(ValueType.float_32, "Weight"),
		NotePart(ValueType.i_32, "uses")]),		
	SubRecordParts("AODT", "", 24, [		//armor
		NotePart(ValueType.ranged_32, "Armor Body Type"),
		NotePart(ValueType.float_32, "Weight"),
		NotePart(ValueType.i_32, "Value"),
		NotePart(ValueType.i_32, "Health"),
		NotePart(ValueType.i_32, "Enchant Points"),
		NotePart(ValueType.i_32, "Armour")]),	
	SubRecordParts("BKDT", "", 20, [		//book
		NotePart(ValueType.float_32, "Weight"),
		NotePart(ValueType.i_32, "Value"),
		NotePart(ValueType.i_32, "isScroll"),
		NotePart(ValueType.ranged_32, "Skill ID"),
		NotePart(ValueType.i_32, "Enchantment points")])
	];


More information about the Digitalmars-d mailing list