Is it considered bad practice to reexport a few symbols from a stdlib module from your module if the intent is to provide the full API in your module and not leak implementation details?
is it exported from the stdlib already?
Yes, in this case, just LinearAlgebra.norm
then I'd say it's fine, as long as you don't inadvertently create a naming conflict
Everyone does it, but I would recommend against it -- by exporting the name like that you take on responsibility for that function. For example, if you export LinearAlgebra.norm
, then my code will work without loading LinearAlgebra
myself. This is fine until LinearAlgebra.norm
changes behavior and my code breaks.
That makes sense, and it is one of my pet peeves with Lisp. I don't even know why I am asking now that I realize Julia doesn't have any provisions for shadowing symbols, only bindings.
In Lisp I would just shadow the original symbol, but symbols are not interned into separate module lookup table namespaces like they are in Lisp.
So I will refrain from doing that.
Fredrik Ekre said:
Everyone does it, but I would recommend against it -- by exporting the name like that you take on responsibility for that function. For example, if you export
LinearAlgebra.norm
, then my code will work without loadingLinearAlgebra
myself. This is fine untilLinearAlgebra.norm
changes behavior and my code breaks.
Hadn't thought about it much, but now that you mention it I think I only ever reexport from another package when I control both packages
Michael Fiano has marked this topic as resolved.
Last updated: Nov 22 2024 at 04:41 UTC