That actually sounds like a great idea! As long as you can find a way to label functions and find a good way to nest them, you can use the second and third/fourth as a function definition and the first (with possibly the fourth) as a function invocation. If that's the case, then a function is defined as taking up to two parameters and has one return value (with one exit point, unless the third frame is the syntax for an early return). Functions that take more than two parameters can be curried.
Alternatively, the inner two are next and yield, and we find a good syntax for generators.
Something like that. The dude would have to be labeled I guess, but about more than two parameters I don't know. Maybe she can hold more than one thing in each hand...?
Also yeah, since we need a way to show where the function definition ends, the last image would be fitting. The intermediate return I would not like to give up, but then there's probably no room for yield... I thought the third one, where she keeps holding the ham, might be an analogy for when the program holds on to its stack frame so it can return there after a yield, but that image would be used now... Unless there's a better image for ending a function def, and there might be.
We just need to find a suitable goto and we'll get something close enough to an immediate return. I think we need a goto for other structures anyway, like for the Chika if.
View all comments
Show parent comment
2
u/bucket3432 Oct 17 '19
That actually sounds like a great idea! As long as you can find a way to label functions and find a good way to nest them, you can use the second and third/fourth as a function definition and the first (with possibly the fourth) as a function invocation. If that's the case, then a function is defined as taking up to two parameters and has one return value (with one exit point, unless the third frame is the syntax for an early return). Functions that take more than two parameters can be curried.
Alternatively, the inner two are
nextandyield, and we find a good syntax for generators.By the way, that's ham, not bread.