Is the reason ask and answer are split between a command and a magic reporter as opposed to just being a single reporter that blocks until the user answers that reporters should be pure functions? Or just a matter of taste?
It’s inherited from scratch, which does have the separate blocks. If it really annoys you, then you can create a custom ask [What's your name?] :: sensing reporterblock
Sure. I was just wondering if there was a pedagogical reason motivating it. I guess in a simpler system like Scratch they didn’t have general purpose variables so it was nice to have this kind of pseudo variable that holds it’s value so you can ask a question once and then refer to the answer multiple times. But in Snap! it feels like it ads confusion because it looks like a variable but is actually temporarily tied to the preceding ask invocation in a kind of spooky action at a distance way.
No, it’s just a mistake in Scratch that we inherited. It would be much better if there were an ASK AND WAIT reporter because then there would be no possibility of confusion if two scripts do ASKs that overlap; the reporter could guarantee to report the answer to this question. There was the same issue with overlapping BROADCASTs until we put the message as an upvar in the hat block rather than a freefloating MESSAGE reporter. (I think in fact ASK and ANSWER do manage to keep coordinated, because the text box into which you type your answer knows what question it’s answering, but users don’t necessarily know that.)
AFAIK Scratch has always had variables, so I don’t think that’s their reason. They just don’t much care for functions. :~(
The problem is that all their variables are permanent and either globally accessible or sprite local. Not only does this create clutter, but for every script in a sprite that can ASK something, you’d have to have a separate “answer” variable for that script, or else you’d gain nothing over the ANSWER reporter.
I made this one last year, you can rename the upvar and use it furter in your code.
(I also add a condition to validate the answer)
