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

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
User avatar
andenixa
Grandmaster Poster
Posts: 105
Joined: Tue Nov 09, 2010 1:33 am

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

Post 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.
OWHorus
Grandmaster Poster
Posts: 106
Joined: Sat Feb 04, 2006 1:24 pm

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

Post by OWHorus »

Hello,

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

OWHorus
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

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

Post 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
User avatar
andenixa
Grandmaster Poster
Posts: 105
Joined: Tue Nov 09, 2010 1:33 am

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

Post 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.
User avatar
Austin
Former Developer
Posts: 621
Joined: Wed Jan 25, 2006 2:30 am

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

Post 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.
Post Reply