From: Ian Jackson Subject: Re: [OSSTEST PATCH 04/10] tcl/osstestlib.tcl: Provide lshift Date: Mon, 9 Feb 2015 18:13:07 +0000 Message-ID: <21720.63667.800583.144242@mariner.uk.xensource.com> References: <1423250275-20872-1-git-send-email-ian.jackson@eu.citrix.com> <1423250275-20872-5-git-send-email-ian.jackson@eu.citrix.com> <1423489913.4508.25.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YKsq5-0004dD-Qm for xen-devel@lists.xenproject.org; Mon, 09 Feb 2015 18:13:41 +0000 In-Reply-To: <1423489913.4508.25.camel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org Ian Campbell writes ("Re: [OSSTEST PATCH 04/10] tcl/osstestlib.tcl: Provide lshift"): > On Fri, 2015-02-06 at 19:17 +0000, Ian Jackson wrote: > > +proc lshift {listvar} { > > + upvar 1 $listvar list > > + set head [lindex $list 0] > > + set list [lrange $list 1 end] > > You calculate but then throw away list here? No. > Perhaps I need to read up on tcl scoping rules ;-) Yes :-). "upvar" is a magic scoping tool. "upvar $listvar list" means "take the variable which in my callers scope has the name contained in the variable which in my variable `listvar', and bring it into my own scope as a variable called `list'". The caller is expected to pass the name of its variable as the actual parameter. The effect is that someone who host set l {1 2 3} set f [lshift l] finds that afterwards l contains `2 3' and f contains `1'. > Anyway, with or without this last quoted line, whichever you intend: > Acked-by: Ian Campbell Thanks, Ian.