Improving the ASK Dialect (and replacing INPUT)


#1

I have been wanting ASK to become more clever than it is today, e.g. to take a dialect:

>> ask ["Operation failed." <(A)bort> <(R)etry> <(I)gnore>]
Operation failed. (A)bort, (R)etry, (I)gnore? A
== #Abort

That's an imaginative idea which would let you use TAG! to signal things to prompt for, and give you back an ISSUE! synthesized from it.

But whatever it is, I'd been thinking that there should be some way of replacing the 0-parameter INPUT with it. Because I hate INPUT being taken for this, it's better for a variable name (we wouldn't want OUTPUT to be a function by default would we?)

But when you don't want any prompt, I wasn't particularly happy with any of:

  • ask _
  • ask []
  • ask blank

Then @gchiu brought up the idea of type filtering, which leads to a pretty good answer for unfiltered text input with no prompt. ask text!. That sounds like a winner to me, and I say regardless of the rest of the design let's go ahead and get rid of INPUT and use ASK TEXT!.

But then...what about the rest of the design?

Can the user cancel the input without canceling the script? e.g. hitting "Escape" returning NULL in some interface.

 ask text! else [print "You indicated you didn't want to give any input"]

If NULL signals that, is there a different signal for errors? Or does the ASK implicitly keep harassing the user until they pass the validation, or hit escape to give NULL?

>> ask ["Enter a number:" integer!]
Enter a number: Q
** Invalid Input
Enter a number: 10
== 10

This seems like a fun dialect to design, so someone should get on it! In the meantime, INPUT is dying, use ASK TEXT!...