Re: changes in script-fu in 2.3.14

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Alexander Rabtchevich wrote:
> 	Raphaël, could you please explain me (I'm new to scheme) in a few 
> words, why the global variables are poor style coding?

Global variables can lead to bugs if not used carefully. The use of global 
variables in Script-Fu is particularly bad since all scripts are read in to a 
single namespace. A global variable defined in one file can be altered by code 
in another file without the need to use a Scheme equivalent of a C extern 
declaration. Everything will seem ok until you add another script file from 
somewhere that happens to use a global variable with the same name as a global 
defined in another file.

Problems can also arise when two files have global functions with the same 
name but different behaviour. This sort of problem has been seen even amongst 
the scripts shipped with GIMP. It is why you now see the use of locally 
defined functions rather than global ones in most scripts. For an example, 
look at the alien-glow-arrow.scm file.

> But the inability to use global 
> variables along with scheme syntaxes leads to a good deal of parentheses 
> which could be a problem to a programmer.

When you understand the syntax of the language, the use of local variables 
instead of global doesn't have any significant impact on the number of 
parentheses in a script.

If someone is afraid of the parentheses they shouldn't be trying to use 
Scheme. :-) More likely the fear of parentheses is caused by badly formatting 
the Scheme code (ie. lack of whitespace). Always putting the closing brackets 
for statements at the end of a single line leads to wasting a lot of time 
counting brackets.

-- 
Cheers!

Kevin.

http://www.ve3syb.ca/           |"What are we going to do today, Borg?"
Owner of Elecraft K2 #2172      |"Same thing we always do, Pinkutus:
                                 |  Try to assimilate the world!"
#include <disclaimer/favourite> |              -Pinkutus & the Borg
_______________________________________________
Gimp-developer mailing list
Gimp-developer@xxxxxxxxxxxxxxxxxxxxxx
https://lists.XCF.Berkeley.EDU/mailman/listinfo/gimp-developer


[Index of Archives]     [Video For Linux]     [Photo]     [Yosemite News]     [gtk]     [GIMP for Windows]     [KDE]     [GEGL]     [Gimp's Home]     [Gimp on GUI]     [Gimp on Windows]     [Steve's Art]

  Powered by Linux