lua-users home
lua-l archive

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



Why are people so afraid of globals?

Maybe it is just my age, but this entire discussion sounds a lot like trying to do nasty things to the language to protect inexperienced people from shooting themselves in the foot.  Which is an activity bound to fail due to fools being so ingenious.

A few months back I ported a rather large distributed application that was originally written in _javascript_ to lua.  In it, we make extensive use of global name space objects, ( which are truly global as the objects's full name actually specifies which sever around the world it actually lives on).  Within each object, all state is represented within the properties of the object itself.  If you happen to  need a temp variable for a particular task, you create a property of the object itself to hold it.  Each object is encapsulated, and has its own internal event queue to manage scheduling.  Globals do not necessarily impede modularization and encapsulation, poor design, lack of style, and insufficient attention to detail definitely do.

If you take a peek at how Self implements globals, and copy that you'd probably address 100% of the problems people actually have with globals.  But lua's OO features aren't quite up to Self's snuff.

Dave

--
-=-=-=-=-=-=-=-=-=-=- http://blog.dloh.org/