[V4REV] symbolic constants // Based on Assoc Array

Robert Brenstein rjb at robelko.com
Mon May 16 12:53:51 CDT 2005


>On 5/13/05 12:48 PM, "Robert Brenstein" <rjb at robelko.com> wrote:
>
>>>  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.
>
>Okay Robert.
>Then what about next solution:
>
>1) Valentina define several global assoc array, to simulate enums of other
>languages. Names will be again similar:
>
>     EVDebugLevel  
>     EVDbMode
>     EVFlags
>     ...
>
>And Now you can write
>
>     SqlSelect(
>         query, EVCursorLocation["kServerSide"], EVAccess["kReadWrite"] )
>
>Only problem, I think this way will have slower access to constant values.
>

You seem to be back to defining globals behind our backs :)

Associative arrays are fast, so they won't affect performance.

Having multiple globals IMHO is not beneficial. Actually, more 
trouble than benefit. As user, I have to remember not only the name 
of constant but also the name of global. I would rather have a single 
global.

On the other hand, as I suggested earlier (as option for future), you 
could offer an optional parameter, so we can get either the all 100+ 
constants (if no param given) or just a subset corresponding to an 
enum.

put Valentina("Constants",[enum]) into var
put Valentina_Constants([enum]) into var
put valConstants([enum]) into var

Please consider seriously to let us decide what the variables are 
rather than presetting them for us. Sometimes doing less is better -- 
more in the spirit of Transcript or xTalks in general. I know this is 
contrary to what you do (have to do) for others. But Transcript is 
not Lingo or Java.

With this approach, you can at least have the names of actual 
constants same as in other environments.

Robert


More information about the Valentina mailing list