Re: declaring variants/subports in loops and loop variables

2016-12-08 Thread Gustaf Neumann
Am 07.12.16 um 18:04 schrieb Joshua Root: This is almost exactly the same situation as: foreach foo {bar baz} { proc p_$foo {} { puts $foo } } p_bar p_baz you probably want the variable "foo" being substituted in the body of the dynamically defined procs: % foreach foo {bar

Re: declaring variants/subports in loops and loop variables

2016-12-08 Thread René J . V . Bertin
On Thursday December 8 2016 12:54:05 Joshua Root wrote: >> doesn't really help (me). ... >Changing that to this will solve the problem: Indeed, but not what I meant to say. >No, my intention was to show that the variable is not in the correct >scope. Adding a global declaration would still ill

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread Joshua Root
On 2016-12-8 04:51 , René J.V. Bertin wrote: On Wednesday December 07 2016 17:09:35 Brandon Allbery wrote: Use a double quoted string and escape anything that needs it (but specifically not those variables for which you need the current value). I don't think that's going to make things much m

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread Brandon Allbery
On Wed, Dec 7, 2016 at 6:42 PM, René J.V. Bertin wrote: > My experience with Python (even from the rather early 2.x days in the late > 90s) is that it's always been very strict about scoping and closures Oh, it's strict enough, it just doesn't *have* some kinds of scope. -- brandon s allbery

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread René J . V . Bertin
On Wednesday December 07 2016 18:35:04 Brandon Allbery wrote: > (iirc you can get into the same mess with python 2, although maybe not in > 2.7) My experience with Python (even from the rather early 2.x days in the late 90s) is that it's always been very strict about scoping and closures. But I

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread Brandon Allbery
On Wed, Dec 7, 2016 at 6:32 PM, René J.V. Bertin wrote: > In this case it indeed won't work because $code is not evaluated > immediately inside `proc variant` but is instead used to create a procedure > that's invoked if the user activates a variant Right, that was implicit in my description of

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread René J . V . Bertin
On Wednesday December 07 2016 17:56:56 Brandon Allbery wrote: > It won't, but that's the best you will do in a stringy language like Tcl > (or shells, for that matter). Fortunately there's also the alternative of using an if construct inside the loop, which does work as expected. > > Not "whic

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread René J . V . Bertin
On Wednesday December 07 2016 17:09:35 Brandon Allbery wrote: > Use a double quoted string and escape anything that needs it (but > specifically not those variables for which you need the current value). I don't think that's going to make things much more readable, would it? I did notice one som

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread Brandon Allbery
On Wed, Dec 7, 2016 at 5:51 PM, René J.V. Bertin wrote: > On Wednesday December 07 2016 17:09:35 Brandon Allbery wrote: > > Use a double quoted string and escape anything that needs it (but > > specifically not those variables for which you need the current value). > > I don't think that's going

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread Brandon Allbery
On Wed, Dec 7, 2016 at 5:42 PM, René J.V. Bertin wrote: > > This is almost exactly the same situation as: > > > > foreach foo {bar baz} { > > proc p_$foo {} { > > puts $foo > > } > > } > > p_bar > > p_baz > > Huh? This complains about foo not being known, I think there s

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread René J . V . Bertin
On Thursday December 08 2016 04:04:57 Joshua Root wrote: > This is almost exactly the same situation as: > > foreach foo {bar baz} { > proc p_$foo {} { > puts $foo > } > } > p_bar > p_baz Huh? This complains about foo not being known, I think there should be a `global

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread Joshua Root
On 2016-12-8 04:14 , René J.V. Bertin wrote: On Wednesday December 07 2016 10:07:31 Ryan Schmidt wrote: Hi, The boost port shows a typical example of using "eval" and "subst" to ensure the variable values are substituted immediately. In a nutshell, put the whole block where you want to for

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread Brandon Allbery
On Wed, Dec 7, 2016 at 5:14 PM, René J.V. Bertin wrote: > That seems to do the trick all right. I was a bit hoping for a `foreach` > option to make limit the scope of the loop variable and all variables > declared inside the loop Tcl doesn't grok closures, or scoping in general (although it doe

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread René J . V . Bertin
On Wednesday December 07 2016 10:07:31 Ryan Schmidt wrote: Hi, > The boost port shows a typical example of using "eval" and "subst" to ensure > the variable values are substituted immediately. In a nutshell, put the whole block where you want to force using the current values of all variables

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread Brandon Allbery
On Wed, Dec 7, 2016 at 10:20 AM, René J.V. Bertin wrote: > variant python${pv} description "Add bindings for Python ${pdv}" { > depends_libs-append port:python${pv} > # snip > } > tcl tends to encourage you to think that { } is a block construct, and in many languages tha

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread Ryan Schmidt
> On Dec 7, 2016, at 11:04 AM, Joshua Root wrote: > > On 2016-12-8 03:07 , Ryan Schmidt wrote: >> >>> On Dec 7, 2016, at 4:20 AM, René J.V. Bertin wrote: >>> >>> Hi, >>> >>> See https://trac.macports.org/ticket/53022#comment:2 >>> >>> I'm still waiting for the final verdict from the ticket

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread Joshua Root
On 2016-12-8 03:07 , Ryan Schmidt wrote: On Dec 7, 2016, at 4:20 AM, René J.V. Bertin wrote: Hi, See https://trac.macports.org/ticket/53022#comment:2 I'm still waiting for the final verdict from the ticket reporter, but it seems that issue was one of those cases where I shouldn't have used

Re: declaring variants/subports in loops and loop variables

2016-12-07 Thread Ryan Schmidt
> On Dec 7, 2016, at 4:20 AM, René J.V. Bertin wrote: > > Hi, > > See https://trac.macports.org/ticket/53022#comment:2 > > I'm still waiting for the final verdict from the ticket reporter, but it > seems that issue was one of those cases where I shouldn't have used a loop > variable in the d

declaring variants/subports in loops and loop variables

2016-12-07 Thread René J . V . Bertin
Hi, See https://trac.macports.org/ticket/53022#comment:2 I'm still waiting for the final verdict from the ticket reporter, but it seems that issue was one of those cases where I shouldn't have used a loop variable in the declaration scope of a variant (nor subport): {{{ set pythonversions {3.4