Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spaces are allowed in broadcast calls f. () #29781

Closed
mbauman opened this issue Oct 23, 2018 · 8 comments
Closed

Spaces are allowed in broadcast calls f. () #29781

mbauman opened this issue Oct 23, 2018 · 8 comments
Assignees
Labels
domain:broadcast Applying a function over a collection kind:minor change Marginal behavior change acceptable for a minor release parser Language parsing and surface syntax
Milestone

Comments

@mbauman
Copy link
Sponsor Member

mbauman commented Oct 23, 2018

We dropped support for spaces between function names and parens in normal calls (#11891), but unfortunately the addition of dot-broadcasting brought this back!

julia> sin    (1)
ERROR: syntax: space before "(" not allowed in "sin ("

julia> sin.    (1)
0.8414709848078965
@mbauman mbauman added parser Language parsing and surface syntax domain:broadcast Applying a function over a collection labels Oct 23, 2018
@mschauer
Copy link
Contributor

There is a difference that the first disarms a trap

# Old julia
julia> [sin (1)]
1×2 Array{Any,2}:
 sin  1

julia> sin (1)
0.8414709848078965

while the second is harmless

julia> [sin. (1)]
1-element Array{Float64,1}:
 0.8414709848078965

julia> sin. (1)
0.8414709848078965

@StefanKarpinski StefanKarpinski added the kind:minor change Marginal behavior change acceptable for a minor release label Oct 23, 2018
@StefanKarpinski StefanKarpinski modified the milestones: 1.x, 1.1 Oct 23, 2018
@Keno
Copy link
Member

Keno commented Oct 25, 2018

While we're at it, let's also fix the parsing of this:

julia> sin. .
ERROR: type #sin has no field .
Stacktrace:
 [1] getproperty(::Any, ::Symbol) at ./sysimg.jl:18

@JeffBezanson
Copy link
Sponsor Member

I believe this is because we intentionally allow space after the dot in a. b. I don't remember why but I think I remember some discussion about this.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Oct 25, 2018

I'd guess it's to allow the development of future syntax concepts? Potentially something along the lines of javascript's chaining:

a.
  b().
  c().
  (broadcast!).
  d()

But also because there's no reason (ambiguity) to disallowing it, so we let people experiment.

@JeffBezanson
Copy link
Sponsor Member

Ah yes, see #17305.

@JeffBezanson
Copy link
Sponsor Member

While we're at it, let's also fix the parsing of this:

julia> sin. .
ERROR: type #sin has no field .
Stacktrace:
 [1] getproperty(::Any, ::Symbol) at ./sysimg.jl:18

Ok, I see that that could be an error, but does this cause an actual problem?

I also suppose we could allow a. b but disallow a. (b).

@shrivaa

This comment has been minimized.

@mbauman
Copy link
Sponsor Member Author

mbauman commented Nov 3, 2018

@shrivaa Please ask questions on the discourse message board. Folks will happily help you out there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:broadcast Applying a function over a collection kind:minor change Marginal behavior change acceptable for a minor release parser Language parsing and surface syntax
Projects
None yet
Development

No branches or pull requests

7 participants