Re: [julia-users] support for '?' suffix on functions that return boolean types.

2014-06-17 Thread Mauro
On Tue, 2014-06-17 at 09:29, j.l.vanderz...@gmail.com wrote:
> On Monday, 16 June 2014 03:33:32 UTC+2, Jacob Quinn wrote:
>>
>> it has nice discoverability properties (tab-completion)
>>
> Oh that's an interesting one. Never consciously thought of the interaction 
> between naming conventions and autocomplete functionality before.
>  
>
>> isn't generally too awkward (though double s's are sometimes weird 
>> `issubset` `issubtype`, and it took me a while to figure out isa() => is 
>> a). 
>>
>
> I take it you don't like camel case? (which makes me wonder: is there a 
> consensus for the idiomatic way to label multi-word identifiers in Julia?) 

http://docs.julialang.org/en/latest/manual/variables/?highlight=camelcase#stylistic-conventions

says:
- Names of variables are in lower case.
- Word separation can be indicated by underscores ('\_'), but use of
  underscores is discouraged unless the name would be hard to read
  otherwise.
- Names of Types begin with a capital letter and word separation is
  shown with CamelCase instead of underscores.
- Names of functions and macros are in lower case, without underscores.
- Functions that modify their inputs have names that end in !. These
  functions are sometimes called mutating functions or in-place
  functions.

I think the general style is: try to use single-word.  If using
multi-word, use one which can be read without _, if that is not possible
us _.


Re: [julia-users] support for '?' suffix on functions that return boolean types.

2014-06-17 Thread Job van der Zwan
On Monday, 16 June 2014 03:33:32 UTC+2, Jacob Quinn wrote:
>
> it has nice discoverability properties (tab-completion)
>
Oh that's an interesting one. Never consciously thought of the interaction 
between naming conventions and autocomplete functionality before.
 

> isn't generally too awkward (though double s's are sometimes weird 
> `issubset` `issubtype`, and it took me a while to figure out isa() => is 
> a). 
>

I take it you don't like camel case? (which makes me wonder: is there a 
consensus for the idiomatic way to label multi-word identifiers in Julia?) 


Re: [julia-users] support for '?' suffix on functions that return boolean types.

2014-06-16 Thread TR NS


On Monday, June 16, 2014 12:39:39 PM UTC-4, Stefan Karpinski wrote:
>
> We already have ifelse as the ternary function. If the function form has 
> different evaluation rules than the operator form, then it ought to have a 
> different name.
>

Ok. I suppose it couldn't evaluate like the ternary operator. Well, just 
ignore the last statement about the ?() function. I was really just being a 
bit silly there, and it isn't relevant to the main of the conversation.


 


Re: [julia-users] support for '?' suffix on functions that return boolean types.

2014-06-16 Thread Stefan Karpinski
We already have ifelse as the ternary function. If the function form has
different evaluation rules than the operator form, then it ought to have a
different name.


On Mon, Jun 16, 2014 at 12:34 PM, TR NS  wrote:

>
>
> On Sunday, June 15, 2014 9:33:32 PM UTC-4, Jacob Quinn wrote:
>>
>> Yeah, I feel kind of torn on this on.
>>
>> On the one hand, I've kind of grown used to the `is...` method naming
>> convention and it has nice discoverability properties (tab-completion) and
>> isn't generally too awkward (though double s's are sometimes weird
>> `issubset` `issubtype`, and it took me a while to figure out isa() => is a).
>>
>> The syntax-hungry beast in me though loves the handiness of adding a `?`
>> to boolean methods. At this point, it's probably not worth the change, and
>> my main concern would be combining it with the ternary operator:
>>
>> result = good?(x) ? good : bad
>>
>> The double `?` would probably get real old real fast.
>>
>
> As a long time Rubyist, I concur that the double `?` from ternary operator
> has always been a little annoying. On the other hand the readability of
> `?`-suffixed predicate methods has easily outweighed the downside of this
> one usage. And in Julia at least you have a `()` in between. In Ruby you
> don't even have that. Valid Ruby:
>
> result = good? ? good : bad
>
> The Julia equivalent of
>
> result = good?() ? good : bad
>
> isn't so bad.
>
> And if I might add a small aside, ternary as an honest to god function:
>
> result = ?(good?(), good, bad)
>
>
>


Re: [julia-users] support for '?' suffix on functions that return boolean types.

2014-06-16 Thread TR NS


On Sunday, June 15, 2014 9:33:32 PM UTC-4, Jacob Quinn wrote:
>
> Yeah, I feel kind of torn on this on.
>
> On the one hand, I've kind of grown used to the `is...` method naming 
> convention and it has nice discoverability properties (tab-completion) and 
> isn't generally too awkward (though double s's are sometimes weird 
> `issubset` `issubtype`, and it took me a while to figure out isa() => is a).
>
> The syntax-hungry beast in me though loves the handiness of adding a `?` 
> to boolean methods. At this point, it's probably not worth the change, and 
> my main concern would be combining it with the ternary operator:
>
> result = good?(x) ? good : bad
>
> The double `?` would probably get real old real fast.
>

