Re: Numeric 'strings' to binary forms

On Tue, 2013-07-09 at 17:18 +0100, John Lumley wrote:
> Part of the EXPath-binary discussion around xs:base64Binary extensions 
> involves the issue of defining simple 'binary' constants for generation 
> of binary forms and comparison, especially used with other functions in 
> the package. Whilst extending the XPath constant grammar to include 0x45 
> might be nice, we know that's a VERY big task,

It would probably involve
1. editing the spec (XPath 3 is currenltly in CR, although XQuery 3 is
about to go back to last call so I suppose a feature could be added if
there were implementator support; otherwise it'd go in XPath 3.1), both
to extend the grammar and to add the necessary paragraph of prose; a
leading zero in 0x means I don't think there would be a problem in
distinguishing the token.

2. creating some test cases

3. defining how the new lexical representation of integers mapped to
values.

Whether that's VERY big or not is subjective. I'm not really arguing one
way or the other so much as saying, let's not assume the world around us
is unchangeable :-)

> <xsl:when test="bin:subsequence($stream,$pointer,1) = bin:hex('FF')">

Writing bin:hex('FF') (or 'ff' as well?) isn't a big burden compared
with writing 0xFF, and unless you're doing image processing the function
call probably isn't an undue burden (systems that do separate
compilation of modules won't be able to optimize that away in practice,
I suspect). (a data point: I have a 13,000 x 4,000 pixel image open in
an image editor right now, a head-piece for a chapter for a printed
book, so 52 million pixels; modern cameras are anywhere from 10 to 50
megapixels too)

But it's really a small issue, I meant it as an aside, "this is how the
two working groups responsible for XPath could make this work easier for
people".

> A more general function which detected the 'base' from the start of the 
> string (e.g. 0x, 0...) can be easily written as a compound, but I would 
> expect that in most cases you'd know what base you wanted to use, as 
> they are mostly expected to be used to generate constants.

I think making a leading 0 mean octal, as in C, would be to much of a
breaking change today, because people would expect xs:integer('077') to
work the same way. 8#77 might work, but again we'd have to do it
everywhere.

The non-constant cases still do have to be supported, of course.

[...]

>   * bin:binary() isn't very comfortable as a (very overloaded) name, but
>     I can't think of anything else.

thank you for not suggesting bin:ary() :-)

Liam

-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org freenode/#xml

Received on Tuesday, 9 July 2013 17:46:11 UTC