Thread overview | |||||
---|---|---|---|---|---|
|
July 18, 2013 Hopefully not-too-obvious observation | ||||
---|---|---|---|---|
| ||||
Hi folks, I was looking at writing a hash-like class with a specific operator and disliking the syntax of: T opBinary(string op)(U key) if (op == "in") {} When it occurred to me that it could be simply tightened up as: T opBinary(string op : "in")(U key) {} Any thoughts? Is this bad style? Thanks Jerry |
July 18, 2013 Re: Hopefully not-too-obvious observation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jerry | On 2013-07-18, 04:50, Jerry wrote:
> Hi folks,
>
> I was looking at writing a hash-like class with a specific operator and
> disliking the syntax of:
>
> T opBinary(string op)(U key) if (op == "in") {}
>
> When it occurred to me that it could be simply tightened up as:
>
> T opBinary(string op : "in")(U key) {}
>
> Any thoughts? Is this bad style?
It's how I write my operator overloads unless the function should match
several of them.
So no, I think it's good style. But that's just, like, my opinion, man.
--
Simen
|
July 19, 2013 Re: Hopefully not-too-obvious observation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jerry | Am Wed, 17 Jul 2013 22:50:09 -0400 schrieb Jerry <jlquinn@optonline.net>: > Hi folks, > > I was looking at writing a hash-like class with a specific operator and disliking the syntax of: > > T opBinary(string op)(U key) if (op == "in") {} > > When it occurred to me that it could be simply tightened up as: > > T opBinary(string op : "in")(U key) {} > > Any thoughts? Is this bad style? > > Thanks > Jerry I write it like that, too. It's more readable with the "in" closer to the method name. -- Marco |
Copyright © 1999-2021 by the D Language Foundation