aviaryan / Ahk-Best-Practices

[WIP] AutoHotkey Best Practices
32 stars 5 forks source link

Library Import Style #1

Open KamalAwasthi opened 8 years ago

KamalAwasthi commented 8 years ago

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.

joedf commented 8 years ago

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

aviaryan commented 8 years ago

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:

joedf commented 8 years ago

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.

aviaryan commented 8 years ago

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.

ttnnkkrr commented 8 years ago

I never include i always use stlib

joedf commented 8 years ago

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