Skip to content

Proposal to add fallback behaviour to map:get and array:get - #289

Merged
ndw merged 2 commits into
qt4cg:masterfrom
michaelhkay:Issue278-array-bound-checking
Mar 10, 2023
Merged

Proposal to add fallback behaviour to map:get and array:get#289
ndw merged 2 commits into
qt4cg:masterfrom
michaelhkay:Issue278-array-bound-checking

Conversation

@michaelhkay

Copy link
Copy Markdown
Contributor

Note: I got a build failure trying to build this, it's doing DTD validation but there are invalidities, unrelated to the changes I made.

@ndw

ndw commented Dec 18, 2022

Copy link
Copy Markdown
Contributor

The <ul> starting near 18,143 in function-catalog.xml is invalid. In xmlspec, an itemized list is a ulist not a ul. Try:

         <ulist diff="add" at="2022-12-16">
            <item><p>It might return a conventional value such as <code>NaN</code> to indicate that no matching
            key was found.</p></item>
            <item><p>It might raise a dynamic error, by means of a call on <code>fn:error</code>.</p></item>
            <item><p>It might compute a result algorithmically. For example, if the map holds a table of
            abbreviations, such as <code>map{'CA':'Canada', 'UK':'United Kingdom', 'US':'United States'}</code>,
            then specifying <code>fallback := fn:identity#1</code> has the effect that the key value is returned
            unchanged if it is not found in the map.</p></item>
         </ulist>

@michaelhkay
michaelhkay force-pushed the Issue278-array-bound-checking branch from 9ed9390 to 7944df5 Compare February 4, 2023 15:14
>same key</termref> as <code>$key</code>. If there is such an entry, it returns the associated value;
otherwise it returns an empty sequence.</p>
<phrase diff="chg" at="2022-12-16">if not, it invokes the supplied <code>$fallback</code> function, supplying
the requsted <code>$key</code> value as the argument, and returns the result of this call.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requsted --> requested

indicate that the key is not present in the map. The two cases can be distinguished by
calling <code>map:contains</code>.</p>
calling <code>map:contains</code><phrase diff="add" at="2022-12-16">, or by using
a <code>$fallback</code> function to return a value is known never to appear in the map</phrase>.</p>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value is known --> value known

@ndw

ndw commented Mar 10, 2023

Copy link
Copy Markdown
Contributor

We agreed to accept this PR at meeting 021. Joel will submit a different PR for the subsequently identified editorial issues.

@ndw
ndw merged commit a616cf8 into qt4cg:master Mar 10, 2023
@ndw ndw mentioned this pull request Mar 10, 2023
@michaelhkay michaelhkay added Tests Added Tests have been added to the test suites Completed PR has been applied, tests written and tagged, no further action needed labels Mar 16, 2024
@michaelhkay michaelhkay added In Saxon 13 The feature is implemented in the Saxon 13 development branch In Saxon 12 The feature is substantially implemented in the latest Saxon 12.x maintenance release labels Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Completed PR has been applied, tests written and tagged, no further action needed In Saxon 12 The feature is substantially implemented in the latest Saxon 12.x maintenance release In Saxon 13 The feature is implemented in the Saxon 13 development branch Tests Added Tests have been added to the test suites

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants