What are the prominent downsides of the D programming language?

mw mingwu at gmail.com
Wed Sep 30 01:17:58 UTC 2020


On Tuesday, 29 September 2020 at 23:21:19 UTC, Jean-Louis Leroy 
wrote:

> Looking at your example, I have the impression that the `addr` 
> "feature" is actually a function. If so, `undefine` in this 
> example is simply the equivalent of tacking a `= 0` after an 
> overridden virtual function in C++ (yes you can inherit an 
> implemented virtual function and make it pure again). But, does 
> this also work on attributes?

One cannot undefine attributes, but can rename it, so the 
programmer can specify individually whether each attribute should 
be either shared or separated.

I created a 2nd example on how to handle attributes here:

https://github.com/mingwugmail/dlang_tour/blob/master/eiffel/visitor2/visitor.e

class VISITOR
inherit
	UK_RESIDENT
		rename addr as uk_addr
		       make as uk_make
	end
	US_RESIDENT
		rename addr as us_addr
		       make as us_make
	end
	PERSON
		redefine make select make
	end


The generated C-struct is here:

https://github.com/mingwugmail/dlang_tour/blob/master/eiffel/visitor2/app.h#L513

struct S30{Tid id;T0* _name;T0* _addr;T0* _us_addr;T0* _uk_addr;};


As you can see after 3-branch-dimond multiple inheritance, the 
`name` is shared (there is only 1 copy); while there are 3 
address attributes in VISITOR.




More information about the Digitalmars-d mailing list