cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
%3CLINGO-SUB%20id%3D%22lingo-sub-248284%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ENomina%20Default%20Here(1)%20come%20spazio%20dei%20nomi%20predefinito%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-248284%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EMolti%20altri%20linguaggi%20di%20programmazione%20utilizzano%20per%20impostazione%20predefinita%20lo%20spazio%20dei%20nomi%2Fambiente%20locale%20anzich%C3%A9%20un%20ambiente%20globale.%20Gli%20esperti%20JMP%20affermano%20che%20NamesDefaultToHere(1)%20%C3%A8%20il%20BKM%20ogni%20volta%20che%20si%20esegue%20lo%20scripting%20poich%C3%A9%20in%20genere%20lo%20spazio%20dei%20nomi%20locale%20%C3%A8%20appropriato%20per%20i%20nuovi%20script%20per%20evitare%20conflitti%20con%20altri%20script%20JMP.%20Sarebbe%20pi%C3%B9%20conveniente%20definire%20NamesDefaultToHere(0)%20quando%20si%20desidera%20che%20uno%20script%20si%20trovi%20nello%20spazio%20dei%20nomi%20globale%20anzich%C3%A9%20definire%20ogni%20script%20con%20l'argomento%20%22true%22%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-248284%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3EAutomazione%20e%20scripting%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-584050%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20Nomina%20per%20impostazione%20predefinita%20Here(1)%20come%20spazio%20dei%20nomi%20predefinito%20-%20Stato%20modificato%20in%3A%20Investigating%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-584050%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-581921%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EOggetto%3A%20Nomina%20per%20impostazione%20predefinita%20Here(1)%20come%20spazio%20dei%20nomi%20predefinito%20-%20Stato%20modificato%20in%3A%20Riconosciuto%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-581921%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ECIAO%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2705%22%20target%3D%22_blank%22%3E%20%40cnattrass%3C%2FA%3E%20%2C%20Grazie%20per%20il%20tuo%20suggerimento!%20Abbiamo%20catturato%20la%20tua%20richiesta%20e%20la%20prenderemo%20in%20considerazione.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-373097%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Nomina%20per%20impostazione%20predefinita%20Here(1)%20come%20spazio%20dei%20nomi%20predefinito%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-373097%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EA%20mio%20avviso%2C%20avere%20lo%20spazio%20dei%20nomi%20Global%20come%20predefinito%20%C3%A8%20una%20decisione%20progettuale%20estremamente%20inadeguata%2C%20anche%20se%20capisco%20che%20potrebbe%20essere%20necessario%20per%20la%20compatibilit%C3%A0%20con%20le%20versioni%20precedenti%20con%20gli%20script%20JSL%20scritti%20nelle%20versioni%20precedenti%20di%20JMP.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPenso%20che%20qualsiasi%20nuovo%20programmatore%20JSL%20impari%20questo%20nel%20modo%20pi%C3%B9%20duro%20quando%20iniziano%20a%20verificarsi%20cose%20strane%20e%20difficili%20da%20eseguire%20il%20debug%20a%20causa%20di%20collisioni%20di%20nomi%20di%20variabili%20con%20pi%C3%B9%20script%3B%20in%20particolare%2C%20con%20i%20detriti%20lasciati%20dagli%20script%20che%20sono%20stati%20eseguiti%20in%20precedenza%20sotto%20lo%20spazio%20dei%20nomi%20globale.Poich%C3%A9%20le%20variabili%20non%20richiedono%20dichiarazioni%20in%20JSL%20e%20lo%20spazio%20dei%20nomi%20globale%20%C3%A8%20l'impostazione%20predefinita%2C%20credo%20che%20sia%20assolutamente%20cruciale%20inizializzare%20tutte%20le%20variabili%20su%20uno%20stato%20vuoto%20nella%20parte%20superiore%20del%20mio%20script%20per%20essere%20certi%20che%20valori%20imprevisti%20non%20si%20intromettano%20nel%20mio%20script%2C%20causando%20confusione%20e%20caos.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENaturalmente%20%C3%A8%20anche%20una%20buona%20pratica%20mettere%3CEM%3E%20Nomi%20predefiniti%20qui(1)%3B%3C%2FEM%3E%20in%20cima%20a%20ogni%20singolo%20script%20JSL%20mai%20scritto%2C%20ovunque%2C%20sempre%2C%20a%20meno%20che%20lo%20script%3CI%3E%20esigenze%3C%2FI%3E%20per%20utilizzare%20lo%20spazio%20dei%20nomi%20globale%20per%20qualche%20strano%20motivo.Anche%20in%20una%20situazione%20del%20genere%2C%20ritengo%20che%20sarebbe%20meglio%20impostare%20lo%20spazio%20dei%20nomi%20predefinito%20su%20Locale%20e%20fare%20riferimento%20a%20tutte%20le%20variabili%20globali%20come%20spazio%20dei%20nomi%20globale%20utilizzando%20esplicitamente%20il%20comando%3CEM%3E%20%3A%3Anome_globale%3C%2FEM%3E%20sintassi.%3CSTRONG%3EPertanto%2C%20se%20lo%20spazio%20dei%20nomi%20globale%20predefinito%20%C3%A8%20veramente%20necessario%20per%20la%20compatibilit%C3%A0%20con%20le%20versioni%20precedenti%2C%20dovremmo%20avere%20l'opzione%20che%20l'editor%20di%20script%20lo%20inserisca%20sempre%3CEM%3E%20Nomi%20predefiniti%20qui(1)%3B%3C%2FEM%3E%20in%20cima%20a%20tutti%20i%20nuovi%20script%2C%20invece%20di%20richiedere%20al%20programmatore%20di%20ricordarlo%20e%20digitarlo%20ogni%20volta%3C%2FSTRONG%3E%20.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnche%20con%20queste%20precauzioni%2C%20a%20volte%20riscontro%20ancora%20casi%20limite%20in%20cui%20si%20verificano%20collisioni.Ad%20esempio%2C%20il%3CEM%3E%20Somma%3C%2FEM%3E%20E%3CEM%3E%20Prodotto%3C%2FEM%3E%20le%20funzioni%20includono%20una%20variabile%20implicita%20denominata%3CEM%3E%20io%3C%2FEM%3E%20per%20impostazione%20predefinita.Va%20bene%20se%20utilizzato%20all'interno%20di%20uno%20script%20in%20cui%20ho%20gi%C3%A0%20impostato%20lo%20spazio%20dei%20nomi%20locale%20predefinito.Ma%20per%20quanto%20riguarda%20le%20formule%20di%20colonna%3FNormalmente%20non%20considero%20le%20formule%20di%20colonna%20come%20script%2C%20anche%20se%20%C3%A8%20esattamente%20quello%20che%20sono.Li%20modifico%20graficamente%20utilizzando%20l'editor%20di%20formule%20della%20GUI.Non%20mi%20era%20mai%20passato%20per%20la%20mente.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBene%2C%20la%20prima%20volta%20che%20ho%20usato%20a%3CEM%3E%20Somma%3C%2FEM%3E%20in%20una%20formula%20di%20colonna%2C%20mi%20%C3%A8%20capitato%20anche%20di%20eseguire%20uno%20script%20di%20tabella%20in%20cui%20avevo%20dimenticato%20di%20impostare%20il%20namespace%20locale%2C%20in%20cui%20ho%20utilizzato%20un%3CEM%3E%20Per%3C%2FEM%3E%20loop%20con%20l'iteratore%20as%3CEM%3E%20io%3C%2FEM%3E%20.Ci%C3%B2%2C%20non%20sorprendentemente%2C%20ha%20portato%20a%20confusione%20e%20caos.L'applicazione%20non%20ha%20risposto%2C%20%C3%A8%20rimasta%20bloccata%20in%20un%20ciclo%20infinito%20e%20ho%20dovuto%20interrompere%20l'attivit%C3%A0.Poi%20ho%20dovuto%20riprovarci%20ancora%20qualche%20volta%20prima%20di%20rendermi%20finalmente%20conto%20del%20terribile%2C%20oscuro%20errore%20che%20avevo%20commesso%2C%20fomentato%20dalla%20trappola%20tesa%20dal%3CEM%3E%20Somma%3C%2FEM%3E%20E'%20pernicioso%20a%20livello%20globale%3CEM%3E%20io%3C%2FEM%3E%20iteratore.Per%20farla%20breve%2C%20ora%20anche%20in%20Formule%20di%20colonna%20faccio%20doppio%20clic%20sull'editor%20di%20script%20e%20inserisco%20il%20file%3CEM%3E%20Nomi%20predefiniti%20qui(1)%3B%3C%2FEM%3E%3CEM%3E%20.%3C%2FEM%3E%3CU%3ENessuno%20script%20%C3%A8%20sicuro%20senza%20di%20esso%3C%2FU%3E%20.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-778102%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Nomina%20per%20impostazione%20predefinita%20Here(1)%20come%20spazio%20dei%20nomi%20predefinito%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-778102%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Edesiderio%20simile%20%2F%20duplicato%20di%3CBR%20%2F%3E%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FJMP-Wish-List%2FAutomatic-inclusion-of-Names-Default-to-Here-1-when-new-script%2Fm-p%2F396070%23U396070%22%20class%3D%22lia-mention-container-editor-message%20lia-img-icon-idea-thread%20lia-fa-icon%20lia-fa-idea%20lia-fa-thread%20lia-fa%22%20target%3D%22_blank%22%3EInclusione%20automatica%20dei%20nomi%20predefiniti%20qui%20(1)%20quando%20viene%20aperta%20una%20nuova%20finestra%20di%20script%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar

