On Mon, 2020-09-21 at 13:47 +0000, Chris Papademetrious
christopher(_dot_)papademetrious(_at_)synopsys(_dot_)com wrote:
I suppose it depends on your background. I use other languages that
chain equal-precedence operators in this fashion. Perl's logical OR
operator comes to mind first - "$a or $b or $c", with short-
circuiting evaluation.
Or, $a || $b || $c in Perl, which returns the first non-false value.
They do not have to be singletons, although the "effective boolean
value" of an array/sequence in Perl is its length, which often confuses
people. So you can put @a for a sequence; sequences do get flattened
but in this case you'd get the whole thing.
Perl also has an "unless" construct,
statement unless (expr)
which is perhaps a little like Mike Kay's "otherwise".
I'd wanted something similar to short-circuiting-or when the XQuery WG
was mired in discussion about "scripting" and ";" committing a
transaction, an awful that design that was thankfully abandonded but
that cost us two years.
Overall, first-not-false($seq as item*) is clearer to me than chaining
otherwise, but i'd prolly write
( ($a otherwise $b) otherwise $c)
to avoid precedence mistakes, especially when it's really
entry[@id = current()/@id] otherwise 1 + $notfound otherwise 0
(to use 0 if $notfound is empty).
--
Liam Quin, https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations: http://www.fromoldbooks.org
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--