Re: [julia-users] Re: For loop = or in?

2015-10-29 Thread Steven G. Johnson
See https://github.com/JuliaLang/julia/issues/8487

On Wednesday, October 28, 2015 at 10:16:37 AM UTC-4, Stefan Karpinski wrote:
>
> No, it's just a matter of changing the parser to accept that – and 
> convincing people that it's a good idea.
>
> On Wed, Oct 28, 2015 at 9:39 AM, DNF > 
> wrote:
>
>> On Wednesday, October 28, 2015 at 2:29:54 PM UTC+1, Stefan Karpinski 
>> wrote:
>>>
>>> I think we're getting into Parkinson's law territory here. First off, I 
>>> don't think this causes all that much confusion. Second, since this is pure 
>>> syntax involving a keyword no less, this is one of the easiest things to 
>>> mechanically fix should we chose to do so in the future.
>>>
>>
>> Fair enough. Could I just ask a question out of curiosity (not to try to 
>> convince anyone of anything)?
>>
>> Are there any technical problems (or other problems) associated with 
>> getting '∈' to work as a keyword, such as 
>> for i ∈ etc...
>> ?
>>
>
>

Re: [julia-users] Re: For loop = or in?

2015-10-29 Thread Tk
> `=` better than `in`: `a = [ f(i,j,k) for i=1:p, j=1:q, k=1:r ]`

Please note that I am not trying to claim "=" is better universally (i.e. 
for everyone) based on this example,
because some people prefer more English like syntax for clarity of meaning 
(even when a bit longer).

So anyway, it would be nice if the official document will be updated to 
emphasize that there is no distinction
between in and = (used with for-loops, as of v0.4), and that if one 
prefers, one could use "in" everywhere (this is
a great point). Then we can just cite that explanation when a question 
arises for a while :)


On Thursday, October 29, 2015 at 10:41:19 PM UTC+9, Tom Breloff wrote:
>
> Agreed with Tony.  Having lots of ways to do the same thing is fine, as 
> long as we had no other syntactical use for the `=`.  Anyone want to 
> support notation like: `for y = sin(_) in 1:10 ... end`?  Probably not, so 
> no big deal to keep both around.
>
> Also I just saw Tk's post with this great example of `=` better than `in`: 
> `a = [ f(i,j,k) for i=1:p, j=1:q, k=1:r ]`
>
> On Thu, Oct 29, 2015 at 9:10 AM, Tony Kelman  > wrote:
>
>> How is having multiple syntaxes for something automatically bad? I don't 
>> hear people complaining that for loops are redundant when you could just do 
>> while with a counter, or that enumerate is equivalent. Having style 
>> guidelines for base to say when one choice makes more sense than another is 
>> fine, but this thread's overblown.
>
>
>

Re: [julia-users] Re: For loop = or in?

2015-10-29 Thread Glen O
But that's true of just about every instance where there are multiple ways 
of doing things. vcat vs [;], for instance. In some cases, there are 
distinct reasons; in others, there's no functional difference, and it only 
exists for the purposes of making it easier to read, for instance. Like 
f(x) and x |> f. I'm sure there will be people who ask if there's any 
benefit to x|>f over f(x). And the answer, as in this case, is 
"readability".

If the question really comes up over and over again, a FAQ should be 
created to answer it. Changing the way the language works because some 
people will ask questions is, in my opinion, a bad reason to change it.

On Thursday, 29 October 2015 23:44:07 UTC+10, Tamas Papp wrote:
>
> Maybe I was not clear: having multiple syntaxes per se is not 
> necessarily bad. 
>
> What is somewhat inconvenient is that since there is no good reason for 
> having multiple syntaxes, some newcomers to the language will be 
> confused, and will ask about this from time to time. Eg this is how this 
> thread got started; this is not the first one and of course not the 
> last. And of course then existing users will join in, and reason for =, 
> in, both, or a third syntax. 
>
> This is one of those tricky situations where it is hard to argue that 
> the status quo is significantly inferior to other options, but since 
> there is not a compelling reason for it either, the issue will be 
> discussed from time to time. Which is of course OK, but if both = and in 
> remain then the FAQ and the manual could clarify that neither is 
> preferred, both are fine, and there is no semantic difference. 
>
> Best, 
>
> Tamas 
>


Re: [julia-users] Re: For loop = or in?

2015-10-29 Thread Seth
+1