As a long time Rubyist, I concur that the double `?` from ternary operator 
has always been a little annoying. On the other hand the readability of 
`?`-suffixed predicate methods has easily outweighed the downside of this 
one usage. And in Julia at least you have a `()` in between. In Ruby you 
don't even have that. Valid Ruby:

result = good? ? good : bad

The Julia equivalent of

result = good?() ? good : bad

isn't so bad.

And if I might add a small aside, ternary as an honest to god function:

result = ?(good?(), good, bad)




Re: [julia-users] support for '?' suffix on functions that return boolean types.

2014-06-15 Thread Jacob Quinn
Yeah, I feel kind of torn on this on.

On the one hand, I've kind of grown used to the `is...` method naming
convention and it has nice discoverability properties (tab-completion) and
isn't generally too awkward (though double s's are sometimes weird
`issubset` `issubtype`, and it took me a while to figure out isa() => is a).

The syntax-hungry beast in me though loves the handiness of adding a `?` to
boolean methods. At this point, it's probably not worth the change, and my
main concern would be combining it with the ternary operator:

result = good?(x) ? good : bad

The double `?` would probably get real old real fast.

-Jacob


On Thu, Jun 12, 2014 at 3:04 PM, Mike Innes  wrote:

> Indeed, Ruby has the ternary operator as well.
>
> I imagine it's unlikely to change at this point, but +1 for trailing ?
> from me – just in case :)
>
>
> On Thursday, 12 June 2014 19:30:58 UTC+1, Stefan Karpinski wrote:
>
>> It's definitely a surmountable thing – I'd actually be rather in favor of
>> using a trailing ? instead of the is prefix for predicates. I believe Jeff
>> prefers the is prefix.
>>
>>
>> On Thu, Jun 12, 2014 at 1:53 PM, Jameson Nash  wrote:
>>
>>>  Interestingly (to me) Apples new language, Swift, uses ? as both a
>>> ternary operator and a suffix for 'nullable' values, so this isn't an
>>> insurmountable obstacle.
>>>
>>>
>>> On Thursday, June 12, 2014, Steven G. Johnson 
>>> wrote:
>>>


 On Thursday, June 12, 2014 1:08:37 PM UTC-4, Aerlinger wrote:
>
> Ruby has a useful convention where methods can end in a '?' to
> indicate that it returns a boolean value. This capability would be useful
> in Julia as well. Much like the bang (!) suffix on functions it might look
> something like this:
>
> function isEven?(n::Int)
>   n % 2 == 2
> end
>

 Yes, both the ! and ? suffixes are common conventions, possibly
 originating in Scheme.  Note that if you have a ? suffix, then you don't
 need the "is" prefix.

 However, ? is already being used for the ternary operator in Julia and
 hence is not available for use in identifiers.  Hence we instead adopt the
 "is" prefix convention.

>>>
>>


Re: [julia-users] support for '?' suffix on functions that return boolean types.

2014-06-12 Thread Mike Innes
Indeed, Ruby has the ternary operator as well.

I imagine it's unlikely to change at this point, but +1 for trailing ? from 
me – just in case :)

On Thursday, 12 June 2014 19:30:58 UTC+1, Stefan Karpinski wrote:
>
> It's definitely a surmountable thing – I'd actually be rather in favor of 
> using a trailing ? instead of the is prefix for predicates. I believe Jeff 
> prefers the is prefix.
>
>
> On Thu, Jun 12, 2014 at 1:53 PM, Jameson Nash  > wrote:
>
>> Interestingly (to me) Apples new language, Swift, uses ? as both a 
>> ternary operator and a suffix for 'nullable' values, so this isn't an 
>> insurmountable obstacle. 
>>
>>
>> On Thursday, June 12, 2014, Steven G. Johnson > > wrote:
>>
>>>
>>>
>>> On Thursday, June 12, 2014 1:08:37 PM UTC-4, Aerlinger wrote:

 Ruby has a useful convention where methods can end in a '?' to indicate 
 that it returns a boolean value. This capability would be useful in Julia 
 as well. Much like the bang (!) suffix on functions it might look 
 something 
 like this:

 function isEven?(n::Int)
   n % 2 == 2
 end

>>>
>>> Yes, both the ! and ? suffixes are common conventions, possibly 
>>> originating in Scheme.  Note that if you have a ? suffix, then you don't 
>>> need the "is" prefix.
>>>
>>> However, ? is already being used for the ternary operator in Julia and 
>>> hence is not available for use in identifiers.  Hence we instead adopt the 
>>> "is" prefix convention.
>>>
>>
>

