Taking all this in, my thought is that this is best done with a library, rather than a new statement. I see that you ended up coming to that conclusion yourself in the end.
Even if we had named parameters (outside of object creation), it's not clear that a single method call is best. There are a lot of things going on with input about the behavior as well as the final results. Consequently, a class makes more sense:
"""
This is a *sketch* of a potential class for prompting for input.
"""
class Prompt<of T>
def init
_text = ''
_retryText = ''
_rawResponse = ''
## Setup
pro text from var as String
pro retryOnFail from var as bool
pro retryText from var as String
pro cancelInput from var as String?
""" When non-nil, this text can be entered by the user to cancel out of the prompt. """
# TODO: add a validation delegate
## Run
def run as Prompt<of T>
# ...
return this
## Results
get didCancel from var as bool
pro rawResponse from var as String
get response from var as T?
class P
def main is shared
prompt = Prompt<of int>( _
text = 'Enter your age \[c to cancel]: ', _
retryOnFail = true, _
retryText = 'Not a valid age.', _
cancelInput = 'c').run
if not prompt.didCancel
trace prompt.response
-- I was bit a surprised that I needed the line continuation character inside the creation of the Prompt. We'll fix that.
-- As you can see, the creation of the prompt is quite explicit about how it will behave, which is great.
-- The multiple properties of the prompt make it easy to explore the results.
-- I'm not positive you could do this with just one class. Maybe this is an abstract class and you need concrete subclasses for each type.
-- Even if it becomes one self-contained class, you still have the option of creating a custom subclass and adding more specs, more results or overriding "run". Try that with a function!
-- There may be other ways to approach this. The sketch above is just my first stab at it. I have other things on my plate, so you can take it from here if you're interested in seeing this fully developed.
-- Hope that helps!