[PD] declare vs. namespaces - current best practice

Christof Ressi christof.ressi at gmx.at
Tue Jan 2 12:02:39 CET 2018

Hi, I think in your case you shouldn't need [declare] at all. [declare -stdlib somelib] makes the assumption that 'somelib' is installed in one of Pd's standard paths. This was maybe true for Pd extended where all libraries were in the /extra folder but actually it could be any other folder (which the user added to their search paths).

IMHO, best practice is to explicitly list your dependencies and have the user set them up correctly. 

regarding namespaces:

In an abstraction library I would always use them if I can (unfortunately it's not possible with externals which are part of a single binary library). It eliminates the possibility that a wrong abstraction/external is called. My favourite example:
Say that for some weird reason you're using [gate] from cyclone. If a users happens to have iemlib earlier in their search path, all your abstractions will have iemlib's [gate] object instead - which works exactly the other way around! This actually happened to a friend of mine :-D.

writing [cyclone/gate] has two advantages: 1) better documentation, 2) forces the cyclone version to be called and warns if the cyclone version is not found (instead of loading another external/abstraction with the same name which happens to be in the search path)


Gesendet: Dienstag, 02. Januar 2018 um 09:54 Uhr
Von: "João Pais" <jmmmpais at gmail.com>
An: pd-list at mail.iem.at
Betreff: [PD] declare vs. namespaces - current best practice

Dear list,
 I'm trying to make my abstraction library vanilla-compatible, but nevertheless I need to use some externals. Since I didn't keep up with the vanilla progress the last years, I wanted to ask what is the best method to make sure that all externals are loaded:- use [declare ....]?- use namespaces such as [list-abs/list1]?
 I imagine that for libraries compiled into one external file the best alternative is declare, such as with Gem: [declare -stdlib Gem -stdlib zexy]. But for cases where the objects are separated, is there a conceptual/political/pratical difference between declaring and using namespaces in the object name?(I'm used to namespaces so that I know immediately from which library the object comes, but I can change that)
 Adding to that: I'm still using mainly Pd-ext, and trying to branch out to vanilla and purr-data. Which is the best method to try to be compatible with these 3 distributions?E.g. [declare -stdlib Gem -stdlib zexy] works quite well on van+ext, but [declare -stdlib iemmatrix] doesn't in pd-ext; I must add a [iemmatrix] object to load the library. Is this a iemmatrix bug, or the [declare] object from pd-ext is too old?
Also: I imagine that there isn't a problem with repeated declarations? Inside each abstraction there is a [declare], and a patch can always use lots of them.
A suggestion: I can write [declare -stdlib xxxxx], and there will be no error message warning that the xxxxx library doesn't exist. Would it be good to have an error message, or even open deken to search for it?

 _______________________________________________ Pd-list at lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list

More information about the Pd-list mailing list