[Design] return char[] or string?

Stewart Gordon smjg_1998 at yahoo.com
Tue Aug 21 15:22:52 PDT 2007


Regan Heath Wrote:

<snip>
> As for your cases mentioned above...
> 
> I would probably implement (c), a property setter, as code that sets the 
> member followed by a call to the getter so it would return the same as 
> (b).  That said I haven't written a lot of these so perhaps my 
> experience using them isn't sufficient.

I've never really liked this idea.  In general, either it would just return the same string that was passed in, IWC there's no point calling the getter rather than simply returning the argument, or there would be a performance hit where the return value isn't used.

Much better would be if D would chain property assignments implicitly:

http://www.digitalmars.com/d/archives/digitalmars/D/10199.html

If only Walter would finally answer this request (among many others)!

Stewart.


More information about the Digitalmars-d-learn mailing list