"LiveCode Infinity": lexically-scoped variables and bytecode blocks

Peter TB Brett peter.brett at livecode.com
Tue Jun 7 07:05:44 EDT 2016


Hi folks,

Just a quick update to let you know that work has already started on the 
"LiveCode Infinity" improvements to LiveCode Builder.

There are two really interesting things that will be finished soon.

Variables in LCB are going to become lexically scoped 
(https://github.com/livecode/livecode/pull/4113).  This means that 
variables declared inside an "if" or "repeat" block won't be accessible 
after the end of that block.

     if true then
        variable tVar as String
     end if
     -- tVar isn't accessible here

This also means that if you have a "repeat" loop, the variables that are 
declared inside the loop will be automatically reset on each iteration. 
It helps avoid bugs where temporary values created inside a loop get 
carried over to the next run of the loop.

    repeat 5 times
       variable tVar as optional String
       -- tVar is reset to "nothing" every time the loop runs
    end repeat

If you wanted tVar to be preserved from one iteration to the next, you 
can simply move the declaration outside the "repeat" loop.

Finally, it means that you can now "shadow" variables.  For example, 
this will become valid LCB code:

    variable tX as Array
    repeat 5 times
       variable tX as Number
       repeat 4 times
          variable tX as String
       end repeat
    end repeat

The second new feature is the "bytecode" block 
(https://github.com/livecode/livecode/pull/4097).  This lets you write 
blocks of raw LCB bytecode in your LCB source files.  At the moment 
there are not very many places where this is likely to be useful, but in 
the future when we add more bytecodes (as part of the "LiveCode 
Infinity" project) bytecode blocks will let us write much more of LCB in 
LCB.

I believe that "unsafe" blocks and "unsafe" handlers will be added soon. 
  These will be used to mark code that does risky direct memory 
manipulation.

                                     Peter

-- 
Dr Peter Brett <peter.brett at livecode.com>
LiveCode Technical Project Manager

LiveCode 2016 Conference: https://livecode.com/edinburgh-2016/




More information about the use-livecode mailing list