[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [octvae forge] shadowing between packages

From: Andrew Janke
Subject: Re: [octvae forge] shadowing between packages
Date: Mon, 18 Mar 2019 09:38:09 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.5.3

On 3/18/19 3:52 AM, JuanPi wrote:
Hi Andrew,

The case is for geometry and matgeom, in particular function clipPolygon
(mercurial) https://sourceforge.net/p/octave/geometry/ci/default/tree/
(git) https://sourceforge.net/p/octave/matgeom/ci/master/tree/

Doing namespaces dynamically is hard, because it means that you have to:
a) rearrange the source files on disk to put them in a namespace before
you add them to the path, and

I am already doing this anyway. For example I am erasing functions
that shadow core functions (e.g. deg2rad), so I could slightly change
this to put all these functions into a namespace.

b) transform the code itself so function references now refer to the
namespaced function, instead of the global non-namespaced one.

ok, based on my ignorance, I thought namespace would work as the
folder private. If global is the first scope where functions are
looked for, then namespaces offer no advantages (for this case) over
the order of loading the packages, i.e. load pkg A first then pkg B to
shadow functions in pkg A, and live with the consequences...

Nope. Namespaced functions don't work like private/. Like static class methods, they are only looked for if explicitly referenced using their namespace-qualified name. (It's a bummer. There's an "import" command to deal with this, but it is scoped to functions, not files or classes, so it's not a whole lot of help.)

I don't envy you this work.

If this were me, I would beg the authors of these packages to move their functions into namespaces (providing optional global-function shims for back-compatibility).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]