Case sensitivity in Livecode ??

Mark Waddingham mark at livecode.com
Wed Jun 1 13:05:42 EDT 2022


On 2022-06-01 17:44, Alex Tweedly via use-livecode wrote:
> I was surprised to find that
> 
>    constant K = TRUE
> 
> produces an error, though
> 
>   constant K = true
> 
> is fine. In other contexts, you can say
> 
>    put TRUE into myVar
>    put true into hisVar
>    etc.
> 
> but in a constant statement, it seems to be case sensitive.
> 
> Anyone got an interesting story (or theory) on why ?   :-)

Its a small mitigation of 
https://quality.livecode.com/show_bug.cgi?id=19413 - i.e. where the 
initializer of constants (and locals) is currently treated as a single 
literal.

In explicitVariables mode, unquoted literals are allowed on the RHS only 
if the literal is a (builtin) constant *and* the constants value is 
identical to the token you have provided.

That extra check is there to ensure that the constants (and 
initializers) you have used are actually what you intended.

Currently - the following does not do what you think:

    constant kEmptyString = empty

Indeed, this isn't allowed in explicitVariables mode, as the constant 
empty's value is "" and not "empty" - which is what kEmptyString will 
actually be with explicitVariables turned off.

Anyway, this rather odd and obscure facet of the language will disappear 
in 10 as we've made it so that initializers for constants and locals can 
be constant expressions. Thus:

     constant kTrue = TRUE
     local sEmptyString = empty

Will do precisely what they look like they should do...

Also, you'll be able to do things like:

     constant kPiBy2 = pi / 2
     constant kPiBy2Squared = kPiBy2 * kPiBy2
     constant kPiBy2String = format("%f", kPiBy2)
     local sPiMap = { "pi-by-2": kPiBy2, "pi-by-2-sq": kPiBy2Squared }

Warmest Regards,

Mark.

P.S. Amusingly, your question came up on exactly the same day I 
'finished' my patch for the above - it now awaits review which may 
result in it not being quite finished ;)

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps



More information about the use-livecode mailing list