Thanks guys. I'll try out your suggestions.

@Mauro  Base.$f does not work either.


On Thu, Mar 26, 2015 at 7:28 PM, Mike Innes <[email protected]> wrote:

> For some reason the parser doesn't like interpolating into import/export
> statements, but you can do this just fine by constructing the `Expr` object
> by hand. It's not pretty, but it works OK.
>
> You best bet is to construct expressions like `:(export foo, bar)` and
> `dump` them to see how the Expr is constructed. I think for export it's
> something like `Expr(:export, :foo, :bar)`.
>
> Example:
> https://github.com/one-more-minute/Hiccup.jl/blob/073f47314d1f08e0e5c8a958a25051248bb85039/src/Hiccup.jl#L95-L100
>
> On 26 March 2015 at 12:52, Andreas Noack <[email protected]>
> wrote:
>
>> Distributed reduce is already implemented, so maybe these slightly
>> simpler with e.g. sum(A::DArray) = reduce(Base.AddFun(), A)
>>
>> 2015-03-26 8:41 GMT-04:00 Jameson Nash <[email protected]>:
>>
>> `eval` (typically) isn't allowed to handle `import` and `export`
>>> statements. those must be written explicitly
>>>
>>> On Thu, Mar 26, 2015 at 8:18 AM Amit Murthy <[email protected]>
>>> wrote:
>>>
>>>> I was trying to add a bunch  of common functions to
>>>> DistributedArrays.jl with the below code block
>>>>
>>>> for f in [:sum, :minimum, :maximum, :mean]
>>>>     @eval begin
>>>>         import Base: ($f)
>>>>         export ($f)
>>>>         function ($f)(D::DArray)
>>>>             refs = [@spawnat p ($f)(localpart(D)) for p in procs(D)]
>>>>             ($f)([fetch(r) for r in refs])
>>>>         end
>>>>     end
>>>> end
>>>>
>>>>
>>>>
>>>> But I get an error
>>>>
>>>> ERROR: LoadError: syntax: invalid "import" statement: expected
>>>> identifier
>>>>  in include at ./boot.jl:250
>>>>  in include_from_node1 at ./loading.jl:129
>>>>  in reload_path at ./loading.jl:153
>>>>  in _require at ./loading.jl:68
>>>>  in require at ./loading.jl:51
>>>>  in process_options at ./client.jl:292
>>>>  in _start at ./client.jl:402
>>>> while loading /home/amitm/.julia/v0.4/DistributedArrays/src/
>>>> DistributedArrays.jl, in expression starting on line 497
>>>>
>>>>
>>>>
>>>> What am I doing wrong ?
>>>>
>>>>
>>
>

Reply via email to