Names Default to Here(1) as the default namespace

Several other programming languages default to the local namespace/environment rather than a global environment. JMP Experts say the NamesDefaultToHere(1) is the BKM whenever scripting as typically the local namespace is appropriate for new scripts to avoid clashing with other JMP scripts. It would be more convenient to define NamesDefaultToHere(0) when you want a script to be in the global namespace rather than defining every script with the "true" argument

4 Comments
Chris_Rodrigues
Level III

Having Global namespace as default is an extremely poor design decision, in my opinion, although I understand it may be necessary for backwards compatibility with JSL scripts written in earlier versions of JMP.

 

I think any new JSL coder learns about this the hard way when strange, difficult-to-debug things start happening because of variable name collisions with multiple scripts; in particular, with the detritus left behind by scripts that have been run earlier under the global namespace.  Since variables do not require declaration in JSL, and global namespace is the default, I believe it is absolutely crucial to initialize all variables to an empty state at the top of my script to be certain that unexpected values do not intrude into my script, causing confusion and mayhem.

 

Of course, it is also good practice to put Names Default To Here(1); at the top of every single JSL script ever written, everywhere, always, unless the script needs to use the global namespace for some strange reason.  Even in such a situation, I feel it would be better to set the default namespace to Local and refer to all Global variables as the global namespace explicitly using the ::global_name syntax.  Thus, if default global namespace is truly necessary for backwards compatibility, we should have the option for the script editor to always insert Names Default To Here(1); at the top of all new scripts, instead of requiring the coder to remember and type this out every time.

 

Even with these precautions, I still sometimes encounter edge cases where collisions occur.  For example, the Summation and Product functions include an implicit variable named by default.  That's fine when used inside of a script where I already set default local namespace.  But what about column formulas?  I don't normally think about column formulas as scripts, even though that's exactly what they are.  I edit them graphically using the GUI formula editor.  It had never crossed my mind.

 

Well, the first time I used a Summation in a column formula, I also happened to run a table script where I had forgotten to set local namespace, in which I used a For loop with the iterator as i.  This, unsurprisingly, led to confusion and mayhem.  The application became unresponsive, stuck in an infinite loop, and I had to kill the task.  Then I had to try it a few more times before I finally realized the terrible, obscure mistake I had made, fomented by the trap that had been set by the Summation's pernicious global iterator.  Long story short, now even in Column Formulas I double-click the script editor and insert the Names Default To Here(1);.  No script is safe without it.

 

Status changed to: Acknowledged

Hi @cnattrass, thank you for your suggestion! We have captured your request and will take it under consideration.

SamGardner
Level VII
Status changed to: Investigating
 
hogi
Level XII