"so" <s...@so.so> wrote in message news:op.vw2s1b19mpw3zg@tan-pc... > On Tue, 14 Jun 2011 16:01:20 +0300, KennyTM~ <kenn...@gmail.com> wrote: > >> On Jun 14, 11 19:11, so wrote: >> [snip] >>> Also i don't understand why some think allowing hybrid calls has any >>> merit. Just search "named arguments" and first thing you'd see is calls >>> with all arguments named, no exception. Allowing unnamed arguments and >>> named arguments in one call doesn't make any sense to me, it is almost >>> opposite to the reasons named arguments designed for, you don't even >>> need to talk about its drawbacks like the complications and confusions. >> >> And if you think it's complicated, you're just thinking in a too >> complicated way. The rule is simple. >> >> Say there is a function >> >> pure nothrow >> S parseString(S=const(char)[], C) >> (ref C[] input, >> out ConversionResult result, >> char quote='"', >> bool recognizePrefix=true) if (...); >> >> and you call it as >> >> string s = `"hello"`; >> ConversionResult detailResult; >> auto parsed = parseString(s, recognizePrefix:false, >> result:detailResult); >> >> The first step is identify all positional arguments ('s' here), and fill >> them in in-order. >> >> input <- s >> result <- ... >> quote <- ... >> recognizePrefix <- ... >> >> next, we match the named args >> >> input <- s >> result <- detailResult >> quote <- ... >> recognizePrefix <- false >> >> finally we fill in the optional parameters >> >> input <- s >> result <- detailResult >> quote <- '"' >> recognizePrefix <- false >> >> what's so complicated? Actually, reordering creates more complication >> than hybrid (e.g. ambiguity in selecting an overload). > > So complicated because it took you this long to match the parameters with > the variables, you still need to check function definition because you > have parameters that have no match. These are the very things named > arguments needs to solve or am i missing something? >
Simple rule for combining hybrid and reordering: Look at the caller's args one at a time: as soon as one is reordered, the rest of the args must be named (otherwise you wouldn't know which param it's supposed to be).