add a comment about execution of 'run'

This commit is contained in:
Brent Yorgey 2021-08-25 16:38:29 -05:00
parent 3679dadd06
commit e85d90c6f6

View File

@ -201,7 +201,23 @@ execConst Run [VString fileName] k r = do
f <- liftIO $ T.readFile (into fileName) -- XXX handle file not existing
case processCmd f of
Left err -> error (into err) -- XXX
Right t -> mkStep r $ In t M.empty (FExec : k) -- XXX write note
Right t -> mkStep r $ In t M.empty (FExec : k)
-- Note, adding FExec to the stack above is correct. run has the
-- type run : String -> Cmd (), i.e. executing (run s) for some
-- string s causes it to load *and immediately execute* the
-- program in the file.
--
-- If we instead had
--
-- load : String -> Cmd (Cmd ())
--
-- then the code would be the same as for run, EXCEPT that we
-- would NOT add the FExec to the stack above. The fact that
-- there are two FExec frames involved in executing 'run' (one to
-- execute the run command itself, and one to execute the thing it
-- loads) corresponds to the fact that it is equivalent to (in
-- pseudo-Haskell syntax) 'join . load'.
execConst Run args k _ = badConst Run args k
badConst :: Const -> [Value] -> Cont -> a