Sensitive built functions GM

20 views
Skip to first unread message

spirit

unread,
May 9, 2012, 5:14:24 AM5/9/12
to greasemonkey-users
Hi, I have a question. In GM builtin function like GM_getValue,
GM_setValue etc. have use uppercase letters on begin (GM). Like we
know, in JavaScript good custom is to use a capital letter at the
start of the constructors function.

All code analysis tools (like JSLint) show error for GM code. Of
course, we can turn of this part of option in toys, but wen we use a
lot of constructors this option will very helpful.

So, why not make the possibility of using the built-in functions with
lower case letters, GM_setValue >> gm_setValue, or gmSetValue, sth
like this? Any other option, which does not indicate that the function
is a constructor will be good.

Tei

unread,
May 9, 2012, 6:37:19 AM5/9/12
to greasemon...@googlegroups.com
On 9 May 2012 11:14, spirit <arekmic...@gmail.com> wrote:
> Hi, I have a question. In GM builtin function like GM_getValue,
> GM_setValue etc. have use uppercase letters on begin (GM). Like we
> know, in JavaScript good custom is to use a capital letter at the
> start of the constructors function.
>

Its a legacy naming scheme, If greasemonkey where invented today, It
probably would use something like greasemonkey.store.setValue() or
gm.setValue(), like you have console.log() for firebug.

Javascript is not Java, anyway, the customs are hilariously
fragmented. GM_getValue may look like a constructor to a Java
programer, but to me, that I have a C background, looks like a ugly
macro :-/


--
--
ℱin del ℳensaje.

Tei

unread,
May 9, 2012, 6:40:58 AM5/9/12
to greasemon...@googlegroups.com
Ha idea.

You can have a snipt of code on the start of your scripts, with lines like this:

var gm_setValue = GM_setValue;
var gm_getValue = GM_setValue;

This way you will not be distracted by warning all over the code.
Then you can ask Douglas Crockford to add something like a "pragma",
so you could have this:

"#pragma ignore function naming rules";
var gm_setValue = GM_setValue;
var gm_getValue = GM_setValue;
"#pragma active function naming rules";

..to enable/disable these errors that JSLint drop on you.
Reply all
Reply to author
Forward
0 new messages