-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 80: fn:iterate-while (before: fn:while) #210
Conversation
It was my impatience that needs to be blamed. All fine now. |
I think it would be useful to try to write a summary that explains to people why they might want to use this function. Something like "Processes a supplied value repeatedly, continuing while some condition remains true, and returning the first value that does not satisfy the condition." I think this is one of those functions where it would help the reader if the rules were structured as "informally, X. More formally, the function is equivalent to..." Perhaps the informal explanation (if I have understood it correctly) is something like this. Informally, the function behaves as follows:
It would be nice to give a simple XML example, for example a function that returns the value of @xml:space on the nearest ancestor-or-self that has such an attribute. I'm not quite sure what is meant by "a single argument" in the Errors section. The Notes section might be a good place to put some discussion of why the function has been introduced and when it's useful: the examples give the reader some ideas, but I think more narrative would be useful. |
We might also like to consider that having a function named "while" prevents us ever using "while" as a language keyword. (Perhaps |
And another idea for an example/use-case - does it make sense to use the function in conjuction with |
Now implemented - 10 lines of code, so it must be a pretty clean spec. All tests passing except while-014 which depends on the |
Readers should be made aware that it's very easy to construct an infinite loop using this function if not used correctly. |
Thanks for the suggestions from a near(est)-native speaker, very appreciated. I’ll incorporate your suggestions as good as possible. The structure of my text was mostly inspired by the fold functions. I’m not sure: Maybe we should give them an informal section as well?
Maybe “one argument” sounds better? The error section is basically a mixture from the corresponding sections for Maybe we should simply skip this section, as we more or less seem to explain here how function arguments are to be evaluated in general?
I wonder if that wouldn’t apply to
Personally, I would probably be confused (without reading the spec and without knowing about XSLT) why a language has
I haven’t used the function a lot. Do you have an example in your mind that I can add?
Would you recommend removing
I see. I’ll update the test case. |
As regards the keyword, It could certainly lead to parsing difficulties, e.g. if we had a function called "where" then we couldn't allow "where" as the first clause in a FLWOR expression (something that would make sense to allow). In practice it's probably not the technical grammar ambiguity that's the issue, as the user confusion that could result if we use the same word to mean different things in different contexts. |
I've been fairly guilty myself in using syntax that isn't yet accepted in test cases, so I can't really complain. But it's probably best avoided if unnecessary - there's a general principle when writing tests to focus on the feature you're testing. |
Trying to use random-number-generator to generate a random sequence (or anything else to generate a sequence), I find myself wanting to output values when the predicate is true, rather than accumulating them until it is false. |
Minor reverts (arrows, named arguments; see qt4cg/qtspecs#210)
Wouldn’t we have to rename
I’ve concocted a little example which I’ll add in my updated version. I won’t be offended if you plan to edit my pull request (I don’t know if the notes will be explanatory enough). |
The clause keywords that are always followed by "$" (for, let, some, every) are less of a problem - the presence of "$" or "(" immediately distinguishes whether its a function call. |
Formatted versions of the specifications with this PR applied are available |
Looks good for the most part. I have some editorial notes.
|
@cmsmcq Thanks, very appreciated. I have incorporated your suggestions. |
A summary of the comments, for next week’s meeting: We need to decide if we want to stick with the function name. It would prevent us from using while (...test...)
return ...result... Alternatives could be:
|
The function seems quite useful. In fact, as I think of using it, my first impulse would be to use it as a keyword, on analogy to |
@Arithmeticus Thanks. I think that both a function and keyword could be beneficial. Michael Kay has added a proposal for a |
I’ve renamed the function from |
Looks good, I think. For the second rule I wonder if a different formulation would be clearer. For:
perhaps read:
(This is longer than I hoped when I started, and if we can shorten it that would be good.) The key change for me is to say more clearly that the input value is produced by evaluating the action. |
@cmsmcq Thanks. I’ve changed it to:
|
Approved at meeting 011, 15 November 2022 |
Issue 80: fn:iterate-while (before: fn:while)
No description provided.