On Thu, Jul 25, 2013 at 12:54 AM, Irek Szczesniak <[email protected]> wrote:
> On Thu, Jul 25, 2013 at 12:29 AM, David Korn <[email protected]> wrote:
>> cc: [email protected] [email protected]
>> Subject: Re: Re: [ast-developers] [RFE] var.__ to access the parent variable 
>> of a  type or compound variable
>> --------
>>
>>
>>> I like the idea of var.__ because it has a lot of potential. IMO, in
>>> terms of usefulness, its 2nd to namerefs.
>>>
>>> Irek
>>>
>>
>> Are you proposing that for compound variables
>>         print ${var.__}
>> be equivalent to
>>
>>         nameref name=${var%.*}
>>         print ${name}
>>
>> Is this correct?
>
> Yes, I think so. It eludes me at the moment why ${var%.*} only removes
> the last element in a compound tree name, but...
>
>>
>> What is ${var.__} for simple variables,
>
> simple variables => throw an error, except if they are member of a
> compound variable. Then the name of the parent variable should be
> printed.
>
>> type variables
>
> Example 1:
> typeset -T my_t=(
>     integer a=1;
> )
>
> my_t v;
>
> v.a.__ will refer to v itself (circular, I know, just for demonstration)
>
>
> Example 2:
> typeset -T my_t=(
>     compound a=(
>         integer b=1;
>     )
> )
>
> my_t v;
>
> v.a.b.__ will refer to v.a, v.a.b.__.__ will refer to v
>
>
> Example 3:
> typeset -T my_t=(
>     compound a=(
>         integer b=1;
>     )
> )
>
> compound c
> my_t c.v;
> nameref v=c.v
>
> v.__ will refer to c
>
>
> Example 4 - the IMO important one:
> typeset -T my_t=(
>     compound a=(
>         integer b=1;
>     )
> )
>
> function add_i
> {
>     nameref parent_of_v=$1.__
>     integer parent_of_v.i=9
> }
>
> compound c
> my_t c.v;
> add_i c.v
> print ${c.i}
>
> should print '9'
>
>> and for array variables?
>
> This is the tough little question I don't have an answer for.

Uhm... return the base name of the array (even for multidimensional
indexed arrays, e.g. $ typeset -a ar ; a[2][3][5]=1 ; a[2][3][5].__
should refer to "a" (and not something like a[2][3].__ ; otherwise the
caller would have to know the number of dimensions in an array and
that's not easily possible)) ? That's technically the parent of the
array elements...

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) [email protected]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to