zsh-users
 help / color / mirror / code / Atom feed
* typesetting parameters
@ 2004-06-14  2:54 lists
  2004-06-14  4:58 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: lists @ 2004-06-14  2:54 UTC (permalink / raw)
  To: zsh-users

Hi list,
	I'm having difficulty understanding why one would define a parameter 
with typeset before using it using.  For example:

integer count=1
until something; do
    something else
    something else
    something else
    (( count++ ))
done

I could just do

count=1
until something; do
    something else
    something else
    something else
    (( count++ ))
done

and get the same results, right?  Similarly,  if I define a scalar 
variable or non-associative array with 'var=foo' and 'array=(one two 
three)', is that different from doing 'typeset var=foo' and 'typeset -a 
array; array=(one two three)'?  Any explanations, online guides, or FMs 
to R would be much appreciated.


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

* Re: typesetting parameters
  2004-06-14  2:54 typesetting parameters lists
@ 2004-06-14  4:58 ` Bart Schaefer
  2004-06-14 18:24   ` Vincent Stemen
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2004-06-14  4:58 UTC (permalink / raw)
  To: zsh-users

On Sun, 13 Jun 2004, lists wrote:

> 	I'm having difficulty understanding why one would define a parameter 
> with typeset before using it.

One probably wouldn't, when interactively typing commands, unless one
wanted to use the special attributes such as padding, alignment, other
integer bases, or floating-point precision.

The primary time/place and reason to use typeset is when defining shell
functions, to create variables that are local to the function scope. When
you use "local" that's really an alias for typeset.


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

* Re: typesetting parameters
  2004-06-14  4:58 ` Bart Schaefer
@ 2004-06-14 18:24   ` Vincent Stemen
  2004-06-15  2:43     ` lists
  0 siblings, 1 reply; 4+ messages in thread
From: Vincent Stemen @ 2004-06-14 18:24 UTC (permalink / raw)
  To: zsh-users

On Sun, Jun 13, 2004 at 09:58:57PM -0700, Bart Schaefer wrote:
> On Sun, 13 Jun 2004, lists wrote:
> 
> > 	I'm having difficulty understanding why one would define a parameter 
> > with typeset before using it.
> 
> One probably wouldn't, when interactively typing commands, unless one
> wanted to use the special attributes such as padding, alignment, other
> integer bases, or floating-point precision.
> 
> The primary time/place and reason to use typeset is when defining shell
> functions, to create variables that are local to the function scope. When
> you use "local" that's really an alias for typeset.

Not only that, even outside of functions, some expressions such as

    variable+=$value

will not always behave as intended if the variable is not typeset.  If
it is typeset as an array for example, you can depend on it appending
"$value" to the list.  Otherwise it might try to add it as an integer
or append it as a string, depending on it's value.

Regards,
Vincent

-- 
Vincent Stemen
Avoid the VeriSign/Network Solutions domain registration trap!
Read how Network Solutions (NSI) was involved in stealing our domain name.
http://www.InetAddresses.net


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

* Re: typesetting parameters
  2004-06-14 18:24   ` Vincent Stemen
@ 2004-06-15  2:43     ` lists
  0 siblings, 0 replies; 4+ messages in thread
From: lists @ 2004-06-15  2:43 UTC (permalink / raw)
  To: zsh-users

What a friendly and helpful list this is.  Thanks Vincent and Bart!


On Jun 14, 2004, at 1:24 PM, Vincent Stemen wrote:

> On Sun, Jun 13, 2004 at 09:58:57PM -0700, Bart Schaefer wrote:
>> On Sun, 13 Jun 2004, lists wrote:
>>
>>> 	I'm having difficulty understanding why one would define a parameter
>>> with typeset before using it.
>>
>> One probably wouldn't, when interactively typing commands, unless one
>> wanted to use the special attributes such as padding, alignment, other
>> integer bases, or floating-point precision.
>>
>> The primary time/place and reason to use typeset is when defining 
>> shell
>> functions, to create variables that are local to the function scope. 
>> When
>> you use "local" that's really an alias for typeset.
>
> Not only that, even outside of functions, some expressions such as
>
>     variable+=$value
>
> will not always behave as intended if the variable is not typeset.  If
> it is typeset as an array for example, you can depend on it appending
> "$value" to the list.  Otherwise it might try to add it as an integer
> or append it as a string, depending on it's value.
>
> Regards,
> Vincent
>
> -- 
> Vincent Stemen
> Avoid the VeriSign/Network Solutions domain registration trap!
> Read how Network Solutions (NSI) was involved in stealing our domain 
> name.
> http://www.InetAddresses.net
>


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

end of thread, other threads:[~2004-06-15  2:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-14  2:54 typesetting parameters lists
2004-06-14  4:58 ` Bart Schaefer
2004-06-14 18:24   ` Vincent Stemen
2004-06-15  2:43     ` lists

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).