variables and objects

Jan Schenkel janschenkel at yahoo.com
Wed Feb 26 00:58:01 EST 2003


--- erik hansen <erikhans08 at yahoo.com> wrote:
> --- Jan Schenkel <janschenkel at yahoo.com> wrote:
> > --- "Ivers, Doug E" <Doug_Ivers at lord.com>
> > wrote:
> > > Seems that all user-created variables are
> > character
> > > strings.  Is target also a character string,
> > or is
> > > it something more sophisticated (like a
> > pointer in
> > > C)?  Same question for this card, recent
> > card, this
> > > stack, etc.
> > > 
> > > Are these statements the same in the way they
> > work
> > > "behind the scenes"?
> > >      answer the id of this card
> > >      get the long name of this card; 
> > >      answer the id of it
> 
> > All variables are indeed character strings ;
> > including
> > 'the target' ; however, the engine recognises
> > certain
> > keywords and can grab the data without having
> > to parse
> > the content of the variable first ; so in your
> > example, "the id of this card" will work faster
> > than
> > "the id of it" because the engine grabs it
> > directly.
> 
> the engine grabs <it> or grabs "this card"?
> 

Hi Erik,

You're right, that was a bit less-than-stellar choice
of words upon review.

"answer the id of this card" takes the engine a single
step to retrieve the ID.

"get the long name of this card; answer the id of it"
actually takes 5 steps :
1) retrieve the long name of this card
2) stuff it down the special variable 'it'
3) retrieve the content of the special variable 'it'
4) parse that content for an object reference
5) retrieve the id of said object

"put the long name of this card into tLongName ;
answer the id of tLongName" would have been the
slowest variant, because the engine recognises the
special variable 'it' and doesn't have to dig through
memory references to find out which bit of RAM you're
referring to.

This sort of information can be used to optimise
performance of certain key areas of your program. One
example of this is the recent thread on imageData
manipulation, where the re-use of local variables
instead of reading the imageData again and again,
turned an effect from sluggish to smooth.

Then again, the point is moot if your program does
what it has to do and runs at acceptable speeds on
your machine.

Hope this cleared a few things up,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/



More information about the use-livecode mailing list