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

Comments

7 participants
@mbauman
Copy link
Member

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
@mschauer

This comment has been minimized.

Copy link
Contributor

commented Oct 23, 2018

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 modified the milestones: 1.x, 1.1 Oct 23, 2018

@Keno

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member

commented Oct 25, 2018

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member

commented Oct 26, 2018

Ah yes, see #17305.

@JeffBezanson

This comment has been minimized.

Copy link
Member

commented Oct 29, 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

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 was marked as off-topic.

Copy link

commented Nov 3, 2018

I am a novice to Julia. I started out with the documentation and the first echo command in it. What is the fix? Please help.

julia> julia -e 'println(PROGRAM_FILE); for x in ARGS; println(x); end' foo bar
ERROR: syntax: space not allowed before "'"

@mbauman

This comment has been minimized.

Copy link
Member Author

commented Nov 3, 2018

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

@JeffBezanson JeffBezanson self-assigned this Nov 28, 2018

JeffBezanson added a commit that referenced this issue Nov 28, 2018

JeffBezanson added a commit that referenced this issue Nov 29, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.