[V4REV] symbolic constants
Robert Brenstein
rjb at robelko.com
Fri May 13 11:48:26 CDT 2005
>On 5/13/05 2:52 AM, "Robert Brenstein" <rjb at robelko.com> wrote:
>
>> c) instead of creating a hundred of variables, it may be better to
>> create a single array variable, so there is only a single name to
>> declare as global. Surely more user-friendly and more
>> self-documenting. And we can get a list of all declared values in a
>> single call, using the keys() function.
>
>Interesting!
>please show me in transcript itself how this can looks
Valentina has associative arrays:
put 3 into myArray["item1Name"]
add 1 to myArray["item1Name"]
to see what elements an array has defined
answer the keys of myArray
We can also use split and combine to convert between normal vars and arrays.
> > d) may be such a global should not be assigned automatically when
>> Valentina external is called, if I follow your suggestion correctly,
>> but there is be a function we call specifying the name of the array
>> we want to be filled. First, you can't know whether we call
>> debuglevel or init or version first. Second, we may want a different
>> name for the global. Or we may prefer it to be local rather than
>> global.
>
>Wait, 100 vars are create ONLY ONCE on Valentina Init call.
>
It does not matter that it is a single call. *I* want to control when
and where (and if) you create it. Nothing personal :) I just don't
like you doing things behind my back. Particularly with globals which
can really be a source of conflicts or errors.
I may want
global gMyValConstants
put Valentina("Constants") into gMyValConstants
put Valentina("DebugLevel", gMyValConstants["kLogParam"])
or I may want
local cVal
put Valentina("Constants") into cVal
put Valentina("DebugLevel", cVal["kLogParam"])
or just
put Valentina("DebugLevel", 3) -- LogParam
With a single global, having your symbolic names identical as in RB
will work just fine. Recalling any name which is not defined
Yes, using arrays require more typing but having a single global
related to Valentina is a big plus IMHO. And what you propose is
put Valentina("DebugLevel", gValentina_kLogParam)
which is not any shorter to type.
Robert
More information about the Valentina
mailing list