On 7 July 2015 at 04:12, Ismael VC <[email protected]> wrote:
>
> Couldn't we just get a warning and let people shoot themselves in their foot
> if that's what they want?
>
> Something like:
>
> Warning: Using private method/type in module Foo at foo.jl:n.
I like that you are trying to find some middle ground. But if I am
doing this intentionally the warning will be a constant annoyance, so,
how should I silence it? Yet another command line option so that we
approach gcc/clang with different levels of warnings? Yuck...
Annotations (@silence?) like Java? Double yuck...
Giving users this level of power is something that I am happy with.
Last week it allowed me to add temporarily add a function looking deep
into a composite type from a library when debugging. Sure, it can be
abused, but it can equally well be used properly when necessary.
Sure, it may break, but ultimately it is always up to the caller not
to violate the API. Sure, sometimes base violates this idiom, but
this is most likely due to historic reasons and a lack of a consensus
more than anything else.
In the future, given enough experience and evidence to the contrary, I
would be happy to reconsider my position. But for now, using idioms
like the one below, is how I write my Julia code.
export Weights, W, b, fanin, fanout
immutable Weights{T<:FloatingPoint}
W::Matrix{T}
b::Vector{T}
end
Weights(fanin, fanout) = Weights(rand(fanout, fanin)./1024, zeros(fanout))
W(w) = w.w
b(w) = w.b
fanin(w) = size(W(w), 2)
fanout(w) = size(W(w), 1)
Apologies for the terribly short variable names, it is an example after all.
Pontus