Generally it's not a different syntax, and the error generated here is
probably a consequence of recent parser changes to handle dot-operator
overloading (and should probably be reported as a bug, and possibly fixed.)

The syntax I suggested is related (I think) to the fact that some operators
need parentheses around them in order to define functions for them:

julia> &(a) = "hi"
ERROR: syntax: invalid assignment location

julia> (&)(a) = "hi"
WARNING: module Main should explicitly import & from Base
& (generic function with 36 methods)

But I agree that it's inconsistent with parsing elsewhere. It would
probably be best to deprecate `import Base.xxx` in favor of `import Base:
xxx` (i.e., removing `import Base.(!)`)

(An early conversation about operator functions needing parentheses is here
<https://groups.google.com/d/msg/julia-users/n0X7bSUlye0/Rz_QXz1ufaYJ>.)

Cheers,
   Kevin

On Mon, Aug 8, 2016 at 9:59 PM, Fengyang Wang <[email protected]>
wrote:

> On Monday, August 8, 2016 at 10:26:46 AM UTC-4, Kevin Squire wrote:
>>
>> Try
>>
>>   import Base.(!)
>>
>> Cheers,
>>   Kevin
>>
>
> Why do import statements have different syntax? This syntax, I'm pretty
> sure, has either meant getfield or broadcast—in neither case does it
> actually refer to the ! function.
>

Reply via email to