lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Paige DePol once stated:
> 
> I wonder then really... why even have positional vs named arguments? I really
> like how they've laid out how it works, but practical examples of the system
> at work makes me think that just named arguments would be nicer overall.

  That's were I was going with my examples.  Perhaps a more concrete example
will help.  In C, you have structures:

	struct foo
	{
	  int x;
	  int y;
	  int z;
	  int a;
	  int b;
	  int c;
	};

  And you can initialize them.  Default, it follows a position notation,
much like function calls:

	struct foo f1 = { 1 , 2 , 3 , 4 , 5 , 6 };

But in C99, you can designate the fields being initialized, so this now
becomes something like named positions:

	struct foo f2 = { .a = 4 , .b = 5 , .c = 6 , .z = 3 , .y = 2 , .x = 1 };

Furthermore, you can mix the two:

	struct foo f3 = { 1 , 2 , 3 , .c = 6 , .b = 5 , .a = 4 };

I don't see why this can't work for function calls as well.

  -spc