--- Michael Rys <mrys@microsoft.com> wrote:
> While I understand David's sentiment, we need to understand the dynamic
> semantics first if I expect a singleton and I get a sequence passed that
> may be longer.
>
It is logical in this case to use the first item of the sequence for the
operation and to ignore the rest.
The operation expects a single argument. It gets a sequence of more than
one argument. Therefore it has the single argument needed -- and this is
the first item of the sequence.
Why operate on the first item? Because this will work in every case --
even in the case when the sequence consists of just one element.
This semantics may seem "strange". However, it has been proven to be
useful and effective in practice when it is well documented and known. If
many thousands of programmers are using XPath 1.0 without problems then
why should this semantics be changed?
If the change was needed to simplify and correct something, then it
obviously didn't achieve these goals -- we are commenting on the anomalies
of the "pessimistic static typing", which require either relaxing the type
so much as to render it useless, or using dynamic-cast clutches such as
zero-or-one(), one-or-more() and exactly-one().
If this (otherwise well-intended) attempt to simplify and correct the
XPath 1.0 semantics is failing so obviously, then the conclusion is to
follow the semantics of XPath 1.0, which, although seeming "strange" at a
surface glance, has passed the reality tests by serving well its users.
Using this semantics it is possible to have type-checking that does not
exhibits the anomalies discussed, does not need any clutches and is really
useful.
Dimitre Novatchev
__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/