Re: [julia-users] support for '?' suffix on functions that return boolean types.

2014-06-12 Thread Harlan Harris
Back in the day, I believe that LISP programmers would end function names
with "p", for "predicate", to indicate a boolean return value. So, (stringp
foo). I recall a professor saying that they'd use "lunchp" to invite
colleagues to lunch...


On Thu, Jun 12, 2014 at 2:30 PM, Stefan Karpinski 
wrote:

> It's definitely a surmountable thing – I'd actually be rather in favor of
> using a trailing ? instead of the is prefix for predicates. I believe Jeff
> prefers the is prefix.
>
>
> On Thu, Jun 12, 2014 at 1:53 PM, Jameson Nash  wrote:
>
>> Interestingly (to me) Apples new language, Swift, uses ? as both a
>> ternary operator and a suffix for 'nullable' values, so this isn't an
>> insurmountable obstacle.
>>
>>
>> On Thursday, June 12, 2014, Steven G. Johnson 
>> wrote:
>>
>>>
>>>
>>> On Thursday, June 12, 2014 1:08:37 PM UTC-4, Aerlinger wrote:

 Ruby has a useful convention where methods can end in a '?' to indicate
 that it returns a boolean value. This capability would be useful in Julia
 as well. Much like the bang (!) suffix on functions it might look something
 like this:

 function isEven?(n::Int)
   n % 2 == 2
 end

>>>
>>> Yes, both the ! and ? suffixes are common conventions, possibly
>>> originating in Scheme.  Note that if you have a ? suffix, then you don't
>>> need the "is" prefix.
>>>
>>> However, ? is already being used for the ternary operator in Julia and
>>> hence is not available for use in identifiers.  Hence we instead adopt the
>>> "is" prefix convention.
>>>
>>
>


Re: [julia-users] support for '?' suffix on functions that return boolean types.

2014-06-12 Thread Stefan Karpinski
It's definitely a surmountable thing – I'd actually be rather in favor of
using a trailing ? instead of the is prefix for predicates. I believe Jeff
prefers the is prefix.


On Thu, Jun 12, 2014 at 1:53 PM, Jameson Nash  wrote:

> Interestingly (to me) Apples new language, Swift, uses ? as both a ternary
> operator and a suffix for 'nullable' values, so this isn't an
> insurmountable obstacle.
>
>
> On Thursday, June 12, 2014, Steven G. Johnson 
> wrote:
>
>>
>>
>> On Thursday, June 12, 2014 1:08:37 PM UTC-4, Aerlinger wrote:
>>>
>>> Ruby has a useful convention where methods can end in a '?' to indicate
>>> that it returns a boolean value. This capability would be useful in Julia
>>> as well. Much like the bang (!) suffix on functions it might look something
>>> like this:
>>>
>>> function isEven?(n::Int)
>>>   n % 2 == 2
>>> end
>>>
>>
>> Yes, both the ! and ? suffixes are common conventions, possibly
>> originating in Scheme.  Note that if you have a ? suffix, then you don't
>> need the "is" prefix.
>>
>> However, ? is already being used for the ternary operator in Julia and
>> hence is not available for use in identifiers.  Hence we instead adopt the
>> "is" prefix convention.
>>
>


Re: [julia-users] support for '?' suffix on functions that return boolean types.

2014-06-12 Thread Jameson Nash
Interestingly (to me) Apples new language, Swift, uses ? as both a ternary
operator and a suffix for 'nullable' values, so this isn't an
insurmountable obstacle.

On Thursday, June 12, 2014, Steven G. Johnson  wrote:

>
>
> On Thursday, June 12, 2014 1:08:37 PM UTC-4, Aerlinger wrote:
>>
>> Ruby has a useful convention where methods can end in a '?' to indicate
>> that it returns a boolean value. This capability would be useful in Julia
>> as well. Much like the bang (!) suffix on functions it might look something
>> like this:
>>
>> function isEven?(n::Int)
>>   n % 2 == 2
>> end
>>
>
> Yes, both the ! and ? suffixes are common conventions, possibly
> originating in Scheme.  Note that if you have a ? suffix, then you don't
> need the "is" prefix.
>
> However, ? is already being used for the ternary operator in Julia and
> hence is not available for use in identifiers.  Hence we instead adopt the
> "is" prefix convention.
>


Re: [julia-users] support for '?' suffix on functions that return boolean types.

2014-06-12 Thread Tim Holy
This has been discussed previously, either on julia-dev or in github/issues.

--Tim

On Thursday, June 12, 2014 10:08:37 AM Aerlinger wrote:
> Ruby has a useful convention where methods can end in a '?' to indicate
> that it returns a boolean value. This capability would be useful in Julia
> as well. Much like the bang (!) suffix on functions it might look something
> like this:
> 
> function isEven?(n::Int)
>   n % 2 == 2
> end
> 
> 
> isEven?(4)  # => true