Re: Names with trailing question mark

2011-10-05 Thread Gor Gyolchanyan
Read my thread about "thoughts on improving the operators". Your idea might see the light after all :-) On Wed, Oct 5, 2011 at 2:42 PM, bearophile wrote: >> I vaguely like the idea of using a trailing question mark in predicate names. > > Thank you to all the people that have answered. > > I don'

Re: Names with trailing question mark

2011-10-05 Thread bearophile
> I vaguely like the idea of using a trailing question mark in predicate names. Thank you to all the people that have answered. I don't like to write isFoo, I'd like to write foo?, but after the discussions I presume this idea will not see the light in D :-| Bye, bearophile

Re: Names with trailing question mark

2011-10-04 Thread Jesse Phillips
bearophile Wrote: > contains? > areInside ==> inside? > > > I don't remember serious recent discussions here about that last form. > Allowing a single trailing question mark in D names has some advantages: > > 1) It gives a standard way to denote a predicate, so it becomes very easy to > tell

Re: Names with trailing question mark

2011-10-04 Thread Christophe
Jacob Carlborg , dans le message (digitalmars.D:146055), a écrit : > > I would say it would be illegal and that the ternary operator requires a > space before the question mark. It works like this in Ruby as well. It > would be parsed like this: > > (foo?) + (foo?(a)) : b > > Have a look at: h

Re: Names with trailing question mark

2011-10-04 Thread Jacob Carlborg
On 2011-10-04 15:03, Timon Gehr wrote: On 04.10.2011 01:37, bearophile wrote: Predicates are quite common. In D I presume the standard way to write them is with a name like "isFoo". In other languages they are written in other ways: if (foo.isEven) {} if (foo.isEven()) {} filter!isEven(data)

Re: Names with trailing question mark

2011-10-04 Thread Jacob Carlborg
On 2011-10-04 16:03, Jacob Carlborg wrote: On 2011-10-04 12:12, Christophe wrote: I don't really like this idea. D has limitations to accepted symbol that are strict, but handy in many cases. Accepting strange character in a method name can lead to parsing ambiguities and I like the way D enfor

Re: Names with trailing question mark

2011-10-04 Thread Jacob Carlborg
On 2011-10-04 12:12, Christophe wrote: I don't really like this idea. D has limitations to accepted symbol that are strict, but handy in many cases. Accepting strange character in a method name can lead to parsing ambiguities and I like the way D enforce non-ambiguous code. I understand why we c

Re: Names with trailing question mark

2011-10-04 Thread Jacob Carlborg
On 2011-10-04 12:22, Gor Gyolchanyan wrote: Here's what i suggest to do: struct MyTestStruct { int[] array; // opCond must take at least a single string template parameter and exactly two lazy parameters, second of which may have a default value. T opCond(string name : "empty", T

Re: Names with trailing question mark

2011-10-04 Thread Timon Gehr
On 04.10.2011 01:37, bearophile wrote: Predicates are quite common. In D I presume the standard way to write them is with a name like "isFoo". In other languages they are written in other ways: if (foo.isEven) {} if (foo.isEven()) {} filter!isEven(data) if (foo.evenQ) {} if (foo.evenQ()) {} f

Re: Names with trailing question mark

2011-10-04 Thread Gor Gyolchanyan
Here's what i suggest to do: struct MyTestStruct { int[] array; // opCond must take at least a single string template parameter and exactly two lazy parameters, second of which may have a default value. T opCond(string name : "empty", T)(lazy T yes, lazy T no = T.init) { i

Re: Names with trailing question mark

2011-10-04 Thread Gor Gyolchanyan
> auto mts.empty ? "wonderful" : "awful"; > auto mts.empty ? "awesome"; sorry, a typo: auto a0 = mts.empty ? "wonderful" : "awful"; auto a1 = mts.empty ? "awesome"; struct MyTestStruct { int[] array; // "this" as a template parameter will make the condition apply to the class

Re: Names with trailing question mark

2011-10-04 Thread Christophe
I don't really like this idea. D has limitations to accepted symbol that are strict, but handy in many cases. Accepting strange character in a method name can lead to parsing ambiguities and I like the way D enforce non-ambiguous code. I understand why we can think that the question mark is ni

Re: Names with trailing question mark

2011-10-04 Thread Jacob Carlborg
On 2011-10-04 10:28, bearophile wrote: Jacob Carlborg: if (foo.even()?) Why would you put the question mark after the parentheses. At least in Ruby the question mark is part of the method name. This looks better: if (foo.even?()) It's a typo of mine, sorry :-) The question mark is part of

Re: Names with trailing question mark

2011-10-04 Thread bearophile
Jacob Carlborg: > > if (foo.even()?) > > Why would you put the question mark after the parentheses. At least in > Ruby the question mark is part of the method name. This looks better: > > if (foo.even?()) It's a typo of mine, sorry :-) The question mark is part of the name, so it is of course

Re: Names with trailing question mark

2011-10-03 Thread Jacob Carlborg
On 2011-10-04 03:13, Nick Sabalausky wrote: "bearophile" wrote in message news:j6dgvp$1rot$1...@digitalmars.com... Predicates are quite common. In D I presume the standard way to write them is with a name like "isFoo". In other languages they are written in other ways: if (foo.isEven) {} if (

Re: Names with trailing question mark

2011-10-03 Thread Jacob Carlborg
On 2011-10-04 01:37, bearophile wrote: Predicates are quite common. In D I presume the standard way to write them is with a name like "isFoo". In other languages they are written in other ways: if (foo.isEven) {} if (foo.isEven()) {} filter!isEven(data) if (foo.evenQ) {} if (foo.evenQ()) {} f

Re: Names with trailing question mark

2011-10-03 Thread Nick Sabalausky
"bearophile" wrote in message news:j6dgvp$1rot$1...@digitalmars.com... > Predicates are quite common. In D I presume the standard way to write them > is with a name like "isFoo". In other languages they are written in other > ways: > > > if (foo.isEven) {} > if (foo.isEven()) {} > filter!isEven

Names with trailing question mark

2011-10-03 Thread bearophile
Predicates are quite common. In D I presume the standard way to write them is with a name like "isFoo". In other languages they are written in other ways: if (foo.isEven) {} if (foo.isEven()) {} filter!isEven(data) if (foo.evenQ) {} if (foo.evenQ()) {} filter!evenQ(data) if (foo.even?) {} if (