JuliaRandom / Random123.jl

Julia implementation of Random123.
http://juliarandom.github.io/RandomNumbers.jl/stable/man/random123/
Other
18 stars 5 forks source link

Type piracy in `convert` and constructors for basic Julia types #16

Closed KristofferC closed 1 year ago

KristofferC commented 1 year ago

The stuff in https://github.com/JuliaRandom/Random123.jl/blob/195d1eeaf948280dbad1a86a9d64d92d2206ae06/src/aesni_common.jl#L7-L16 is type piracy and changes how basic Julia types behave.

You should in general do something like

struct __m128i
    data:: NTuple{2, VecElement{UInt64}}
end

and define functions on that (similar as to how e.g. SIMD.jl does it, https://github.com/eschnett/SIMD.jl/blob/863e12ffd3fc36c4d9257f5332525948d55c9a70/src/simdvec.jl#L1-L3)

sunoru commented 1 year ago

Yes you are right and thanks for pointing it out. I realized this problem once but forgot to fix it. 😢