So that is the hacky way that you can do this. Not sure if it's a good idea
– it's possible that it will be crashy to do that, especially if you're
going to replace the method and then call it.
On Tue, Jun 30, 2015 at 6:08 PM, Yichao Yu wrote:
> On Tue, Jun 30, 2015 at 5:50 PM, Stefan Karpinski
On Tue, Jun 30, 2015 at 5:50 PM, Stefan Karpinski wrote:
> A good approach to that specific issue would be for us to provide hooks into
> srand, allowing other packages to register callbacks with the same
> signature. As to the original question, while you can pull individual
> methods out of gene
A good approach to that specific issue would be for us to provide hooks
into srand, allowing other packages to register callbacks with the same
signature. As to the original question, while you can pull individual
methods out of generic functions, you can't call them, so there's no way to
do this c
Thanks! I guess my rand() example was not a good example. The actual use
case was trying to get srand to set the seed for the gpu as well as the
cpu. I thought if I could override the srand function (so the user does
not need to remember a new name), and have it call the original srand as
well a
Overwriting methods in Base is a bad idea. This will affect all usages of
the function, not just the ones in your module. You can have your own
function called rand() instead.
On Tue, Jun 30, 2015 at 3:43 PM, Matt Bauman wrote:
> Note the warning message you get upon trying to define Base.rand()
Note the warning message you get upon trying to define Base.rand():
Warning: Method definition rand() in module Random at random.jl:195
overwritten in module Main at none:1
You're not shadowing rand; you're totally overwriting one of its main
methods. I agree with Tom that you should probably
My gut reaction is that you should not even try to do this. Here's other
options:
# recommended
myrand() = rand() + 1
# if you really need to use rand
immutable MyUselessType end
Base.rand(::Type{MyUselessType}) = rand() + 1
What's your use case that you feel you need to do this? You get into