Ahk-Best-Practices icon indicating copy to clipboard operation
Ahk-Best-Practices copied to clipboard

Library Import Style

Open KamalAwasthi opened this issue 9 years ago • 6 comments

I think libraries and codes(like. functions) from other files should be included separately under a declarative comment like:

/*
**********************************
 libraries used
***********************************
*/ 
#include libcrypt.ahk
#include tf.ahk

either at the top of the file or at bottom as per the need.

KamalAwasthi avatar Feb 20 '16 16:02 KamalAwasthi

I put them at the top as per the C/C++ convention.

joedf avatar Feb 20 '16 18:02 joedf

I would have put them at the top but as AHK is a scripting language and runs from top to bottom, putting a lib on top scares me that lib code may get executed at startup. You see AHK has no main() method like those. But this is so silly :stuck_out_tongue_winking_eye:

aviaryan avatar Feb 20 '16 18:02 aviaryan

Well that is true, libraries are to (or should) be written in a way that it does not disrupt the script no matter where they are included. This point could be added to this "style" guide.

joedf avatar Feb 20 '16 18:02 joedf

I don't know. Maybe it's too advanced level for this guide. You know, writing a library, that kind of thing. Also there is no package manager for ahk. You just copy the code and paste it to a new file, or download something from GitHub. The lib code is not inaccessible like Python/Go/Java. Also library authors are sensible enough to not include auto-execute stuff in their scripts. If they have, you can always remove it when you have downloaded it locally.

aviaryan avatar Feb 20 '16 19:02 aviaryan

I never include i always use stlib

ttnnkkrr avatar Feb 20 '16 22:02 ttnnkkrr

Still trying to get ASPDM going, right now it's functional, it's just that the website isn't exactly complete and some small things here and there... :p

joedf avatar Feb 21 '16 01:02 joedf