Revolution Studio strong suggestion

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Josh
Posts: 46
Joined: Sat Jan 12, 2008 6:42 am

Revolution Studio strong suggestion

Post by Josh » Mon Feb 11, 2008 10:11 am

Hi all,

I've been using Rev Studio for a while and I really enjoy it. However, I kept encountering frustration due to global variables not being declared in all procedures. I appreciate Revolution's approach to variable usage without declaration. Heck, in the beginning, I thought it was a Godsend. I shook my head at the other languages I use and their pesky insistence on variable declarations.

However, with enough time, I've realized that the freedom to make new variables willy-nilly without a peep is a recipe for disaster. Typos go undetected. Even if you are a careful typer, sometimes (at least for me), I decide to use a variable globally, that was originally going to be local.

So, I would urge everyone to click the option in preferences "always use explicit variables". It may take some time to declare all of your locals, but you won't be sorry in the long run. You will almost certainly save time as I can't imagine any Revolution scripter avoiding lengthy debugging sessions because of this willy-nilly variable setting.

If you prefer the default of never having to declare variables, how in the world do you avoid bugs (or at least time-consuming bugs)?

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Contact:

Post by Mark Smith » Mon Feb 11, 2008 3:58 pm

I've never used 'explicit variables', and though I won't say I've never run round in circles only to eventually discover a simple typo, it's been very rare.

Perhaps having come to Rev from HC rather than a language that requires declarations, I'm just used to being careful when typing variable names.

I've used other languages (forth, opl, C) and find the 'on-the-fly' creation of variables in xTalks a boon. But each to his own, of course.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Mon Feb 11, 2008 7:52 pm

If you don't want to declare globals in each handler you use them you might consider accessors for those. For example, if you needed to access a global called gUserName you might put these in a library for all your scripts to access:

on SetUserName pUserName
global gUserName
put pUserName into gUserName
end SetUserName

function GetUserName
global gUserName
return gUserName
end GetUserName
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply