[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [OSSTEST PATCH 04/10] tcl/osstestlib.tcl: Provide lshift



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 <ian.campbell@xxxxxxxxxx>

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.