small idea

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Wed Jan 9 10:57:14 PST 2013


On Wed, 09 Jan 2013 15:28:31 +0100
"eles" <eles at eles.com> wrote:

> Disclaimer: I do not ask for anything, it is just an idea, do not 
> blame me (too much).
> 
> One thing that I really like about a function is to know quite 
> clearly which of its parameters are for input, which for output 
> and, yes, which one are for carrying (input/output parameters).
> 
> In D, this is signalled by the in/out/inout keywords. However, 
> these are only visible at the moment of function declaration, not 
> calling.
> 
> In C, you usually can distinguish since parameters intended to be 
> modified are passed through address (pointers), and you see that 
> at use time:
> 
> void make_a_equal_to_b(&a,b);
> 
> In D, it would be:
> 
> void make_a_equal_to_b(a,b);
> 
> Yes, the name of the function can convey the intention. But, in 
> C, the calling, too. It is a kind of a double check.
> 
> Now, what about accepting a quick and optional (to not break 
> existing code) annotation at the time of the call:
> 
> void make_a_equal_to_b(??a,!!b); //I give you "b", give me "a"
> 
> so that in, out and inout could be replaced by !!, ?? and !?
> 
> Alternatives could be: >>, <<, >< but that's more complex.
> 
> Non-concordance between !!/!?/?? use and in/out/inout declaration 
> could be sanctioned with a warning or an error, or explicitely 
> ignored through a compiler flag.

Yea, that's one thing I do like about C#.



More information about the Digitalmars-d mailing list