Description
Ref:
Context: Trying to solve/implement this exercise for the Wren track and getting very confused.
I wonder if we should have added this without additional instructions describing for proper behavior. I find the current tests lacking in that they do not give me enough a picture of the correct behavior. I imagine students could make them pass while still having all sorts of bugs that don't actually implement Forth.
Take the JS canonical implementation for example: it is doing "immediate evaluation"... is that correct? I'm pretty sure that simply defining a function should not execute it. Also it seems to not deal with the fact that the function in question could remove items from the stack, not just add them... it could also theoretically work with items already on the stack (passed arguments?) making evaluating it immediately impossible (you need the future stack, not the present stack). ...or what if the function references another function that's not defined yet? I see we have a try
catch (perhaps to handle some of these many edge cases) but that just confirms my suspicions that we're probably handling this improperly (and likely need more far more tests).
I'm guessing that is not what Fortran is doing [immediate eval]... it feels more like closures (at a glance).. where a function definition closes on any other function definitions as they stood at the time the function is defined... so calling them later should run the actual function (with any side effects it might have) - BUT the function as it stood at the time the callee was defined, not however it might stand now. But that's just my educated guess. 🤷🏻♂️
- Are we wanting this exercise to truly be so complex?
- Have I properly understood what Fortran actually does here or is it something else?
- Am I entirely off the track here?