In Julia 0.5, [1, 2, 3] and [1; 2; 3] do not mean the same thing – the
former does array construction while the latter does array concatenation.
These happen to produce the same result for scalars. When the elements are
collections, however, they do not:

julia> [1:3, 4:6, 7:9]
3-element Array{UnitRange{Int64},1}:
 1:3
 4:6
 7:9

julia> [1:3; 4:6; 7:9]
9-element Array{Int64,1}:
 1
 2
 3
 4
 5
 6
 7
 8
 9


Eliminating the `for i=1:10` syntax has been discussed repeatedly, but
there are situations like array comprehensions where the additional three
characters required to write `for i in 1:10` seems annoyingly verbose:

julia> [1/(i+j-1) for i=1:3, j=1:3]
3×3 Array{Float64,2}:
 1.0       0.5       0.333333
 0.5       0.333333  0.25
 0.333333  0.25      0.2

julia> [1/(i+j-1) for i in 1:3, j in 1:3]
3×3 Array{Float64,2}:
 1.0       0.5       0.333333
 0.5       0.333333  0.25
 0.333333  0.25      0.2


Regularizing this syntax just doesn't seem like a pressing matter – if you
don't like the = syntax, don't use it.

Syntax 3 is not available since it already means something:

julia> a, b, c = rand(3), rand(3), rand(3);

julia> (a, b, c) = a + b + c
3-element Array{Float64,1}:
 1.55292
 1.89841
 1.72875


As a general comment, "armchair programming language design" is not very
effective or helpful. If you want to gain credibility when it comes to
influencing the design of Julia, you should make some pull requests that
fix or improve things first. Get a feel for the language and how it is
built. By working with it, you will come to understand why things work the
way they do – there is usually a reason. If you'd attempted to change
syntaxes 1 or 3, for example, you would have quickly found that they are
not actually possible to change without significantly altering the language
and breaking lots of code.


On Fri, Jun 3, 2016 at 4:05 AM, Ford Ox <[email protected]> wrote:

> I think this deserves an own topic.
>
> *You* should post here syntax that looks like duplicate or you think it
> could use already existing keyword. (mark with* # identical *or *#
> replacement*)
> Rule of thumb - *the less special syntax the better*.
>
> # identical
> # replace ' , ' with ' ; ' in arrays ?
> [1, 2, 3, 4]
> [1; 2; 3; 4]
>
>
>
> # identical
> # replace ' = ' with ' in ' in for loops ?
> for i = 1:10
> for i in 1:10
>
>
>
>
> # replacement
> # replace ' -> ' with ' = ' in anonymous functions ?
> (a, b, c) -> a + b + c
> (a, b, c) = a + b + c
>

Reply via email to