Flag proposal

so so at so.so
Wed Jun 15 08:28:19 PDT 2011


> I'm just bringing up the fact. Why would you need to check the function  
> signature when reading
>
>      MoveWindow(hWnd, loc.x, loc.y, myWin.width, myWin.height,
>                 bRepaint:true);
>
> ? It's clear what each argument does. If you feel the need of  
> duplicating the same information, fine, write
>
>      MoveWindow(hWnd:hWnd, X:loc.x, Y:loc.y,
>                 nWidth:myWin.width, nHeight:myWin.height, bRepaint:true);
>
> in your code. But don't make it mandatory, it's a waste of time and  
> space when the writer just wants to clarify that 'true' is a bRepaint.

Waste of time? so is writing docs and comments, so is checking the library  
everytime you have trouble understanding a call. It is designed to ease  
understanding your own or others code. I have no idea how you can think  
about writing a few chars more as if something bad. In programming we  
waste our times not when we are actually writing but while doing  
everything else!

>> Looks like i am just repeating myself but i don't understand how is
>> pssing constants meaningless and variables, and why do you even need
>> named arguments for those?
>>
>> enum x=...
>> enum y=...
>> ...
>> fun(x, y)
>>
>
> If you want to disregard named argument, why go the complicated route  
> and define enums? You could do as well
>
>      fun(/*x*/0, /*y*/0);

No, you are the one suggesting that, in your example you called  
MoveWindow(hwnd) and said it was all you need, then i gave this example to  
prove if all you need is that, you don't need NAs anyways since it is just  
so easy to treat other things as "hwnd".

> (and yes I'm currently using it.) But the point is it's ugly. Heck why  
> do we need to defend NA. My point is only "hybrid should be allowed if I  
> want to".

It is ugly but it is not heck, it does nothing, it gives you no  
guaranties, compiler does no matching. It is no better than fun(0, 0). We  
came this far but we still don't think the NAs same way, and i am starting  
to lose my hope explaining myself.

>>> Yet all well-known languages that support named arguments that support
>>> reordering also support hybrid. (C# 4, VB 6, Python, CLisp, ...)
>>
>> This is not an argument.
>
> Neither is 'Just search "named arguments" and first thing you'd see is  
> calls with all arguments named, no exception.'

Why not? first thing you would encounter is its prototype, its best usage  
that makes most sense, i told it because you seem to give its primary  
function no value at all.

> Maybe another argument: D's static struct initializer already supports  
> hybrid and reordering. Extending that to function arguments is natural.
>
> ------------------------------------
> struct S { int x; int y; }
> void main() {
>      S s0 = {4, 5};
>      S s1 = {x:4, 5};
>      S s2 = {4, y:5};
>      S s3 = {x:4, y:5};
> //  S s4 = {y:4, 5};    // error
>      S s5 = {y:5, x:4};
> }
> ------------------------------------

I didn't know they work this way, i agree it is a good argument (finally  
we agree on something!)
Though i have to say it looks quite confusing and verbose (rules).
Then again, it looks like i am alone on this one, quite possibly i am  
wrong :)


More information about the Digitalmars-d mailing list