small idea

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Jan 9 11:36:27 PST 2013


On Wed, Jan 09, 2013 at 01:57:14PM -0500, Nick Sabalausky wrote:
> On Wed, 09 Jan 2013 15:28:31 +0100
> "eles" <eles at eles.com> wrote:
[...]
> > 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.
[...]
> > 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 !?
[...]

Why replace them? Why not just reuse them:

	void func(in int parmA, out int parmB) { ... }

	void main() {
		int x, y;

		func(in x, out y);	// self-documenting
		func(out x, out y);	// compile error
		func(in x, in y);	// compile error
	}


T

-- 
Only boring people get bored. -- JM


More information about the Digitalmars-d mailing list