Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: for x in * evaluates filenames as arithmetic expressions?
- X-seq: zsh-users 8910
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: for x in * evaluates filenames as arithmetic expressions?
- Date: Tue, 24 May 2005 12:36:06 +0100
- In-reply-to: <200505241321.38329.huginson@xxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <200505241236.10511.huginson@xxxxxx> <26989.1116931903@xxxxxxx> <200505241321.38329.huginson@xxxxxx>
Einar Huginson wrote:
> Yes, that was indeed the case. I used `x' in an arithmetic for-loop earlier.
> However, I didn't realize that this would implicitly impose a `sticky' type
> for the variable. Now that I know, I'll be more careful in the future.
It's documented in the ARITHMETIC EVALUATION manual entry in zshmisc,
but fairly well down, so I don't suppose most people have read that far.
I expect the structure of the entry could be improved.
If a variable is first assigned in a numeric context without previously
being declared, it will be implicitly typed as integer or float and
retain that type either until the type is explicitly changed or until
the end of the scope.
The corollary is that if you always explicitly say "typeset x" before x
is ever used the variable will stay as a scalar.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author