"At some point", yes... *Bug 8244* <https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8244> - Script to find exporter problems *Bug 17600* <https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17600> - Standardize the EXPORT On Wed, 24 Oct 2018 at 20:24 David Cook <dcook@prosentient.com.au> wrote:
Whether or not to prefix the function with "C4::Accounts::" is something we should probably talk about at some point.
Historically, a lot of Koha modules use the "Exporter" module to export their functions into the main namespace of the caller. When "use C4::Accounts" runs, it automatically calls the "import" function in C4::Accounts, which in most/all cases is provided by the Exporter module. Blah blah blah. You can use the syntax "use C4::Accounts qw()" to prevent the importing of any functions or you can selectively import functions with "use C4::Accounts qw(function1 function2)". Fun times...
If you don't automatically import functions into the main namespace of the caller, then you'd want to definitely prefix the function with C4::Accounts::, otherwise you'll get an error since that function would be declared in the main namespace (or worse it's the same function name and you wind up with more errors/unexpected behaviour).
Personally, I rather use object oriented programming like we're trying in the Koha:: modules and/or have function libraries that don't use Exporter and instead require use of full namespace (e.g. C4::Accounts::function1). I think that's just a lot more transparent. More verbose but more explicit and easier to understand. Also fewer changes of function name collisions and less messy main namespace in the caller.
That's my 2 cents.
David Cook Systems Librarian Prosentient Systems 72/330 Wattle St Ultimo, NSW 2007 Australia
Office: 02 9212 0899 <02%2092%2012%2008%2099> Direct: 02 8005 0595 <02%2080%2005%2005%2095>
-----Original Message----- From: koha-devel-bounces@lists.koha-community.org [mailto: koha-devel-bounces@lists.koha-community.org] On Behalf Of Mark Tompsett Sent: Thursday, 25 October 2018 3:43 AM To: Koha-devel <koha-devel@lists.koha-community.org> Subject: [Koha-devel] The order of "use"
Greetings,
I was looking at bug 21641, and noticed the patch was explicitly stating C4::Accounts:: on the function in question. I vaguely recalled this sort of symptom shows itself in a knotted “use” mess.
C4::Circulation –> C4::Members –> C4::Accounts C4::Circulation –> C4::Accounts C4::Circulation –> C4::Overdues –> C4::Accounts
What is the best order to list these? C4::Accounts last? Is putting the C4::Accounts:: on the function in question still something we should do anyways?
Feedback appreciated, Mark Tompsett
_______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
_______________________________________________ Koha-devel mailing list Koha-devel@lists.koha-community.org http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-devel website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/