Strict Compile Mode

Mark Wieder mwieder at ahsoftware.net
Mon Oct 8 18:01:40 EDT 2012


Peter Haworth <pete at ...> writes:

> I'm switching over to to using strict compile mode in all my stacks, which
> I should have done long ago.

Yay! But aren't you going to feel nostalgic for all those runtime bugs you used
to have to hunt down?

> I was surprised to find that not all variables have to be defined in this
> mode.  It seems that using a variable in a repeat command such as "repeat
> with x=1 to 10" does not require x to be defined as a local variable, nor
> is an error flagged when x is used later in the handler, either within the
> loop or after it.  I can't decide if I like that or not.

I'm probably going to agree with Bob on this. I could justify it as saying the
compiler is being "helpful" in allowing relaxed rules for iterators in repeat
loops, but I think it just got overlooked.

> I like it because most of the time I don't use x outside of the repeat loop
> and it seems overkill to have to define it in those circumstances.  However
> if I accidentally type "x" when I really meant to type "y", I wouldn't get
> an error but my code probably wouldn't work correctly which is the whole
> point of strict compile mode.

Yeah. Nice that the compiler is so "helpful", no?

> It also seems that sometimes LC constants have to be enclosed in quotes.
>  For example "Set the backgroundcolor of field "xyz" to empty" works fine
> but "set the backgroundcolor of field "xyz" to black" fails and I have to
> put quotes around black, even though black is colored in the script as if
> it is a known LC constant.  Not a big deal, just wondering why that is.

Lazy compiler parsing. It seems that there are constants and then there are
constants. The color names in particular seem not to be real constants, although
you can't redefine them.

-- 
 Mark Wieder
 mwieder at ahsoftware.net










More information about the use-livecode mailing list