zsh-workers
 help / color / mirror / code / Atom feed
* Re: sorting/uniq-ing an array?
       [not found]     ` <vbvho1xe7s.fsf@snake.isode.com>
@ 1998-08-10 15:55       ` Bart Schaefer
  1998-08-10 16:25         ` Andrej Borsenkow
  1998-08-10 16:32         ` Zefram
  0 siblings, 2 replies; 6+ messages in thread
From: Bart Schaefer @ 1998-08-10 15:55 UTC (permalink / raw)
  To: ZSH Users

On Aug 10, 12:34pm, Bruce Stephens wrote:
} Subject: Re: sorting/uniq-ing an array?
}
} "typeset -U" works for arrays, and so works for path.  Unfortunately,
} it doesn't work with (for example) LD_LIBRARY_PATH, which is a
} colon-separated list.  Annoying: this really needs configurableness.

Is there any difference (internally) between a plain array variable and
a colon-array, other than the set/get functions?  If not, it should be
pretty trivial to make colon-arrays a typeset-able parameter type.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sorting/uniq-ing an array?
  1998-08-10 15:55       ` sorting/uniq-ing an array? Bart Schaefer
@ 1998-08-10 16:25         ` Andrej Borsenkow
  1998-08-10 16:32         ` Zefram
  1 sibling, 0 replies; 6+ messages in thread
From: Andrej Borsenkow @ 1998-08-10 16:25 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: ZSH Users

Bart Schaefer wrote:
> 
> On Aug 10, 12:34pm, Bruce Stephens wrote:
> } Subject: Re: sorting/uniq-ing an array?
> }
> } "typeset -U" works for arrays, and so works for path.  Unfortunately,
> } it doesn't work with (for example) LD_LIBRARY_PATH, which is a
> } colon-separated list.  Annoying: this really needs configurableness.
> 
> Is there any difference (internally) between a plain array variable and
> a colon-array, other than the set/get functions?  If not, it should be
> pretty trivial to make colon-arrays a typeset-able parameter type.
> 

It is the main difference; there are some subteltis, as far as I
remember.

But the main problem is user interface. Standard variables are lower
case for arrays/upper case for scalars. What should really be done
(assuming typeset -C stays for creating colon-array variable):

  typeset -C <lower case name> => implicitly creates upper case scalar
version
    (or the variant of it for scalar => array)
    What, if the name is not all upper/lower case?
    What, if variable to be created exists? Or exists and is empty?

  typeset -C <scalar> <array>  => allowing arbitrary binding
    the same question with existing/empty variables

What to do, if one of such variables is explicitly unset? (Which one is
"master":) Going from implementation, scalar variable doesn't actually
exists and is created "on the fly", but in real life it is exactly
scalar which is used as base value. Should the second disappear as well?

-- 
============================================================
Andrej Borsenkow 		Fax:   +7 (095) 796 99 20
SNI ITS Moscow			Tel:   +7 (095) 796 99 24

NERV:  borsenkow.msk		E-Mail: borsenkow.msk@sni.de
============================================================


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sorting/uniq-ing an array?
  1998-08-10 15:55       ` sorting/uniq-ing an array? Bart Schaefer
  1998-08-10 16:25         ` Andrej Borsenkow
@ 1998-08-10 16:32         ` Zefram
  1998-08-10 18:13           ` Bart Schaefer
  1 sibling, 1 reply; 6+ messages in thread
From: Zefram @ 1998-08-10 16:32 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

Bart Schaefer wrote:
>Is there any difference (internally) between a plain array variable and
>a colon-array, other than the set/get functions?

Yes.  Colon-separated `arrays' are actually scalars.  Except for PATH,
MANPATH, et al, which are actually scalars reflecting the contents of
the true array variables path, manpath, et al.

-zefram


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sorting/uniq-ing an array?
  1998-08-10 16:32         ` Zefram
@ 1998-08-10 18:13           ` Bart Schaefer
  1998-08-11  9:31             ` Bruce Stephens
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 1998-08-10 18:13 UTC (permalink / raw)
  To: zsh-workers

On Aug 10,  5:32pm, Zefram wrote:
} Subject: Re: sorting/uniq-ing an array?
}
} Bart Schaefer wrote:
} >Is there any difference (internally) between a plain array variable and
} >a colon-array, other than the set/get functions?
} 
} Yes.  Colon-separated `arrays' are actually scalars.

Ah, yes, of course.  What I'm asking is, other than changing the cfn.gets
and cfn.sets members of the param struct to point at colonarrgetfn and
colonarrsetfn, is there any other magic involved in managing colon-arrays?

On Aug 10,  8:25pm, Andrej Borsenkow wrote:
} Subject: Re: sorting/uniq-ing an array?
}
} But the main problem is user interface. Standard variables are lower
} case for arrays/upper case for scalars.

Standard linked pairs of arrays and colon-arrays behave that way, yes.
I'm not (yet) suggesting adding that sort of linkage.  I'm interested
only in being able to declare a colon-array variable.  For example, I
can't think of any reason to create ld_library_path as an array.

}   typeset -C <lower case name> => implicitly creates upper case scalar
} version

I think this is the wrong approach.  I think creating the colon-array
scalar and linking it to an array should be two separate steps (or at
least two separate typeset flags).  I don't think zsh should be in the
business of enforcing upper/lower case; in fact, I don't even think it
should even be a requirement that the two variables have similar names!

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sorting/uniq-ing an array?
  1998-08-10 18:13           ` Bart Schaefer
@ 1998-08-11  9:31             ` Bruce Stephens
  1998-08-11 17:59               ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Bruce Stephens @ 1998-08-11  9:31 UTC (permalink / raw)
  To: zsh-workers

"Bart Schaefer" <schaefer@brasslantern.com> writes:

> Standard linked pairs of arrays and colon-arrays behave that way,
> yes.  I'm not (yet) suggesting adding that sort of linkage.  I'm
> interested only in being able to declare a colon-array variable.
> For example, I can't think of any reason to create ld_library_path
> as an array.

Being able to create new special variables would be sufficient for
this specific case.  I was playing around with a variety of installed
Tcl libraries, and it was handy to change my LD_LIBRARY_PATH quite a
lot interactively.  There wouldn't be any problem with having an
ld_library_path which is an array (in exactly the same way that
path/PATH and things are set).

Indeed, arrays have some nice syntax in zsh, which might be
convenient.  Or are you suggesting using the same syntax for
colon-arrays?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: sorting/uniq-ing an array?
  1998-08-11  9:31             ` Bruce Stephens
@ 1998-08-11 17:59               ` Bart Schaefer
  0 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 1998-08-11 17:59 UTC (permalink / raw)
  To: zsh-workers

On Aug 11, 10:31am, Bruce Stephens wrote:
} Subject: Re: sorting/uniq-ing an array?
}
} "Bart Schaefer" <schaefer@brasslantern.com> writes:
} 
} > Standard linked pairs of arrays and colon-arrays behave that way,
} > yes.  I'm not (yet) suggesting adding that sort of linkage.  I'm
} > interested only in being able to declare a colon-array variable.
} > For example, I can't think of any reason to create ld_library_path
} > as an array.
} 
} Being able to create new special variables would be sufficient for
} this specific case.

There are lots of kinds of special variables besides just colon-arrays.
Most of them involve more special handling than just changing the set/get 
functions for the values.  On further inspection I now understand that
colonarr{set,get}fn are assuming that there's a global char ** somewhere
(pointed to by the param struct) in which to store the associated array
representation, so it's not merely a matter of changing the functions
even for this case.

} I was playing around with a variety of installed
} Tcl libraries, and it was handy to change my LD_LIBRARY_PATH quite a
} lot interactively.

vared works a lot better on colon-arrays (scalars) than on true arrays.

} Indeed, arrays have some nice syntax in zsh, which might be
} convenient.  Or are you suggesting using the same syntax for
} colon-arrays?

I'm not (at this point) suggesting changing any syntax other than to
add something to typeset.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1998-08-11 18:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <19980809025636.18149@astaroth.nit.gwu.edu>
     [not found] ` <980809044123.ZM19065@candle.brasslantern.com>
     [not found]   ` <19980809123608.01170@astaroth.nit.gwu.edu>
     [not found]     ` <vbvho1xe7s.fsf@snake.isode.com>
1998-08-10 15:55       ` sorting/uniq-ing an array? Bart Schaefer
1998-08-10 16:25         ` Andrej Borsenkow
1998-08-10 16:32         ` Zefram
1998-08-10 18:13           ` Bart Schaefer
1998-08-11  9:31             ` Bruce Stephens
1998-08-11 17:59               ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).