W3C home > Mailing lists > Public > xproc-dev@w3.org > November 2011

Re: Shadowing of variables..

From: Florent Georges <fgeorges@fgeorges.org>
Date: Mon, 28 Nov 2011 11:53:22 +0100
Message-ID: <CADyR_r1iTmjXHe+cx_dk_8mrao5AozTKyS_Daz4HiooGxFVt7w@mail.gmail.com>
To: Geert Josten <geert.josten@dayon.nl>
Cc: vojtech.toman@emc.com, xproc-dev@w3.org
On 28 November 2011 11:30, Geert Josten wrote:

> I usually redeclare variables if I want to build a final value
> in multiple steps, to make either calculation easier (reusing
> intermediate values multiple times in one expression), or just
> to decompose an otherwise very long calculation.

  I was pretty sure that was the reason :-) The thing is:  1/ you
name a temporary thing with the name of the final thing, and 2/
when one is looking back for the way a variable is computed,
he/she can be misled when finding the variable declaration, but
not noticing it is actually shadowed later on and is actually
only a temporary step.

  In the wrong case scenario, when I don't find a meaningful name
for the temporary variable, I simply call it [the-final-var]-tmp.

  But I guess this is becoming more a development best practice /
ideology thing, than an XProc topic...

> PS: what are the use cases for XSLT? ;-)

  Honestly, I am not quite sure but I suspect this is the same
reason.  Maybe also to ease generating code in some cases.  But
I didn't say I liked it more in XSLT :-)

  Regards,

-- 
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/
Received on Monday, 28 November 2011 10:54:11 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 28 November 2011 10:54:12 GMT