On Thursday, October 29, 2015 at 5:56:46 AM UTC-7, Tom Breloff wrote:
>
> Lets close the topic.  Keep them both.
>
> On Thu, Oct 29, 2015 at 8:47 AM, feza > 
> wrote:
>
>> My only problem with `=` vs `in`
>> is that even the base julia code is inconsistent! Looking at one file ( I 
>> can't remember which now)
>> it had both
>> i = 1:nr
>> and
>> i in 1:n
>> Again this was in the same file! Please tell me I am not being pedantic 
>> when I saw this and thought this must be fixed if even the base is being 
>> inconsistent.
>>
>> On Thursday, October 29, 2015 at 8:44:03 AM UTC-4, mschauer wrote:
>>>
>>> Do we want to give up on this topic? Then we should do so in an earnest 
>>> way and close the case with a clear message, ideally after 
>>> establishing if we want to add a style recommendation about the use of 
>>> ``=`` and ``in`` to 
>>> http://docs.julialang.org/en/release-0.4/manual/style-guide/. Currently 
>>> the manual states in the control-flow chapter "In general, the for loop 
>>> construct can iterate over any container. In these cases, the alternative 
>>> (but fully equivalent) keyword in is typically used instead of =, since 
>>> it makes the code read more clearly."
>>>
>>
>

Re: [julia-users] Re: For loop = or in?

2015-10-29 Thread Tamas Papp
Maybe I was not clear: having multiple syntaxes per se is not
necessarily bad.

What is somewhat inconvenient is that since there is no good reason for
having multiple syntaxes, some newcomers to the language will be
confused, and will ask about this from time to time. Eg this is how this
thread got started; this is not the first one and of course not the
last. And of course then existing users will join in, and reason for =,
in, both, or a third syntax.

This is one of those tricky situations where it is hard to argue that
the status quo is significantly inferior to other options, but since
there is not a compelling reason for it either, the issue will be
discussed from time to time. Which is of course OK, but if both = and in
remain then the FAQ and the manual could clarify that neither is
preferred, both are fine, and there is no semantic difference. 

Best,

Tamas

On Thu, Oct 29 2015, Tony Kelman  wrote:

> How is having multiple syntaxes for something automatically bad? I don't hear 
> people complaining that for loops are redundant when you could just do while 
> with a counter, or that enumerate is equivalent. Having style guidelines for 
> base to say when one choice makes more sense than another is fine, but this 
> thread's overblown.



Re: [julia-users] Re: For loop = or in?

2015-10-29 Thread Tom Breloff
Agreed with Tony.  Having lots of ways to do the same thing is fine, as
long as we had no other syntactical use for the `=`.  Anyone want to
support notation like: `for y = sin(_) in 1:10 ... end`?  Probably not, so
no big deal to keep both around.

Also I just saw Tk's post with this great example of `=` better than `in`: `a
= [ f(i,j,k) for i=1:p, j=1:q, k=1:r ]`

On Thu, Oct 29, 2015 at 9:10 AM, Tony Kelman  wrote:

> How is having multiple syntaxes for something automatically bad? I don't
> hear people complaining that for loops are redundant when you could just do
> while with a counter, or that enumerate is equivalent. Having style
> guidelines for base to say when one choice makes more sense than another is
> fine, but this thread's overblown.


[julia-users] Re: For loop = or in?

2015-10-29 Thread Tk
Hi,

Before closing (this thread?), I would like to write one more thing. First, 
because I am not a native English speaker, it doesn't
actually matter how 1:n etc "reads" (simply because I don't pronounce them 
in mind :) Second, when I started
learning Julia half a year ago (sorry for a slow starter...), I also felt 
awkward that I have two kinds of syntax for the same
thing. So I tried to use "in" only for the time being (to mimic Python). 
But after a while I got back to "=", because it is gives  more concise (and 
IMO more readable) expressions, particularly in array comprehension. For 
example,

a = [ f(i,j,k) for i=1:p, j=1:q, k=1:r ]

a = [ f(i,j,k) for i in 1:p, j in 1:q, k in 1:r ]

# In this sense \in (greek letter) is as concise as =, but typing in the 
greek character takes a bit more time... (though I may be
able to customize Emacs if necessary).

As for Python-like, "there should be only one syntax for one purpose 
(semantic?)" policy (sorry if my English is strange), there seem to be many 
counter examples in Julia. For example, vcat() and [ a; b ] seem 
essentially the same, while the latter is probably there for brevity. I 
think it is not bad to have a shorter way to write it unless there are 
serious problems.

Btw, apart from the = vs in stuff, I really like this language because it 
allows multiple for-loops to be written concisely as

for i = 1:p,
 j = 1:q,
 k = 1:r
 (do something)
end

Indeed, I used to use a macro like this in C++ before that allows to write

For( i, 1, p,
   j, 1, p,
   k, 1, r ) {
 (do something)
}

so Julia has become one of my most favorite languages :)
Sorry for a long post...


Re: [julia-users] Re: For loop = or in?

2015-10-29 Thread Tony Kelman
How is having multiple syntaxes for something automatically bad? I don't hear 
people complaining that for loops are redundant when you could just do while 
with a counter, or that enumerate is equivalent. Having style guidelines for 
base to say when one choice makes more sense than another is fine, but this 
thread's overblown.

Re: [julia-users] Re: For loop = or in?

2015-10-29 Thread Tamas Papp
1. Unless there is a single syntax, the topic will inevitably come up
again and again. This does not necessarily mean that we need a single
syntax, but this is a cost of the status quo (ie having both = and in)
that has to be considered.

2. I think everyone said what they wanted to say. IMO it would be great
if the key people in Julia could make a decision about this, either
deprecate =, or in, or keep both, anything is fine, just have a clear
indication of what is going to happen so that people could submit a PR
for the documentation and the FAQ (if both are kept), or the base code
(or one is dropped).

Best,

Tamas

On Thu, Oct 29 2015, feza  wrote:

> My only problem with `=` vs `in`
> is that even the base julia code is inconsistent! Looking at one file ( I 
> can't remember which now)
> it had both
> i = 1:nr
> and
> i in 1:n
> Again this was in the same file! Please tell me I am not being pedantic 
> when I saw this and thought this must be fixed if even the base is being 
> inconsistent.
>
> On Thursday, October 29, 2015 at 8:44:03 AM UTC-4, mschauer wrote:
>>
>> Do we want to give up on this topic? Then we should do so in an earnest 
>> way and close the case with a clear message, ideally after 
>> establishing if we want to add a style recommendation about the use of 
>> ``=`` and ``in`` to 
>> http://docs.julialang.org/en/release-0.4/manual/style-guide/. Currently 
>> the manual states in the control-flow chapter "In general, the for loop 
>> construct can iterate over any container. In these cases, the alternative 
>> (but fully equivalent) keyword in is typically used instead of =, since 
>> it makes the code read more clearly."
>>



Re: [julia-users] Re: For loop = or in?

2015-10-29 Thread Tom Breloff
Lets close the topic.  Keep them both.

On Thu, Oct 29, 2015 at 8:47 AM, feza  wrote:

> My only problem with `=` vs `in`
> is that even the base julia code is inconsistent! Looking at one file ( I
> can't remember which now)
> it had both
> i = 1:nr
> and
> i in 1:n
> Again this was in the same file! Please tell me I am not being pedantic
> when I saw this and thought this must be fixed if even the base is being
> inconsistent.
>
> On Thursday, October 29, 2015 at 8:44:03 AM UTC-4, mschauer wrote:
>>
>> Do we want to give up on this topic? Then we should do so in an earnest
>> way and close the case with a clear message, ideally after
>> establishing if we want to add a style recommendation about the use of
>> ``=`` and ``in`` to
>> http://docs.julialang.org/en/release-0.4/manual/style-guide/. Currently
>> the manual states in the control-flow chapter "In general, the for loop
>> construct can iterate over any container. In these cases, the alternative
>> (but fully equivalent) keyword in is typically used instead of =, since
>> it makes the code read more clearly."
>>
>


Re: [julia-users] Re: For loop = or in?

2015-10-29 Thread feza
My only problem with `=` vs `in`
is that even the base julia code is inconsistent! Looking at one file ( I 
can't remember which now)
it had both
i = 1:nr
and
i in 1:n
Again this was in the same file! Please tell me I am not being pedantic 
when I saw this and thought this must be fixed if even the base is being 
inconsistent.

On Thursday, October 29, 2015 at 8:44:03 AM UTC-4, mschauer wrote:
>
> Do we want to give up on this topic? Then we should do so in an earnest 
> way and close the case with a clear message, ideally after 
> establishing if we want to add a style recommendation about the use of 
> ``=`` and ``in`` to 
> http://docs.julialang.org/en/release-0.4/manual/style-guide/. Currently 
> the manual states in the control-flow chapter "In general, the for loop 
> construct can iterate over any container. In these cases, the alternative 
> (but fully equivalent) keyword in is typically used instead of =, since 
> it makes the code read more clearly."
>


Re: [julia-users] Re: For loop = or in?

2015-10-29 Thread mschauer
Do we want to give up on this topic? Then we should do so in an earnest way 
and close the case with a clear message, ideally after 
establishing if we want to add a style recommendation about the use of 
``=`` and ``in`` to 
http://docs.julialang.org/en/release-0.4/manual/style-guide/. Currently the 
manual states in the control-flow chapter "In general, the for loop 
construct can iterate over any container. In these cases, the alternative 
(but fully equivalent) keyword in is typically used instead of =, since it 
makes the code read more clearly."


Re: [julia-users] Re: For loop = or in?

2015-10-29 Thread Kristoffer Carlsson
Well then it's settled. Someone prepare a PR ;)

Re: [julia-users] Re: For loop = or in?

2015-10-29 Thread Tony Kelman
Pontus, you're awesome. Technically the first commit here was merged 4 
minutes before your post, but funny anyway:

julia> mod(big"0xdfe0cc00e3ae91cd981d0b4243498f8321992fbc",10)
0

julia> mod(big"0xf8a4340548e7d6be31fede13cdc4e0f5f434f33f",10)
7

My opinion would be to leave it since Julia isn't Python and we're not too 
militaristic about "one way to do it" zen nonsense when things aren't 
actively harmful or confusing, but Pontus just about wins me over with that.


On Thursday, October 29, 2015 at 2:38:33 AM UTC-7, Pontus Stenetorp wrote:
>
> I have to agree with Stefan that this is turning into 
> bikeshedding [1].  My personal bias is towards `in`, probably due to 
> my many years of Python, but I am convinced that both keeping the 
> current duality or picking one of them will not lead to a mental 
> overload.  In fact, in order for us to stop spending brain cycles on 
> this, it would even seem sane to me to take the hash of the next 
> commit after this e-mail has been sent, apply modulo 10, if the number 
> is 1-3, preserve the status quo, for 4-6, switch to using `=`, for 
> 7-9, switch to using `in`, for 0, discard the number and use the next 
> commit instead. 
>
> Pontus 
>
> [1]: https://en.wikipedia.org/wiki/Parkinson's_law_of_triviality 
>


Re: [julia-users] Re: For loop = or in?

2015-10-29 Thread Pontus Stenetorp
I have to agree with Stefan that this is turning into
bikeshedding [1].  My personal bias is towards `in`, probably due to
my many years of Python, but I am convinced that both keeping the
current duality or picking one of them will not lead to a mental
overload.  In fact, in order for us to stop spending brain cycles on
this, it would even seem sane to me to take the hash of the next
commit after this e-mail has been sent, apply modulo 10, if the number
is 1-3, preserve the status quo, for 4-6, switch to using `=`, for
7-9, switch to using `in`, for 0, discard the number and use the next
commit instead.

Pontus

[1]: https://en.wikipedia.org/wiki/Parkinson's_law_of_triviality


[julia-users] Re: For loop = or in?

2015-10-29 Thread Alireza Nejati
I'm with Tomas here - if anything this thread is testimony to the fact that 
both '=' and 'in' should be left in.


Re: [julia-users] Re: For loop = or in?

2015-10-29 Thread Tomas Lycken
I read 1:n that way. And even if I didn't, I prefer to think about a looping 
construct as "do this for each element in that collection" - and regardless of 
how I pronounce 1:n, I see it as a collection since it inherits AbstractArray. 

But I can also see how other mental models work for you. There's a lot of talk 
in this thread along the lines of "my mental model of this construct is better 
than yours, and therefore my syntax preference is better than yours." I find 
this ridiculously inconstructive - bordering on children arguing in the 
sandbox... To me, this just indicates that both mental models are valid that 
both syntaxes should, at least for the time being, stay. The fact that no clear 
winner can be found by counting usages in base further supports this. 

There is a suggestion in this thread worth keeping, though - supporting unicode 
\in would be a nice addition for those of us who embrace supersets of ascii.

// Tomas 

Re: [julia-users] Re: For loop = or in?

2015-10-28 Thread Glen O
And in any other context in Julia, "in" is a function that returns "true" 
or "false" based on whether the first thing is in the second thing.

As far as I'm aware, the language is supposed to be structured to make it 
easy for a human to understand, with the underlying parser then converting 
it into a form that a computer understands. The parsing is the underlying 
interpretation; why should we impose the parser's interpretation? "for 
i=1:n" reads naturally as "for i equals 1 through n", even as "1:n" reads 
as "1 through n". On the other hand, "for i in 1:n" would be read as "for i 
in 1 through n", which makes no sense. Of course, if you get more wordy, it 
can be redeemed - "for i in the range 1 through n"... but I can't imagine 
anybody would read "1:n" as the phrase "the range 1 through n".



On Thursday, 29 October 2015 03:05:05 UTC+10, mschauer wrote:
>
>
> Let's shortly state why "in" is more appropriate. The notion "for i = 1 : 
> n" is established and meaningful *when* read as "for (i = 1) : (n)", very 
> similar in the mathematical notation $\sum_{i=1}^{n} f(i)$. Notice the 
> parentheses in both expressions! On the other hand, at any other location 
> "r = 1:2" in julia parses as "r = (1:2)" and indicates that r is a range 
> and not that r is an integer from a range. 
>
>
>
>
> Am Mittwoch, 28. Oktober 2015 15:16:37 UTC+1 schrieb Stefan Karpinski:
>>
>> No, it's just a matter of changing the parser to accept that – and 
>> convincing people that it's a good idea.
>>
>> On Wed, Oct 28, 2015 at 9:39 AM, DNF  wrote:
>>
>>> On Wednesday, October 28, 2015 at 2:29:54 PM UTC+1, Stefan Karpinski 
>>> wrote:

 I think we're getting into Parkinson's law territory here. First off, I 
 don't think this causes all that much confusion. Second, since this is 
 pure 
 syntax involving a keyword no less, this is one of the easiest things to 
 mechanically fix should we chose to do so in the future.

>>>
>>> Fair enough. Could I just ask a question out of curiosity (not to try to 
>>> convince anyone of anything)?
>>>
>>> Are there any technical problems (or other problems) associated with 
>>> getting '∈' to work as a keyword, such as 
>>> for i ∈ etc...
>>> ?
>>>
>>
>>

Re: [julia-users] Re: For loop = or in?

2015-10-28 Thread mschauer

Let's shortly state why "in" is more appropriate. The notion "for i = 1 : 
n" is established and meaningful *when* read as "for (i = 1) : (n)", very 
similar in the mathematical notation $\sum_{i=1}^{n} f(i)$. Notice the 
parentheses in both expressions! On the other hand, at any other location 
"r = 1:2" in julia parses as "r = (1:2)" and indicates that r is a range 
and not that r is an integer from a range. 




Am Mittwoch, 28. Oktober 2015 15:16:37 UTC+1 schrieb Stefan Karpinski:
>
> No, it's just a matter of changing the parser to accept that – and 
> convincing people that it's a good idea.
>
> On Wed, Oct 28, 2015 at 9:39 AM, DNF > 
> wrote:
>
>> On Wednesday, October 28, 2015 at 2:29:54 PM UTC+1, Stefan Karpinski 
>> wrote:
>>>
>>> I think we're getting into Parkinson's law territory here. First off, I 
>>> don't think this causes all that much confusion. Second, since this is pure 
>>> syntax involving a keyword no less, this is one of the easiest things to 
>>> mechanically fix should we chose to do so in the future.
>>>
>>
>> Fair enough. Could I just ask a question out of curiosity (not to try to 
>> convince anyone of anything)?
>>
>> Are there any technical problems (or other problems) associated with 
>> getting '∈' to work as a keyword, such as 
>> for i ∈ etc...
>> ?
>>
>
>

Re: [julia-users] Re: For loop = or in?

2015-10-28 Thread Stefan Karpinski
No, it's just a matter of changing the parser to accept that – and
convincing people that it's a good idea.

On Wed, Oct 28, 2015 at 9:39 AM, DNF  wrote:

> On Wednesday, October 28, 2015 at 2:29:54 PM UTC+1, Stefan Karpinski wrote:
>>
>> I think we're getting into Parkinson's law territory here. First off, I
>> don't think this causes all that much confusion. Second, since this is pure
>> syntax involving a keyword no less, this is one of the easiest things to
>> mechanically fix should we chose to do so in the future.
>>
>
> Fair enough. Could I just ask a question out of curiosity (not to try to
> convince anyone of anything)?
>
> Are there any technical problems (or other problems) associated with
> getting '∈' to work as a keyword, such as
> for i ∈ etc...
> ?
>


Re: [julia-users] Re: For loop = or in?

2015-10-28 Thread DNF
On Wednesday, October 28, 2015 at 2:29:54 PM UTC+1, Stefan Karpinski wrote:
>
> I think we're getting into Parkinson's law territory here. First off, I 
> don't think this causes all that much confusion. Second, since this is pure 
> syntax involving a keyword no less, this is one of the easiest things to 
> mechanically fix should we chose to do so in the future.
>

Fair enough. Could I just ask a question out of curiosity (not to try to 
convince anyone of anything)?

Are there any technical problems (or other problems) associated with 
getting '∈' to work as a keyword, such as 
for i ∈ etc...
?


[julia-users] Re: For loop = or in?

2015-10-28 Thread Glen O
You are right, it only "really" applies to indexing (and related)... but 
that's kind of the point. There are only a select number of cases where the 
"=" is more natural, but it is definitely more natural in those situations. 
More generally, if you're wanting a simple counter to make the code do 
something N times, then "for x=1:N" feels much more natural than "for x in 
1:N".

I'm also not clear on what you're calling a metaphor. The two pieces of 
code I provided do exactly the same thing (the only difference is the order 
of operations, but it's doing the same thing).

On Wednesday, 28 October 2015 23:08:05 UTC+10, feza wrote:
>
> I don't think that this metaphor is actually relevant:
>
> i=1:5
> A[i]=B[i].*C[i]
>
> or, you could write it as a loop...
>
> for i=1:5
>  A[i]=B[i]*C[i]
> end
>
> since the `for` changes meaning completely
> i = 1:10
> a[i] = b[i].*c[i]
>
> and  the above only makes sense when indexing, not for other iterables
>


Re: [julia-users] Re: For loop = or in?

2015-10-28 Thread Stefan Karpinski
I think we're getting into Parkinson's law territory here. First off, I
don't think this causes all that much confusion. Second, since this is pure
syntax involving a keyword no less, this is one of the easiest things to
mechanically fix should we chose to do so in the future.

On Wed, Oct 28, 2015 at 9:18 AM, Tamas Papp  wrote:

> On Wed, Oct 28 2015, feza  wrote:
>
> > But really this seems like a fundamental enough language construct that
> > there should be only one correct way; but on the other hand my brain
> > doesn't have a problem with `=` and it seems natural since I have been
> > using matlab for a while, even though `in` seems actually to make more
> > sense here.
>
> I think that even simply tossing a coin between = and in and just
> picking one would improve on the current situation. Either Matlab or R
> users will have to learn a new syntax, but I doubt that this is the
> biggest hurdle they will encounter in Julia.
>
> This would resolve the uncertainty, stop "why = or in" questions (they
> come up frequently), and also stop further bikeshedding about this.
>
> Best,
>
> Tamas
>


Re: [julia-users] Re: For loop = or in?

2015-10-28 Thread Tamas Papp
On Wed, Oct 28 2015, feza  wrote:

> But really this seems like a fundamental enough language construct that 
> there should be only one correct way; but on the other hand my brain 
> doesn't have a problem with `=` and it seems natural since I have been 
> using matlab for a while, even though `in` seems actually to make more 
> sense here.

I think that even simply tossing a coin between = and in and just
picking one would improve on the current situation. Either Matlab or R
users will have to learn a new syntax, but I doubt that this is the
biggest hurdle they will encounter in Julia.

This would resolve the uncertainty, stop "why = or in" questions (they
come up frequently), and also stop further bikeshedding about this.

Best,

Tamas


[julia-users] Re: For loop = or in?

2015-10-28 Thread feza
actually its more about simple confusion rather than mental cost @DNF. 
Starting out you either use = or in then you see some other code and they 
use something else and wonder, what is right, is one notation faster or 
better, what's going on? Of course, it's not the simplest thing to try and 
search for in the documents (for someone not familiar with iterator 
terminology, searching for `in` or `=` is useless). Hence Fang's original 
post's concern (and others as evident from this post).

But really this seems like a fundamental enough language construct that 
there should be only one correct way; but on the other hand my brain 
doesn't have a problem with `=` and it seems natural since I have been 
using matlab for a while, even though `in` seems actually to make more 
sense here.

I don't think that this metaphor is actually relevant:

i=1:5
A[i]=B[i].*C[i]

or, you could write it as a loop...

for i=1:5
 A[i]=B[i]*C[i]
end

since the `for` changes meaning completely
i = 1:10
a[i] = b[i].*c[i]

and  the above only makes sense when indexing, not for other iterables


 
In any case, someone should collect the arguments and file an issue on 
github to at least get some additional opinions.

On Wednesday, October 28, 2015 at 8:45:16 AM UTC-4, DNF wrote:
>
> You are right, of course. It's just one of those minor cosmetic things you 
> fix in a pre-1.0 version, or then maybe never. And it's good not to have 
> too many of those.
>
> Also
> for i ∈ 1:N
> just looks incredibly awesome. 
>
>
> On Wednesday, October 28, 2015 at 1:38:57 PM UTC+1, STAR0SS wrote:
>>
>> I think people grossly exaggerate the "mental cost" of having both = and 
>> in. It's really not that complicated, well explained in the docs and can 
>> never cause bugs.
>>
>> On the other hand the depreciation cost will big quite large, given it 
>> seems both are used 50/50. Plus the numerous complain posts on this forum. 
>> Don't fix what's not broken.
>>
>>
>>
>>

[julia-users] Re: For loop = or in?

2015-10-28 Thread DNF
You are right, of course. It's just one of those minor cosmetic things you 
fix in a pre-1.0 version, or then maybe never. And it's good not to have 
too many of those.

Also
for i ∈ 1:N
just looks incredibly awesome. 


On Wednesday, October 28, 2015 at 1:38:57 PM UTC+1, STAR0SS wrote:
>
> I think people grossly exaggerate the "mental cost" of having both = and 
> in. It's really not that complicated, well explained in the docs and can 
> never cause bugs.
>
> On the other hand the depreciation cost will big quite large, given it 
> seems both are used 50/50. Plus the numerous complain posts on this forum. 
> Don't fix what's not broken.
>
>
>
>

[julia-users] Re: For loop = or in?

2015-10-28 Thread STAR0SS
I think people grossly exaggerate the "mental cost" of having both = and 
in. It's really not that complicated, well explained in the docs and can 
never cause bugs.

On the other hand the depreciation cost will big quite large, given it 
seems both are used 50/50. Plus the numerous complain posts on this forum. 
Don't fix what's not broken.





Re: [julia-users] Re: For loop = or in?

2015-10-28 Thread DNF


On Wednesday, October 28, 2015 at 10:22:45 AM UTC+1, Glen O wrote:
>
> The thing is, it IS an assignment that's going on. In the case of a range, 
> especially, "for i=1:5" says "loop 5 times, with i=1, then i=2, then i=3, 
> then i=4, then i=5". "i' is being assigned to on each iteration. Think of 
> it this way - suppose you were using elementwise operations. You could write
>
> i=1:5
> A[i]=B[i].*C[i]
>
> or, you could write it as a loop...
>
> for i=1:5
>  A[i]=B[i]*C[i]
> end
>

I buy that argument. Both 'in' and '=' make good metaphors for thinking 
about loops. It's that they are different metaphors, while 'in' and '∈' are 
identical in meaning and (arguably) in pronunciation.

Choosing either of them for loops would be fine, but having two different 
synonyms for 'in' is just a bit jarring.
 

> The two pieces of code are doing exactly the same thing; one is just 
> explicitly writing the loop. In what way does restricting to "in" help, in 
> this situation?
>

I don't know about this situation in particular, but I think in general it 
is helping in 
a) simplifying; no more three-way aliasing stuff.
b) consistency; 'in' and '∈' become interchangeable in both contexts.


Re: [julia-users] Re: For loop = or in?

2015-10-28 Thread DNF


On Wednesday, October 28, 2015 at 9:51:10 AM UTC+1, Tamas Papp wrote:
>
> I am probably old-fashined, but I always prefer to stick to ASCII unless 
> there is a compelling reason. If I want something to stick out, I can 
> always customize Emacs to do it. 
>
 
Well, both 'in' and '=' are ASCII, so that shouldn't be a problem either 
way. 

Also, I don't think it is ideal to have two (or more) operators that are 
> interchangeable as far as the language is concerned, but have stylistic 
> differences assigned to them by convention. If that convention is 
> useful and justified, it should be merged into the language per se; if 
> not, then it just borders on confusing.
>

Admittedly, I understand only about half of this paragraph, but it sounds 
like an argument against having both 'in' and '=' notation in loops. As for 
unicode aliases, I think that ship has sailed. There are lots of those, and 
I don't think they're going anywhere. I don't even know if it's most 
correct to say that '∈' is an alias for 'in', or if 'in' is the English 
transcription of '∈'. They are one and the same as far as I can tell. The 
same cannot really be said about 'in' and '='.

The worst thing, I think, though, is having two different aliases for 'in': 
'∈' in one context, and '=' in the other. Especially since '=' is used in 
the infix position
where '∈' would be natural. 


Re: [julia-users] Re: For loop = or in?

2015-10-28 Thread Glen O
The thing is, it IS an assignment that's going on. In the case of a range, 
especially, "for i=1:5" says "loop 5 times, with i=1, then i=2, then i=3, 
then i=4, then i=5". "i' is being assigned to on each iteration. Think of 
it this way - suppose you were using elementwise operations. You could write

i=1:5
A[i]=B[i].*C[i]

or, you could write it as a loop...

for i=1:5
 A[i]=B[i]*C[i]
end

The two pieces of code are doing exactly the same thing; one is just 
explicitly writing the loop. In what way does restricting to "in" help, in 
this situation?

On Wednesday, 28 October 2015 17:56:44 UTC+10, DNF wrote:
>
> On Wednesday, October 28, 2015 at 7:56:54 AM UTC+1, Gabor wrote:
>>
>> Confusion?
>> Considering the investment into learning all the new and powerful Julia 
>> language constructs,
>> I don't see why exactly this elegant duality would be a problem for 
>> anyone.
>>
>
> I don't think = and in represent an elegant duality. They seem a very odd 
> couple to me (even though I have been using = in Matlab for 15 years.) On 
> the other hand, = and ∈ do seem to offer an elegant duality, since they 
> are already synonyms in other contexts. The concept of 'in' also seems more 
> logical than '=', which is an assignment operator.
>
> One advantage of = over 'in' is that it sticks out more visually. That is 
> solved by ∈, though.
>


Re: [julia-users] Re: For loop = or in?

2015-10-28 Thread Tamas Papp
On Wed, Oct 28 2015, DNF  wrote:

> On Wednesday, October 28, 2015 at 7:56:54 AM UTC+1, Gabor wrote:
>>
>> Confusion?
>> Considering the investment into learning all the new and powerful Julia 
>> language constructs,
>> I don't see why exactly this elegant duality would be a problem for anyone.
>>
>
> I don't think = and in represent an elegant duality. They seem a very odd 
> couple to me (even though I have been using = in Matlab for 15 years.) On 
> the other hand, = and ∈ do seem to offer an elegant duality, since they are 
> already synonyms in other contexts. The concept of 'in' also seems more 
> logical than '=', which is an assignment operator.
>
> One advantage of = over 'in' is that it sticks out more visually. That is 
> solved by ∈, though.

I am probably old-fashined, but I always prefer to stick to ASCII unless
there is a compelling reason. If I want something to stick out, I can
always customize Emacs to do it.

Also, I don't think it is ideal to have two (or more) operators that are
interchangeable as far as the language is concerned, but have stylistic
differences assigned to them by convention. If that convention is
useful and justified, it should be merged into the language per se; if
not, then it just borders on confusing.

Best,

Tamas


Re: [julia-users] Re: For loop = or in?

2015-10-28 Thread DNF


On Wednesday, October 28, 2015 at 8:56:44 AM UTC+1, DNF wrote:
>
> I don't think = and in represent an elegant duality. They seem a very odd 
> couple to me (even though I have been using = in Matlab for 15 years.) On 
> the other hand, = and ∈ do seem to offer an elegant duality,
>

Sorry, of course I meant ∈ and 'in' are dually elegant, not ∈ and =. 


Re: [julia-users] Re: For loop = or in?

2015-10-28 Thread DNF
On Wednesday, October 28, 2015 at 7:56:54 AM UTC+1, Gabor wrote:
>
> Confusion?
> Considering the investment into learning all the new and powerful Julia 
> language constructs,
> I don't see why exactly this elegant duality would be a problem for anyone.
>

I don't think = and in represent an elegant duality. They seem a very odd 
couple to me (even though I have been using = in Matlab for 15 years.) On 
the other hand, = and ∈ do seem to offer an elegant duality, since they are 
already synonyms in other contexts. The concept of 'in' also seems more 
logical than '=', which is an assignment operator.

One advantage of = over 'in' is that it sticks out more visually. That is 
solved by ∈, though.


Re: [julia-users] Re: For loop = or in?

2015-10-27 Thread Gabor
My vote is for keeping '='.
It is very readable for counters as is 'in' for other containers.

Confusion?
Considering the investment into learning all the new and powerful Julia 
language constructs,
I don't see why exactly this elegant duality would be a problem for anyone.

It is not even a documentation issue, 
the documentation is already crystal clear:

"In general, the for loop construct can iterate over any container. 
In these cases, the alternative (but fully equivalent) keyword in is 
typically used
instead of =, since it makes the code read more clearly"

On Tuesday, October 27, 2015 at 10:55:23 PM UTC+1, Hai Nguyen wrote:
>
>
>
> On Tue, Oct 27, 2015 at 10:04 AM, Stefan Karpinski  > wrote:
>
>> My general approach is to only use = when the RHS is an explicit range, 
>> as in `for i = 1:n`. For everything else I use `for i in v`. I would be ok 
>> with dropping the = syntax at some point, but it seems pretty harmless to 
>> have it.
>>
>>
> I have 1 vote for removing '='. It is harmless but it introduces confusion.
>
> Hai
>  
>
>> On Tue, Oct 27, 2015 at 8:56 AM, FANG Colin > > wrote:
>>
>>> Thank you. In that case I will happily stick with `in`.
>>>
>>>
>>> On Monday, October 26, 2015 at 8:43:22 PM UTC, Alireza Nejati wrote:

 There is no difference, as far as I know.

 '=' seems to be used more for explicit ranges (i = 1:5) and 'in' seems 
 to be used more for variables (i in mylist). But using 'in' for everything 
 is ok too.

 The '=' is there for familiarity with matlab. Remember that julia's 
 syntax was in part designed to be familiar to matlab users.

 On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:
>
> Hi All
>
> I have got a stupid question:
>
> Are there any difference in "for i in 1:5" and "for i = 1:5"?
>
> Does the julia community prefer one to the other? I see use of both in 
> the documentations and source code.
>
> Personally I haven't seen much use of "for i = 1:5" in other 
> languages.
>
> Thanks.
>

>>
>

Re: [julia-users] Re: For loop = or in?

2015-10-27 Thread Hai Nguyen
On Tue, Oct 27, 2015 at 10:04 AM, Stefan Karpinski 
wrote:

> My general approach is to only use = when the RHS is an explicit range, as
> in `for i = 1:n`. For everything else I use `for i in v`. I would be ok
> with dropping the = syntax at some point, but it seems pretty harmless to
> have it.
>
>
I have 1 vote for removing '='. It is harmless but it introduces confusion.

Hai


> On Tue, Oct 27, 2015 at 8:56 AM, FANG Colin  wrote:
>
>> Thank you. In that case I will happily stick with `in`.
>>
>>
>> On Monday, October 26, 2015 at 8:43:22 PM UTC, Alireza Nejati wrote:
>>>
>>> There is no difference, as far as I know.
>>>
>>> '=' seems to be used more for explicit ranges (i = 1:5) and 'in' seems
>>> to be used more for variables (i in mylist). But using 'in' for everything
>>> is ok too.
>>>
>>> The '=' is there for familiarity with matlab. Remember that julia's
>>> syntax was in part designed to be familiar to matlab users.
>>>
>>> On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:

 Hi All

 I have got a stupid question:

 Are there any difference in "for i in 1:5" and "for i = 1:5"?

 Does the julia community prefer one to the other? I see use of both in
 the documentations and source code.

 Personally I haven't seen much use of "for i = 1:5" in other languages.

 Thanks.

>>>
>


Re: [julia-users] Re: For loop = or in?

2015-10-27 Thread Tk
As far as I can understand, Julia also seems trying to attract people from 
Matlab,
because there are so many similarities in the syntax (.* and ./ etc) and 
the names of functions.

Also I often see questions from Matlab users posted in StackOverflow. Their 
codes are
rather Matlab-like, but it works anyway. I guess this helps people to try a 
new language
with lower barrier. (Though, personally, I don't like ".*" notation very 
much. But I can live with it.)

As for =, I also prefer using = for counters (for i = 1:n) and "in" for 
other containers.
I use Fortran and Python most often for research work, but I feel "=" is 
quite natural for indicating
that the index goes from 1 to n. On the other hand, with "in", I feel like 
the entity is just
somewhere inside the container, with no particular order enforced (even if 
it has a definite order).
My familiarity with "=" is probably coming from old languages (including 
C-like ones),
but that aside, I hope "=" remains a valid symbol for this.

So anyway, +1 for the comments from Glen O.

On Wednesday, October 28, 2015 at 3:20:19 AM UTC+9, FANG Colin wrote:
>
> Julia tries to attract people from Python & R, which use `in`. As for 
> matlab, it is not a direct competitor.
>
> Anyway, I think we only need 1 of the 2. "There should be one-- and 
> preferably only one --obvious way to do it."
>
> Maybe enhance the documentation for the time being.
>
>
> On 27 October 2015 at 16:38, Glen O > 
> wrote:
>
>> "When calculating a Fibonacci number, we have to apply 
>> F_n=F_(n-1)+F_(n-2) repeatedly. So to find F_6, we apply the equation for n 
>> equals 3 through 6". Writing it as "for n in 3 through 6" or "for n in the 
>> range 3 through 6" wouldn't make nearly as much sense.
>>
>> As I said, for general iterables, like vectors, the "in" keyword makes 
>> more sense. But when you're talking about a counter variable, equals makes 
>> a much more natural expression - you're not really constructing the range 
>> object, you're just telling the program you want the counter to start at 
>> the first value, and increment until it reaches the second value.
>>
>> On Wednesday, 28 October 2015 02:23:54 UTC+10, Tom Breloff wrote:
>>>
>>> It definitely makes sense for a range.
>>>
>>>
>>> Sorry... gotta disagree... mathematical set notation is more 
>>> appropriate, especially for scientific computing.  This is coming from a 
>>> former matlab user, btw, so it's not like I was confused by the syntax.   
>>> The "for i = 1:5" syntax is actually more reminiscent of C:  "for (int i=1; 
>>> i<=5; i++)", and I'm guessing that the syntax originated more from that 
>>> rather than scientific concepts.
>>>
>>> On Tue, Oct 27, 2015 at 11:58 AM, feza  wrote:
>>>
 +1 @Tom Breloff .  
 I was confused about this when starting out. Comparing   `for i in 
 1:3` vs  `for i = 1:3`, even though I regularly use matlab if you think 
 about it for `i = 1:10` doesn't really make a lot of sense. It would be 
 nice if it was just one way as opposed to the confusion about whether = or 
 in should be used.

 On Tuesday, October 27, 2015 at 10:26:44 AM UTC-4, Tom Breloff wrote:
>
> It's harmless, sure, but I would prefer that everyone uses "in" 
> exclusively so that there's one less thing to waste brainpower on.  You 
> don't say "for each x equals the range 1 to n", you say "for each x in 
> the 
> range 1 to n".  I don't think "=" has a place here at all except to allow 
> copy/pasting of Matlab code (which creates other performance problems 
> anyways).
>
> On Tue, Oct 27, 2015 at 10:04 AM, Stefan Karpinski <
> ste...@karpinski.org> wrote:
>
>> My general approach is to only use = when the RHS is an explicit 
>> range, as in `for i = 1:n`. For everything else I use `for i in v`. I 
>> would 
>> be ok with dropping the = syntax at some point, but it seems pretty 
>> harmless to have it.
>>
>> On Tue, Oct 27, 2015 at 8:56 AM, FANG Colin  
>> wrote:
>>
>>> Thank you. In that case I will happily stick with `in`.
>>>
>>>
>>> On Monday, October 26, 2015 at 8:43:22 PM UTC, Alireza Nejati wrote:

 There is no difference, as far as I know.

 '=' seems to be used more for explicit ranges (i = 1:5) and 'in' 
 seems to be used more for variables (i in mylist). But using 'in' for 
 everything is ok too.

 The '=' is there for familiarity with matlab. Remember that julia's 
 syntax was in part designed to be familiar to matlab users.

 On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:
>
> Hi All
>
> I have got a stupid question:
>
> Are there any difference in "for i in 1:5" and "for i = 1:5"?
>
> Does the julia community prefer one to the other? I see use of 
> both in the documentations and source code.
>>>

Re: [julia-users] Re: For loop = or in?

2015-10-27 Thread DNF
On Tuesday, October 27, 2015 at 4:56:12 PM UTC+1, Glen O wrote:
>
> Incidentally, it would be nice if ∈ could be used as another option - it's 
> just another way of saying "in", but it would look nicer in certain 
> mathematical contexts, and it's not like the symbol would be used in 
> another way in that position.
>

I very much like the idea of using for ∈ 1:n. In fact, as ∈ is a direct 
synonym for the function in, would it not make sense to let it be a synonym 
also in this context? Would it be problematic in some way? What is the 
difference in the meanings of in that prevents this from already being the 
case?


Re: [julia-users] Re: For loop = or in?

2015-10-27 Thread Seth
There are, by my unscientific count*, 439 instances in base that use "for 
... =", and 653 using "for ... in".

(grep -Ri "for .* =" *.jl | wc -l)

On Tuesday, October 27, 2015 at 11:36:01 AM UTC-7, David Anthoff wrote:
>
> If something like this were to change, it would be good to do it sooner 
> rather than later -> less code that depends on the syntax that would go 
> would have been written. So maybe the right way forward for this is to open 
> an issue suggesting to drop the = variant, discuss it, make a decision and 
> then live with it, all for the 0.5 cycle.
>
>  
>
> I don’t feel strongly about this, but for what it’s worth, I’m also a fan 
> of having only one way to do something like this.
>
>  
>
> Cheers,
>
> David 
>
>  
>
> *From:* julia...@googlegroups.com  [mailto:
> julia...@googlegroups.com ] *On Behalf Of *FANG Colin
> *Sent:* Tuesday, October 27, 2015 11:20 AM
> *To:* julia...@googlegroups.com 
> *Subject:* Re: [julia-users] Re: For loop = or in?
>
>  
>
> Julia tries to attract people from Python & R, which use `in`. As for 
> matlab, it is not a direct competitor.
>
>  
>
> Anyway, I think we only need 1 of the 2. "There should be one-- and 
> preferably only one --obvious way to do it."
>
>  
>
> Maybe enhance the documentation for the time being.
>
>  
>
>  
>
> On 27 October 2015 at 16:38, Glen O > 
> wrote:
>
> "When calculating a Fibonacci number, we have to apply F_n=F_(n-1)+F_(n-2) 
> repeatedly. So to find F_6, we apply the equation for n equals 3 through 
> 6". Writing it as "for n in 3 through 6" or "for n in the range 3 through 
> 6" wouldn't make nearly as much sense.
>
>  
>
> As I said, for general iterables, like vectors, the "in" keyword makes 
> more sense. But when you're talking about a counter variable, equals makes 
> a much more natural expression - you're not really constructing the range 
> object, you're just telling the program you want the counter to start at 
> the first value, and increment until it reaches the second value.
>
> On Wednesday, 28 October 2015 02:23:54 UTC+10, Tom Breloff wrote:
>
> It definitely makes sense for a range.
>
>  
>
> Sorry... gotta disagree... mathematical set notation is more appropriate, 
> especially for scientific computing.  This is coming from a former matlab 
> user, btw, so it's not like I was confused by the syntax.   The "for i = 
> 1:5" syntax is actually more reminiscent of C:  "for (int i=1; i<=5; i++)", 
> and I'm guessing that the syntax originated more from that rather than 
> scientific concepts.
>
>  
>
> On Tue, Oct 27, 2015 at 11:58 AM, feza  wrote:
>
> +1 @Tom Breloff .  
> I was confused about this when starting out. Comparing   `for i in 1:3` vs 
>  `for i = 1:3`, even though I regularly use matlab if you think about it 
> for `i = 1:10` doesn't really make a lot of sense. It would be nice if it 
> was just one way as opposed to the confusion about whether = or in should 
> be used.
>
> On Tuesday, October 27, 2015 at 10:26:44 AM UTC-4, Tom Breloff wrote:
>
> It's harmless, sure, but I would prefer that everyone uses "in" 
> exclusively so that there's one less thing to waste brainpower on.  You 
> don't say "for each x equals the range 1 to n", you say "for each x in the 
> range 1 to n".  I don't think "=" has a place here at all except to allow 
> copy/pasting of Matlab code (which creates other performance problems 
> anyways).
>
>  
>
> On Tue, Oct 27, 2015 at 10:04 AM, Stefan Karpinski  
> wrote:
>
> My general approach is to only use = when the RHS is an explicit range, as 
> in `for i = 1:n`. For everything else I use `for i in v`. I would be ok 
> with dropping the = syntax at some point, but it seems pretty harmless to 
> have it.
>
>  
>
> On Tue, Oct 27, 2015 at 8:56 AM, FANG Colin  wrote:
>
> Thank you. In that case I will happily stick with `in`.
>
>
>
> On Monday, October 26, 2015 at 8:43:22 PM UTC, Alireza Nejati wrote:
>
> There is no difference, as far as I know.
>
>  
>
> '=' seems to be used more for explicit ranges (i = 1:5) and 'in' seems to 
> be used more for variables (i in mylist). But using 'in' for everything is 
> ok too.
>
>  
>
> The '=' is there for familiarity with matlab. Remember that julia's syntax 
> was in part designed to be familiar to matlab users.
>
>
> On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:
>
> Hi All
>
>  
>
> I have got a stupid question:
>
>  
>
> Are there any difference in "for i in 1:5" and "for i = 1:5"?
>
>  
>
> Does the julia community prefer one to the other? I see use of both in the 
> documentations and source code.
>
>  
>
> Personally I haven't seen much use of "for i = 1:5" in other languages.
>
>  
>
> Thanks.
>
>  
>
>  
>
>  
>
>  
>


Re: [julia-users] Re: For loop = or in?

2015-10-27 Thread J Luis
Please, leave the '=' alone. It's very well as is.

terça-feira, 27 de Outubro de 2015 às 18:20:19 UTC, FANG Colin escreveu:
>
> Julia tries to attract people from Python & R, which use `in`. As for 
> matlab, it is not a direct competitor.
>
> Anyway, I think we only need 1 of the 2. "There should be one-- and 
> preferably only one --obvious way to do it."
>
> Maybe enhance the documentation for the time being.
>
>
> On 27 October 2015 at 16:38, Glen O > 
> wrote:
>
>> "When calculating a Fibonacci number, we have to apply 
>> F_n=F_(n-1)+F_(n-2) repeatedly. So to find F_6, we apply the equation for n 
>> equals 3 through 6". Writing it as "for n in 3 through 6" or "for n in the 
>> range 3 through 6" wouldn't make nearly as much sense.
>>
>> As I said, for general iterables, like vectors, the "in" keyword makes 
>> more sense. But when you're talking about a counter variable, equals makes 
>> a much more natural expression - you're not really constructing the range 
>> object, you're just telling the program you want the counter to start at 
>> the first value, and increment until it reaches the second value.
>>
>> On Wednesday, 28 October 2015 02:23:54 UTC+10, Tom Breloff wrote:
>>>
>>> It definitely makes sense for a range.
>>>
>>>
>>> Sorry... gotta disagree... mathematical set notation is more 
>>> appropriate, especially for scientific computing.  This is coming from a 
>>> former matlab user, btw, so it's not like I was confused by the syntax.   
>>> The "for i = 1:5" syntax is actually more reminiscent of C:  "for (int i=1; 
>>> i<=5; i++)", and I'm guessing that the syntax originated more from that 
>>> rather than scientific concepts.
>>>
>>> On Tue, Oct 27, 2015 at 11:58 AM, feza  wrote:
>>>
 +1 @Tom Breloff .  
 I was confused about this when starting out. Comparing   `for i in 
 1:3` vs  `for i = 1:3`, even though I regularly use matlab if you think 
 about it for `i = 1:10` doesn't really make a lot of sense. It would be 
 nice if it was just one way as opposed to the confusion about whether = or 
 in should be used.

 On Tuesday, October 27, 2015 at 10:26:44 AM UTC-4, Tom Breloff wrote:
>
> It's harmless, sure, but I would prefer that everyone uses "in" 
> exclusively so that there's one less thing to waste brainpower on.  You 
> don't say "for each x equals the range 1 to n", you say "for each x in 
> the 
> range 1 to n".  I don't think "=" has a place here at all except to allow 
> copy/pasting of Matlab code (which creates other performance problems 
> anyways).
>
> On Tue, Oct 27, 2015 at 10:04 AM, Stefan Karpinski <
> ste...@karpinski.org> wrote:
>
>> My general approach is to only use = when the RHS is an explicit 
>> range, as in `for i = 1:n`. For everything else I use `for i in v`. I 
>> would 
>> be ok with dropping the = syntax at some point, but it seems pretty 
>> harmless to have it.
>>
>> On Tue, Oct 27, 2015 at 8:56 AM, FANG Colin  
>> wrote:
>>
>>> Thank you. In that case I will happily stick with `in`.
>>>
>>>
>>> On Monday, October 26, 2015 at 8:43:22 PM UTC, Alireza Nejati wrote:

 There is no difference, as far as I know.

 '=' seems to be used more for explicit ranges (i = 1:5) and 'in' 
 seems to be used more for variables (i in mylist). But using 'in' for 
 everything is ok too.

 The '=' is there for familiarity with matlab. Remember that julia's 
 syntax was in part designed to be familiar to matlab users.

 On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:
>
> Hi All
>
> I have got a stupid question:
>
> Are there any difference in "for i in 1:5" and "for i = 1:5"?
>
> Does the julia community prefer one to the other? I see use of 
> both in the documentations and source code.
>
> Personally I haven't seen much use of "for i = 1:5" in other 
> languages.
>
> Thanks.
>

>>
>
>>>
>

RE: [julia-users] Re: For loop = or in?

2015-10-27 Thread David Anthoff
If something like this were to change, it would be good to do it sooner rather 
than later -> less code that depends on the syntax that would go would have 
been written. So maybe the right way forward for this is to open an issue 
suggesting to drop the = variant, discuss it, make a decision and then live 
with it, all for the 0.5 cycle.

 

I don’t feel strongly about this, but for what it’s worth, I’m also a fan of 
having only one way to do something like this.

 

Cheers,

David 

 

From: julia-users@googlegroups.com [mailto:julia-users@googlegroups.com] On 
Behalf Of FANG Colin
Sent: Tuesday, October 27, 2015 11:20 AM
To: julia-users@googlegroups.com
Subject: Re: [julia-users] Re: For loop = or in?

 

Julia tries to attract people from Python & R, which use `in`. As for matlab, 
it is not a direct competitor.

 

Anyway, I think we only need 1 of the 2. "There should be one-- and preferably 
only one --obvious way to do it."

 

Maybe enhance the documentation for the time being.

 

 

On 27 October 2015 at 16:38, Glen O mailto:gjo1...@gmail.com> > wrote:

"When calculating a Fibonacci number, we have to apply F_n=F_(n-1)+F_(n-2) 
repeatedly. So to find F_6, we apply the equation for n equals 3 through 6". 
Writing it as "for n in 3 through 6" or "for n in the range 3 through 6" 
wouldn't make nearly as much sense.

 

As I said, for general iterables, like vectors, the "in" keyword makes more 
sense. But when you're talking about a counter variable, equals makes a much 
more natural expression - you're not really constructing the range object, 
you're just telling the program you want the counter to start at the first 
value, and increment until it reaches the second value.

On Wednesday, 28 October 2015 02:23:54 UTC+10, Tom Breloff wrote:

It definitely makes sense for a range.

 

Sorry... gotta disagree... mathematical set notation is more appropriate, 
especially for scientific computing.  This is coming from a former matlab user, 
btw, so it's not like I was confused by the syntax.   The "for i = 1:5" syntax 
is actually more reminiscent of C:  "for (int i=1; i<=5; i++)", and I'm 
guessing that the syntax originated more from that rather than scientific 
concepts.

 

On Tue, Oct 27, 2015 at 11:58 AM, feza mailto:moham...@gmail.com> > wrote:

+1 @Tom Breloff .  
I was confused about this when starting out. Comparing   `for i in 1:3` vs  
`for i = 1:3`, even though I regularly use matlab if you think about it for `i 
= 1:10` doesn't really make a lot of sense. It would be nice if it was just one 
way as opposed to the confusion about whether = or in should be used.

On Tuesday, October 27, 2015 at 10:26:44 AM UTC-4, Tom Breloff wrote:

It's harmless, sure, but I would prefer that everyone uses "in" exclusively so 
that there's one less thing to waste brainpower on.  You don't say "for each x 
equals the range 1 to n", you say "for each x in the range 1 to n".  I don't 
think "=" has a place here at all except to allow copy/pasting of Matlab code 
(which creates other performance problems anyways).

 

On Tue, Oct 27, 2015 at 10:04 AM, Stefan Karpinski mailto:ste...@karpinski.org> > wrote:

My general approach is to only use = when the RHS is an explicit range, as in 
`for i = 1:n`. For everything else I use `for i in v`. I would be ok with 
dropping the = syntax at some point, but it seems pretty harmless to have it.

 

On Tue, Oct 27, 2015 at 8:56 AM, FANG Colin mailto:coli...@gmail.com> > wrote:

Thank you. In that case I will happily stick with `in`.



On Monday, October 26, 2015 at 8:43:22 PM UTC, Alireza Nejati wrote:

There is no difference, as far as I know.

 

'=' seems to be used more for explicit ranges (i = 1:5) and 'in' seems to be 
used more for variables (i in mylist). But using 'in' for everything is ok too.

 

The '=' is there for familiarity with matlab. Remember that julia's syntax was 
in part designed to be familiar to matlab users.


On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:

Hi All

 

I have got a stupid question:

 

Are there any difference in "for i in 1:5" and "for i = 1:5"?

 

Does the julia community prefer one to the other? I see use of both in the 
documentations and source code.

 

Personally I haven't seen much use of "for i = 1:5" in other languages.

 

Thanks.

 

 

 

 



Re: [julia-users] Re: For loop = or in?

2015-10-27 Thread FANG Colin
Julia tries to attract people from Python & R, which use `in`. As for
matlab, it is not a direct competitor.

Anyway, I think we only need 1 of the 2. "There should be one-- and
preferably only one --obvious way to do it."

Maybe enhance the documentation for the time being.


On 27 October 2015 at 16:38, Glen O  wrote:

> "When calculating a Fibonacci number, we have to apply F_n=F_(n-1)+F_(n-2)
> repeatedly. So to find F_6, we apply the equation for n equals 3 through
> 6". Writing it as "for n in 3 through 6" or "for n in the range 3 through
> 6" wouldn't make nearly as much sense.
>
> As I said, for general iterables, like vectors, the "in" keyword makes
> more sense. But when you're talking about a counter variable, equals makes
> a much more natural expression - you're not really constructing the range
> object, you're just telling the program you want the counter to start at
> the first value, and increment until it reaches the second value.
>
> On Wednesday, 28 October 2015 02:23:54 UTC+10, Tom Breloff wrote:
>>
>> It definitely makes sense for a range.
>>
>>
>> Sorry... gotta disagree... mathematical set notation is more appropriate,
>> especially for scientific computing.  This is coming from a former matlab
>> user, btw, so it's not like I was confused by the syntax.   The "for i =
>> 1:5" syntax is actually more reminiscent of C:  "for (int i=1; i<=5; i++)",
>> and I'm guessing that the syntax originated more from that rather than
>> scientific concepts.
>>
>> On Tue, Oct 27, 2015 at 11:58 AM, feza  wrote:
>>
>>> +1 @Tom Breloff .
>>> I was confused about this when starting out. Comparing   `for i in
>>> 1:3` vs  `for i = 1:3`, even though I regularly use matlab if you think
>>> about it for `i = 1:10` doesn't really make a lot of sense. It would be
>>> nice if it was just one way as opposed to the confusion about whether = or
>>> in should be used.
>>>
>>> On Tuesday, October 27, 2015 at 10:26:44 AM UTC-4, Tom Breloff wrote:

 It's harmless, sure, but I would prefer that everyone uses "in"
 exclusively so that there's one less thing to waste brainpower on.  You
 don't say "for each x equals the range 1 to n", you say "for each x in the
 range 1 to n".  I don't think "=" has a place here at all except to allow
 copy/pasting of Matlab code (which creates other performance problems
 anyways).

 On Tue, Oct 27, 2015 at 10:04 AM, Stefan Karpinski <
 ste...@karpinski.org> wrote:

> My general approach is to only use = when the RHS is an explicit
> range, as in `for i = 1:n`. For everything else I use `for i in v`. I 
> would
> be ok with dropping the = syntax at some point, but it seems pretty
> harmless to have it.
>
> On Tue, Oct 27, 2015 at 8:56 AM, FANG Colin  wrote:
>
>> Thank you. In that case I will happily stick with `in`.
>>
>>
>> On Monday, October 26, 2015 at 8:43:22 PM UTC, Alireza Nejati wrote:
>>>
>>> There is no difference, as far as I know.
>>>
>>> '=' seems to be used more for explicit ranges (i = 1:5) and 'in'
>>> seems to be used more for variables (i in mylist). But using 'in' for
>>> everything is ok too.
>>>
>>> The '=' is there for familiarity with matlab. Remember that julia's
>>> syntax was in part designed to be familiar to matlab users.
>>>
>>> On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:

 Hi All

 I have got a stupid question:

 Are there any difference in "for i in 1:5" and "for i = 1:5"?

 Does the julia community prefer one to the other? I see use of both
 in the documentations and source code.

 Personally I haven't seen much use of "for i = 1:5" in other
 languages.

 Thanks.

>>>
>

>>


Re: [julia-users] Re: For loop = or in?

2015-10-27 Thread Glen O
"When calculating a Fibonacci number, we have to apply F_n=F_(n-1)+F_(n-2) 
repeatedly. So to find F_6, we apply the equation for n equals 3 through 
6". Writing it as "for n in 3 through 6" or "for n in the range 3 through 
6" wouldn't make nearly as much sense.

As I said, for general iterables, like vectors, the "in" keyword makes more 
sense. But when you're talking about a counter variable, equals makes a 
much more natural expression - you're not really constructing the range 
object, you're just telling the program you want the counter to start at 
the first value, and increment until it reaches the second value.

On Wednesday, 28 October 2015 02:23:54 UTC+10, Tom Breloff wrote:
>
> It definitely makes sense for a range.
>
>
> Sorry... gotta disagree... mathematical set notation is more appropriate, 
> especially for scientific computing.  This is coming from a former matlab 
> user, btw, so it's not like I was confused by the syntax.   The "for i = 
> 1:5" syntax is actually more reminiscent of C:  "for (int i=1; i<=5; i++)", 
> and I'm guessing that the syntax originated more from that rather than 
> scientific concepts.
>
> On Tue, Oct 27, 2015 at 11:58 AM, feza > 
> wrote:
>
>> +1 @Tom Breloff .  
>> I was confused about this when starting out. Comparing   `for i in 
>> 1:3` vs  `for i = 1:3`, even though I regularly use matlab if you think 
>> about it for `i = 1:10` doesn't really make a lot of sense. It would be 
>> nice if it was just one way as opposed to the confusion about whether = or 
>> in should be used.
>>
>> On Tuesday, October 27, 2015 at 10:26:44 AM UTC-4, Tom Breloff wrote:
>>>
>>> It's harmless, sure, but I would prefer that everyone uses "in" 
>>> exclusively so that there's one less thing to waste brainpower on.  You 
>>> don't say "for each x equals the range 1 to n", you say "for each x in the 
>>> range 1 to n".  I don't think "=" has a place here at all except to allow 
>>> copy/pasting of Matlab code (which creates other performance problems 
>>> anyways).
>>>
>>> On Tue, Oct 27, 2015 at 10:04 AM, Stefan Karpinski >> > wrote:
>>>
 My general approach is to only use = when the RHS is an explicit range, 
 as in `for i = 1:n`. For everything else I use `for i in v`. I would be ok 
 with dropping the = syntax at some point, but it seems pretty harmless to 
 have it.

 On Tue, Oct 27, 2015 at 8:56 AM, FANG Colin  wrote:

> Thank you. In that case I will happily stick with `in`.
>
>
> On Monday, October 26, 2015 at 8:43:22 PM UTC, Alireza Nejati wrote:
>>
>> There is no difference, as far as I know.
>>
>> '=' seems to be used more for explicit ranges (i = 1:5) and 'in' 
>> seems to be used more for variables (i in mylist). But using 'in' for 
>> everything is ok too.
>>
>> The '=' is there for familiarity with matlab. Remember that julia's 
>> syntax was in part designed to be familiar to matlab users.
>>
>> On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:
>>>
>>> Hi All
>>>
>>> I have got a stupid question:
>>>
>>> Are there any difference in "for i in 1:5" and "for i = 1:5"?
>>>
>>> Does the julia community prefer one to the other? I see use of both 
>>> in the documentations and source code.
>>>
>>> Personally I haven't seen much use of "for i = 1:5" in other 
>>> languages.
>>>
>>> Thanks.
>>>
>>

>>>
>

Re: [julia-users] Re: For loop = or in?

2015-10-27 Thread Tom Breloff
>
> It definitely makes sense for a range.


Sorry... gotta disagree... mathematical set notation is more appropriate,
especially for scientific computing.  This is coming from a former matlab
user, btw, so it's not like I was confused by the syntax.   The "for i =
1:5" syntax is actually more reminiscent of C:  "for (int i=1; i<=5; i++)",
and I'm guessing that the syntax originated more from that rather than
scientific concepts.

On Tue, Oct 27, 2015 at 11:58 AM, feza  wrote:

> +1 @Tom Breloff .
> I was confused about this when starting out. Comparing   `for i in 1:3` vs
>  `for i = 1:3`, even though I regularly use matlab if you think about it
> for `i = 1:10` doesn't really make a lot of sense. It would be nice if it
> was just one way as opposed to the confusion about whether = or in should
> be used.
>
> On Tuesday, October 27, 2015 at 10:26:44 AM UTC-4, Tom Breloff wrote:
>>
>> It's harmless, sure, but I would prefer that everyone uses "in"
>> exclusively so that there's one less thing to waste brainpower on.  You
>> don't say "for each x equals the range 1 to n", you say "for each x in the
>> range 1 to n".  I don't think "=" has a place here at all except to allow
>> copy/pasting of Matlab code (which creates other performance problems
>> anyways).
>>
>> On Tue, Oct 27, 2015 at 10:04 AM, Stefan Karpinski 
>> wrote:
>>
>>> My general approach is to only use = when the RHS is an explicit range,
>>> as in `for i = 1:n`. For everything else I use `for i in v`. I would be ok
>>> with dropping the = syntax at some point, but it seems pretty harmless to
>>> have it.
>>>
>>> On Tue, Oct 27, 2015 at 8:56 AM, FANG Colin  wrote:
>>>
 Thank you. In that case I will happily stick with `in`.


 On Monday, October 26, 2015 at 8:43:22 PM UTC, Alireza Nejati wrote:
>
> There is no difference, as far as I know.
>
> '=' seems to be used more for explicit ranges (i = 1:5) and 'in' seems
> to be used more for variables (i in mylist). But using 'in' for everything
> is ok too.
>
> The '=' is there for familiarity with matlab. Remember that julia's
> syntax was in part designed to be familiar to matlab users.
>
> On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:
>>
>> Hi All
>>
>> I have got a stupid question:
>>
>> Are there any difference in "for i in 1:5" and "for i = 1:5"?
>>
>> Does the julia community prefer one to the other? I see use of both
>> in the documentations and source code.
>>
>> Personally I haven't seen much use of "for i = 1:5" in other
>> languages.
>>
>> Thanks.
>>
>
>>>
>>


Re: [julia-users] Re: For loop = or in?

2015-10-27 Thread feza
+1 @Tom Breloff .  
I was confused about this when starting out. Comparing   `for i in 1:3` vs 
 `for i = 1:3`, even though I regularly use matlab if you think about it 
for `i = 1:10` doesn't really make a lot of sense. It would be nice if it 
was just one way as opposed to the confusion about whether = or in should 
be used.

On Tuesday, October 27, 2015 at 10:26:44 AM UTC-4, Tom Breloff wrote:
>
> It's harmless, sure, but I would prefer that everyone uses "in" 
> exclusively so that there's one less thing to waste brainpower on.  You 
> don't say "for each x equals the range 1 to n", you say "for each x in the 
> range 1 to n".  I don't think "=" has a place here at all except to allow 
> copy/pasting of Matlab code (which creates other performance problems 
> anyways).
>
> On Tue, Oct 27, 2015 at 10:04 AM, Stefan Karpinski  > wrote:
>
>> My general approach is to only use = when the RHS is an explicit range, 
>> as in `for i = 1:n`. For everything else I use `for i in v`. I would be ok 
>> with dropping the = syntax at some point, but it seems pretty harmless to 
>> have it.
>>
>> On Tue, Oct 27, 2015 at 8:56 AM, FANG Colin > > wrote:
>>
>>> Thank you. In that case I will happily stick with `in`.
>>>
>>>
>>> On Monday, October 26, 2015 at 8:43:22 PM UTC, Alireza Nejati wrote:

 There is no difference, as far as I know.

 '=' seems to be used more for explicit ranges (i = 1:5) and 'in' seems 
 to be used more for variables (i in mylist). But using 'in' for everything 
 is ok too.

 The '=' is there for familiarity with matlab. Remember that julia's 
 syntax was in part designed to be familiar to matlab users.

 On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:
>
> Hi All
>
> I have got a stupid question:
>
> Are there any difference in "for i in 1:5" and "for i = 1:5"?
>
> Does the julia community prefer one to the other? I see use of both in 
> the documentations and source code.
>
> Personally I haven't seen much use of "for i = 1:5" in other 
> languages.
>
> Thanks.
>

>>
>

Re: [julia-users] Re: For loop = or in?

2015-10-27 Thread Glen O
An alternative way to read it is "for x equals 1 through 5". It definitely 
makes sense for a range. And I don't think anyone has any difficulty 
intuitively understanding a for loop using =, even if "in" reads slightly 
better.

Incidentally, it's not just Matlab that does it. Most variants of Basic use 
it, as does Delphi, Fortran, Lua, Pascal, and Scilab. One thing you might 
notice about most of the languages on the list is that they're languages 
that were more oriented towards scientific computing, or languages designed 
to teach programming concepts. It's a more intuitive notation when applied 
to basic for loops (that is, where the variable is simply being incremented 
a fixed number of times), with "in" really being of use when you want to 
iterate over a data structure, rather than to iterate with a counting 
variable.

I agree with Stefan's approach of using "=" for explicit ranges (which 
represent the phrasing "for x equals 1 through 5") and "in" for application 
to other structures ("for each x in the vector A"), with the other notation 
being usable but somewhat discouraged. Besides, it's not like there's any 
other natural use for = in that context.

Incidentally, it would be nice if ∈ could be used as another option - it's 
just another way of saying "in", but it would look nicer in certain 
mathematical contexts, and it's not like the symbol would be used in 
another way in that position.

On Wednesday, 28 October 2015 00:26:44 UTC+10, Tom Breloff wrote:
>
> It's harmless, sure, but I would prefer that everyone uses "in" 
> exclusively so that there's one less thing to waste brainpower on.  You 
> don't say "for each x equals the range 1 to n", you say "for each x in the 
> range 1 to n".  I don't think "=" has a place here at all except to allow 
> copy/pasting of Matlab code (which creates other performance problems 
> anyways).
>
> On Tue, Oct 27, 2015 at 10:04 AM, Stefan Karpinski  > wrote:
>
>> My general approach is to only use = when the RHS is an explicit range, 
>> as in `for i = 1:n`. For everything else I use `for i in v`. I would be ok 
>> with dropping the = syntax at some point, but it seems pretty harmless to 
>> have it.
>>
>> On Tue, Oct 27, 2015 at 8:56 AM, FANG Colin > > wrote:
>>
>>> Thank you. In that case I will happily stick with `in`.
>>>
>>>
>>> On Monday, October 26, 2015 at 8:43:22 PM UTC, Alireza Nejati wrote:

 There is no difference, as far as I know.

 '=' seems to be used more for explicit ranges (i = 1:5) and 'in' seems 
 to be used more for variables (i in mylist). But using 'in' for everything 
 is ok too.

 The '=' is there for familiarity with matlab. Remember that julia's 
 syntax was in part designed to be familiar to matlab users.

 On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:
>
> Hi All
>
> I have got a stupid question:
>
> Are there any difference in "for i in 1:5" and "for i = 1:5"?
>
> Does the julia community prefer one to the other? I see use of both in 
> the documentations and source code.
>
> Personally I haven't seen much use of "for i = 1:5" in other 
> languages.
>
> Thanks.
>

>>
>

Re: [julia-users] Re: For loop = or in?

2015-10-27 Thread Tom Breloff
It's harmless, sure, but I would prefer that everyone uses "in" exclusively
so that there's one less thing to waste brainpower on.  You don't say "for
each x equals the range 1 to n", you say "for each x in the range 1 to n".
I don't think "=" has a place here at all except to allow copy/pasting of
Matlab code (which creates other performance problems anyways).

On Tue, Oct 27, 2015 at 10:04 AM, Stefan Karpinski 
wrote:

> My general approach is to only use = when the RHS is an explicit range, as
> in `for i = 1:n`. For everything else I use `for i in v`. I would be ok
> with dropping the = syntax at some point, but it seems pretty harmless to
> have it.
>
> On Tue, Oct 27, 2015 at 8:56 AM, FANG Colin  wrote:
>
>> Thank you. In that case I will happily stick with `in`.
>>
>>
>> On Monday, October 26, 2015 at 8:43:22 PM UTC, Alireza Nejati wrote:
>>>
>>> There is no difference, as far as I know.
>>>
>>> '=' seems to be used more for explicit ranges (i = 1:5) and 'in' seems
>>> to be used more for variables (i in mylist). But using 'in' for everything
>>> is ok too.
>>>
>>> The '=' is there for familiarity with matlab. Remember that julia's
>>> syntax was in part designed to be familiar to matlab users.
>>>
>>> On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:

 Hi All

 I have got a stupid question:

 Are there any difference in "for i in 1:5" and "for i = 1:5"?

 Does the julia community prefer one to the other? I see use of both in
 the documentations and source code.

 Personally I haven't seen much use of "for i = 1:5" in other languages.

 Thanks.

>>>
>


Re: [julia-users] Re: For loop = or in?

2015-10-27 Thread Stefan Karpinski
My general approach is to only use = when the RHS is an explicit range, as
in `for i = 1:n`. For everything else I use `for i in v`. I would be ok
with dropping the = syntax at some point, but it seems pretty harmless to
have it.

On Tue, Oct 27, 2015 at 8:56 AM, FANG Colin  wrote:

> Thank you. In that case I will happily stick with `in`.
>
>
> On Monday, October 26, 2015 at 8:43:22 PM UTC, Alireza Nejati wrote:
>>
>> There is no difference, as far as I know.
>>
>> '=' seems to be used more for explicit ranges (i = 1:5) and 'in' seems to
>> be used more for variables (i in mylist). But using 'in' for everything is
>> ok too.
>>
>> The '=' is there for familiarity with matlab. Remember that julia's
>> syntax was in part designed to be familiar to matlab users.
>>
>> On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:
>>>
>>> Hi All
>>>
>>> I have got a stupid question:
>>>
>>> Are there any difference in "for i in 1:5" and "for i = 1:5"?
>>>
>>> Does the julia community prefer one to the other? I see use of both in
>>> the documentations and source code.
>>>
>>> Personally I haven't seen much use of "for i = 1:5" in other languages.
>>>
>>> Thanks.
>>>
>>


[julia-users] Re: For loop = or in?

2015-10-27 Thread FANG Colin
Thank you. In that case I will happily stick with `in`.

On Monday, October 26, 2015 at 8:43:22 PM UTC, Alireza Nejati wrote:
>
> There is no difference, as far as I know.
>
> '=' seems to be used more for explicit ranges (i = 1:5) and 'in' seems to 
> be used more for variables (i in mylist). But using 'in' for everything is 
> ok too.
>
> The '=' is there for familiarity with matlab. Remember that julia's syntax 
> was in part designed to be familiar to matlab users.
>
> On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:
>>
>> Hi All
>>
>> I have got a stupid question:
>>
>> Are there any difference in "for i in 1:5" and "for i = 1:5"?
>>
>> Does the julia community prefer one to the other? I see use of both in 
>> the documentations and source code.
>>
>> Personally I haven't seen much use of "for i = 1:5" in other languages.
>>
>> Thanks.
>>
>

[julia-users] Re: For loop = or in?

2015-10-26 Thread Alireza Nejati
There is no difference, as far as I know.

'=' seems to be used more for explicit ranges (i = 1:5) and 'in' seems to 
be used more for variables (i in mylist). But using 'in' for everything is 
ok too.

The '=' is there for familiarity with matlab. Remember that julia's syntax 
was in part designed to be familiar to matlab users.

On Tuesday, October 27, 2015 at 8:26:07 AM UTC+13, FANG Colin wrote:
>
> Hi All
>
> I have got a stupid question:
>
> Are there any difference in "for i in 1:5" and "for i = 1:5"?
>
> Does the julia community prefer one to the other? I see use of both in the 
> documentations and source code.
>
> Personally I haven't seen much use of "for i = 1:5" in other languages.
>
> Thanks.
>