Hello colleauges,
On Wednesday, July 23, 2014 6:18:03 PM UTC+2, Stefan Karpinski wrote:
>
> On Wed, Jul 23, 2014 at 6:06 AM, Andreas Lobinger <[email protected]
> <javascript:>> wrote:
>
>>
>> In principle i agree, everything that is defined in the Modules is usable
>> regarding its own namespace. But then, why do we have the export of
>> functions? It's not even needed...
>> If you strictly prefix all functions by their module everything will be
>> alright, but what in mixed environments?
>>
>
> You can just do `import Gadfly` and `import Gtk` and then use everything
> via prefixes like `Gadfly.plot`. I suspect this will be unpopular for
> interactive work, however.
>
>
>> The point i'm trying to make is: The current situation - not merging the
>> functions/methods - creates a dependency between Modules/Packages. Is this
>> the intended work style?
>>
>
> Merging functions is definitely not a good solution. In issue #4345
> <https://github.com/JuliaLang/julia/issues/4345> I proposed that clashing
> names be dropped entirely, forcing the programmer to pick which name they
> meant explicitly. That would make the order that using statements occur
> insignificant, at least in this regard.
>
>
I read the #4345 and find also there some messages in favour of merging.
I'm not really into the terminology what is a method and what is a
function, i tried to make my point from the perspective of usability (and
ease of development).
btw (side effects)...
lobi@maroon:~/juliarepo$ ../julia/julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "help()" to list help topics
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.3.0-rc1+116 (2014-07-21 15:59 UTC)
_/ |\__'_|_|_|\__'_| | Commit e75595f* (3 days old master)
|__/ | i686-linux-gnu
julia> using Gtk
julia> type bVector
b::Int32
end
julia> function draw(v::bVector)
print(v);
end
draw (generic function with 1 method)
julia>
lobi@maroon:~/juliarepo$ ../julia/julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "help()" to list help topics
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.3.0-rc1+116 (2014-07-21 15:59 UTC)
_/ |\__'_|_|_|\__'_| | Commit e75595f* (3 days old master)
|__/ | i686-linux-gnu
julia> using Gtk
julia> methods(draw)
# 3 methods for generic function "draw":
draw(redraw::Function,widget::GtkCanvas) at
/home/lobi/.julia/v0.3/Gtk/src/cairo.jl:56
draw(widget::GtkCanvas) at /home/lobi/.julia/v0.3/Gtk/src/cairo.jl:61
draw(widget::GtkCanvas,immediate::Bool) at
/home/lobi/.julia/v0.3/Gtk/src/cairo.jl:61
julia> type bVector
b::Int32
end
julia> function draw(v::bVector)
print(v);
end
ERROR: error in method definition: function Gtk.draw must be explicitly
imported to be extended
...
I find the situation of developers of modules/packages to organize which
english words (maybe unicode can help here...) to use in exported
functions, well, complicated, because the 'good ones' are already taken
(plot, draw, paint, render, update, show, calc, derive, optimize etc.) and
only the non-obvious verbs are 'free' (unless taken). And for some time i
was under the impression, that multiple dispatch helps here, because there
would be a draw(::thisType) and a draw(::thatType) and a
draw(::somethingCompletelyDifferentType) and the propability that types are
named conflicting i rate lower.
There might be something complicated in the technical background, but from
a commandline perspective: i can merge functions in the same module (Main),
why can't i across modules?