From: Bulat Ziganshin Date: 2002-10-08T19:32:33+09:00 Subject: block vars (some theory) Hello all, in different languages there is need to mark variables as global/local, const/variable, integer/float and so on. there is several methods to do this markup: 1) in variable name. f.e. constants and global vars in ruby indicated by variable name: Array, $global 2) by declararation. f.e. type declarators in C or Pascal 3) by definition, i.e. declararion combinated with some action. as example - using ':=' to declare var as local PLUS execute '=' first is definitely better if kind of variable can't be changed while program grows; third - when there is only one kind of actions, which can be combined with declaration to mark vars as local to block we can use any of methods above. but imho it is better to explicitly declare vars imported from outer blocks: a = 1 { a = 2 # ruby prints warning - outer var used without explicit import { import a a = 3 # OK - changing value of imported variable { local a # bad style - reusing outer variable name. # suitable only for metaprogramming a = 4 } { local a=4 } # same as above, but more suitable for one-liners } } p a #=> 3 proposed style is a less cryptish than other variants and conforms to principle of least surprise in my vision -- Best regards, Bulat mailto:bulatz@integ.ru