What is the difference between a ' and a " ?

Richard Gaskin ambassador at fourthworld.com
Sat Jun 26 00:33:42 EDT 2004


Troy Rollins wrote:
 > On Jun 25, 2004, at 11:10 PM, Ken Ray wrote:
 >> You see Rev will assume an
 >> unquoted value as a string unless it is a variable
 >
 > It's statements like that which send traditional language
 > programmers running.

I guess it depends on the programmer.  If one is in the formal-language 
habit of quoting strings this likely won't ever be a problem.

Automatic typecasting is nearly as common in scripting languages as 
automatic garbage collection.  Rev is smart but it isn't psychic so it 
has to choose a type and, like VB and many others, it chooses a string 
type because of its flexibilty.

But if the string is numeric it will convert it to a number as needed (a 
float, if I understand it, but maybe Tuv can jump in and tell us if Rev 
ever uses ints for things it knows should be ints, like object coordinates).

Once converted to a number, subsequent numeric operations on the 
variable will be fairly efficient as it won't require another type 
coersion unless that var is once again used as a string (such as 
concatenation or chunk expressions).

Even with these productivity benefits, the engine's performance is often 
on par with fully compiled programs for a wide range of common tasks, 
and a few uncommon ones.

 > I don't expect that to change, but I'm guessing this is what all
 > the explicit vars noise is about? If so, count me in!

It's a handy feature, requiring the scripter to explicitely declare all 
local variables in addition to globals.  A great way to catch assignment 
issues before they're executed.

 >> perhaps we need another global property like "the explicitStrings"
 >> which if true would require strings to be quoted? ;-)
 >
 > Oh man, that would be great... I thought maybe too much to ask.

Working with explicitVars on should catch those circumstances, as 
unquoted strings will be assumed to be vars and if not declared will 
throw a compilation error.

-- 
  Richard Gaskin
  Fourth World Media Corporation
  ___________________________________________________
  Rev tools and more:  http://www.fourthworld.com/rev



More information about the use-livecode mailing list