QueryOne!: Support /./ to immediately get term + -default when 0 results#265
QueryOne!: Support /./ to immediately get term + -default when 0 results#265osnr wants to merge 2 commits into
Conversation
on queries where we only expect one result and immediately extract one value from it.
| } | ||
| set formats [QueryOne! the paper formats are /./] | ||
| set formatName [QueryOne! paper format /./ is the default paper format \ | ||
| -default letter] |
There was a problem hiding this comment.
Do you allow flags to be passed in after query parameters? I suppose this is more of an edge case, but -- might be needed in the future.
There was a problem hiding this comment.
Generally, I think we allow flags anywhere? + it reads better this way, I think, without the letter right up next to paper
There was a problem hiding this comment.
Yeah, I like the idea of eventually supporting --
| } | ||
| try { | ||
| dict set options printer \ | ||
| [QueryOne! printer /./ is the default printer] |
There was a problem hiding this comment.
Would you want a flag like -takefirst instead of try/on here?
There was a problem hiding this comment.
Or I suppose this is just in case nothing is returned, never mind.
|
Neat. You could also specify defaults inline, although that requires introducing specialized syntax once again: |
Saves a lot of code repetition -- we've been using lindex, dict getdef, and list length comparisons very repetitively when querying imperatively.
See Discord: https://discord.com/channels/956758212152025098/956765077883744266/1510000054507802785
Need to test that this didn't break anything.