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.

Reply via email to