hedy
hedy copied to clipboard
[BUG] combining `ask` with `at random` does not work (level 3)
Describe the bug
When using at random
in combination with ask
, the name of the list and at random
is printed without being replaced by one of the elements of the list.
Paste the Hedy code & level
questions is color, food, song, movie
answer is ask What is your favourite questions at random ?
print answer? me too!
In level 3
Expected behavior The question asked becomes: What is your favourite color? (Or one of the other options in the list. )
Hmm, I think this is gonna be a bit tough! A simpler program such as:
questions is color, food, song, movie
topic is questions at random
answer is ask What is your favourite topic ?
print answer? me too!
Is currently also not supported, as the text after ask
is treated as plain text
Now that you mentioned this, I see that any variable does not work with ask
! For example:
x is how are you?
y is ask x
This should work from level 2 on, but doesn't.
Is it too difficult to treat the text behind ask
the same way as text behind print
?
From level 4 on, we need to use quotation marks for strings we want to print with ask
and print
. So these example programs work from level 4 on, maybe it is okay that it does not work in level 3 yet. @Felienne What do you think?
In level 4, the first example would become:
questions is color, food, song, movie
answer is ask 'What is your favourite ' questions at random'?'
print answer'? me too!'
This works fine, so the problem that we cannot use variables (let alone use at random) in combination with ask
is only in level 3. It just seemed a little weird it could be used with other commands but not with ask
, that's why I made this issue, but since it is solved in level 4, maybe we can leave it like this.
Thanks for diving into this you both!!
I think in general ask
and print
are sort of similar things so I think kids might assume that they work the same. So if it works for print
it should work for ask
too?
On the other hand, the ask
syntax is more complex with the variable, so maybe we should not allow it to grow even more complex before it is really needed? I am torn but I lean towards consistency between print
and ask
. That will probably simplify the grammar/code too.
Hi, new to open source and looking to contribute! I've been able to build and run Hedy. I'm working with a partner from my class to do an assignment that pertains to contributing to open-source. Any chance this issue is still unassigned and we can work on it?
Yes it is still open! As you can read there was some discussion on the best path here, but I think that it would be nice to have consistency between ask and print, meaning
questions is color, food, song, movie
answer is ask What is your favourite questions at random ?
print answer? me too!
should indeed work.
Let us know if you need any help! Since this is an issue pertaining to the Hedy language it can be a bit complex (many connected parts) but we are here to help.
I am afraid the ask
and print
commands are already very different and making them symmetrical would require a big change in the content of the levels. Please note that the differences between the commands start already at level 2 which is illustrated in the snippet below:
name is ask What is your name?
print Hello name
The print
command accepts variables, while ask
does not. I can easily make ask
accept variables and list access but then we need to teach kids that they cannot use the variable name in the ask question (name
of the right-hand-side of the ask
becomes a variable now). It is very common to use a name for the variable of an ask
statement which appears as a literal word inside the ask
question. We could do some magic to solve specific case, but I am afraid the complexity will outweigh the benefits.
We could ignore the difference in level 2 and just add list access in level 3. But wouldn't that be confusing? ask
will not support variables but will support list access. @Felienne how would you like me to proceed?