Which one of the following is NOT a side effect?
print
format
set-box!
read-line
error
random
Last week, and in the homework, we discussed implementing side effects
in a lazy language. Say that we want to add the ability to read a line
with a given prompt — we’ll want to extend the IO
type
What should the ReadPrompt
type be?
[ReadPrompt (IO -> IO)]
[ReadPrompt (IO -> String)]
[ReadPrompt (String String -> IO)]
[ReadPrompt String (IO -> String)]
[ReadPrompt String (String -> IO)]
[ReadPrompt String String IO]
[ReadPrompt String ReadLine]
Which statement about the above definitions is the most accurate?
and-fun
and and-macro
are completely equivalent.and-fun
is better since it’s a plain function (which is
preferable when possible).and-macro
uses a lazy evaluation strategy.and-fun
does not work because it is a function.and-macro
does not work because it is a macro.and-fun
produces a boolean value while and-macro
returns a Sexpr.The following macro definition is an attempt to implement a runtime debugging utility:
How is it broken?
It’s not actually broken, but could just as well be implemented as a function.
The first printout will never happen since it’s not quoted.
The second printout will never happen since it’s quoted.
The first printout will happen at the wrong time.
The first printout will never happen since its not part of the return value.