Jan,

> So the same function with the same arguments
> could evaluate to different things in different contexts?

There are different ways to accomplish such dynamic behavior:
- the mapping from function name to actual function object may in general
depend on the context and arguments
- the function may be a method on the context node
- the function may be coded to handle different contexts and arguments

> To me, your idea sounds like invoking a method on an object,
> whereas the traditional functions are more like stand-alone  functions in
a
> programming language.

In my case I use GNUs Rhino implementation of Javascript. I have implemented
a RhinoElement class extending JDOM's Element with support for the
javascript object model and scripting. So the function is actually a
javascript function attached to a Element, giving the feel of a method call.

> The alternative to a method invocation is to pass the "this" object in an
> argument (see the Perl and the Python programming languages).

> So instead of
>
> / path / to / somewhere /
>     ext:and-now-something-completely-different( 'zz' ) /
>     here-we-stand
>
> You could write
>
> ext:and-now-something-completely-different-II(
>    / path / to / somewhere,
>    'zz'
> ) / here-we-stand

Although in the former case the function is called once for each node
("somewhere" element) in the node set, and hence more naturally maps to
method call. In the latter case, the first argument is a node set (a set of
"somewhere" Elements). Isn't that correct and doesn't that make a
difference?

Hallvard


_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to