Page 1 of 1

Is it safe to use leading underscore in var/func naming?

Posted: Sun Aug 14, 2011 5:29 am
by andenixa
Pretty much the subj. Is it safe to use leading underscores in function naming and could it possibly have any collisions with pol internals?
I have a number of functions starting with _p_ to indicate its private and some of those display a rather odd behavior.
Could the naming be the case?
Thank you.

Re: Is it safe to use leading underscore in var/func naming?

Posted: Sun Aug 14, 2011 11:54 am
by OWHorus
Hello,

it should be completely safe to use underlines in function/variable names. The name '_p_' should be ok.

OWHorus

Re: Is it safe to use leading underscore in var/func naming?

Posted: Mon Aug 15, 2011 11:07 am
by Austin
Sometimes it is.
If you are in a 'foreach' loop there is a _(var)_iter variable that comes with it.

Example:

Code: Select all

var beer := array{"Yum", "Yay", "Good", "Superb", "Fantastic", "Bacon", "Hell Yeah!"};
foreach word in ( beer )
     print ("Entry "+_word_iter+" contains "+word);
     Sleepms(10);
endforeach

Re: Is it safe to use leading underscore in var/func naming?

Posted: Mon Oct 17, 2011 5:03 am
by andenixa
I actually found that _*_iter is prone to the same dictionary glitch as for loop (a short version), such that it wouldn't insert Integer keys inside the foreach if _*_iter is used. I wonder if the explicit calls dictionary::insert(key, value) could help to avert this.

Re: Is it safe to use leading underscore in var/func naming?

Posted: Mon Oct 17, 2011 5:23 pm
by Austin
Interesting... Ill look into this when I get time. It looks like a run-time issue with the scripts, rather than compile-time. I went through the compiler code last night.