I thought we already had global constants?? I think they are called, 
"Literals." ;-)

Bob S


> On Jun 7, 2022, at 24:18 , Mark Waddingham via use-livecode 
> <use-livecode@lists.runrev.com> wrote:
> 
> On 2022-06-01 19:54, Alex Tweedly via use-livecode wrote:
>>> 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 }
>> Very good. In fact, great !! Thank you!
>> Would you be ale to do something like
>> constant kPiMap = { ... as above ... }
> 
> Yes - the initializers in both constant and local keywords are the same - 
> both can use arbitrary constant expressions (any local properties are assumed 
> to be the default values when evaluating).
> 
>> And now I'll push my luck and ponder the possibility of 'global' constants.
> 
> Haha...
> 
>> OK - 'global constant' is likely counter to the scope concepts. But
>> perhaps they could be done as "write-once" variables, or as a more
>> general "write-protected' variable.
>>    put 17 into gkMyMagicValue
>>    writeprotect "gkMyMagicValue"
>> and any *subsequent* attempt to change the value would fail.
> 
> How is that any better than putting something like this in a library or back 
> script:
> 
>    function gkMyMagicValue
>        return 17
>    end gkMyMagicValue
> 
> Including the global declaration its the same number of lines (indeed less, 
> as you'd need to put a global declaration in every script which wanted to use 
> said global constant...).
> 
> Warmest Regards,
> 
> Mark.
> 
> -- 
> Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
> LiveCode: Everyone can create apps
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to