On 6/7/22 00:18, Mark Waddingham via use-livecode wrote:
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...).
1. Because it's a function, not a constant.
put gkMyMagicValue() into tVar
is cognitively different from
put gkMyMagicValue into tVar
Something like 17 is a trivial case. Something more like real world
usage would be
constant kRootURL="http://example.com/aUrlThatMightChange/api/v2"
2. Because the server already build supports the "include" keyword which
would neatly solve the issue, but none of the other platforms do. Why?
3. Because every other language I've used has global constants and makes
this easy. It's only xtalk that makes this hard. If an LC goal is to
provide a tool for learning coding then multiple definitions of the same
constant is a paradigm that is not transportable to other languages, and
indeed will probably result in a compiler error.
4. Because it gets tiresome having to explain to new developers that you
have to declare constants in multiple scripts even though it's the same
constant you already declared and the workaround is to use a getter
function as you described.
--
Mark Wieder
ahsoftw...@gmail.com
_______________________________________________
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