DIP 1019--Named Arguments Lite--Final Review

Dukc ajieskola at gmail.com
Tue Aug 27 19:27:01 UTC 2019


On Tuesday, 27 August 2019 at 17:39:44 UTC, H. S. Teoh wrote:
> That's exactly Jonathan's point.  The reader *assumes* 
> semantics based on the names of the function and parameters.  
> But without actually reading the documentation, you cannot know 
> for sure.  And I think by now we all know what happens when we 
> make assumptions about a function that we don't actually 
> understand.  So the point is that if you want to understand 
> what the code actually does, you have to read the docs. Having 
> named arguments doesn't relieve you of that need.
>
> I can't say I 100% agree with Jonathan, but he certainly has a 
> point that you can't avoid reading documentation at *some* 
> point.
>
>
> T

Named parameters are intended for when you remember partially, 
but not fully, the function you are calling. Yuxan provided a 
good example of such situation.

Personally, I'd be unlikely to forget ordering of width and 
height, but if I was hunting a rendering bug and encountered 
`drawRect(100, 100, a[0], a[1], true)`, it's fairly likely I 
wouldn't remember whether the latter two parameters are absolute 
or relative to first two, and/or what that `true` stands for. I'd 
have to open the documentation, which tends to have the same 
effect on me as long compile times on some. Alternatively, I 
could open the file where `drawRect()` is defined and have Geany 
to hint me the parameter names, but that file could be deep in 
some DUB package, even slower to fire up than the docs. Assuming 
I wrote the call myself, parameter names would give my memory 
enough hint that I wouldn't have to bother with the doc.


More information about the Digitalmars-d mailing list