W3C home > Mailing lists > Public > www-ql@w3.org > July to September 2002

Re: context across function calls

From: Per Bothner <per@bothner.com>
Date: Thu, 15 Aug 2002 12:25:50 -0700
Message-ID: <3D5C003E.6020008@bothner.com>
To: Michael Rys <mrys@microsoft.com>
CC: Damien Fisher <damien@sodatech.com>, www-ql@w3.org

Michael Rys wrote:
> Since functions may be compiled outside of the context where they are
> called, currently the function definition below would not pick up the
> dynamic context. Instead I would expect such a function to raise a
> compilation error about that there is not enough context information
> provided.

Yes, the 'context size' and 'context position' *values* are part of the
dynamic context, not available to the compiler.  However, the position()
and last() functions are part of the static context, visible to a
compiler.  Your argument is like say that the expression '10 + $x'
cannot be compiled because the compiler does not have enough context
information to do the addition at compile time.

> Passing implicit contexts is dangerous and should not be encouraged by
> the language since it makes the function partially dynamically scoped
> (talk to old APL programmers why dynamic scoped functions are a pain to
> debug).

However, the informal language language specification does define
'context size' and 'context position' to be part of the dynamic context.

> Instead rewrite your function to take the position and last as argument:

Right, no one is arguing that my sample program is good style or cannot
be re-written.  The point is that the specification documents appear to
be inconsistent, in a rather important area, and no-one on the committee
has acknowledged that this is an issue that must be resolved.
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/
Received on Thursday, 15 August 2002 15:18:30 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:17:15 UTC