Closed blerner closed 6 months ago
I would put a contract on these so that if someone were to accidentally pass in a non-thunk value they'll get a run-time error. I imagine a lot of students will write something like
time-only(some-big-computation())
and…not at all get what they expect. Of course they'll get an error at f()
but a contract error may be better. (Ideally, they get an even more informative error that educates them, but that requires reflecting on value types and arity and what not.)
I might swap the order of values in time-value
so that time comes first and value comes second, both matching the focus and the function's naem.
The first two lines of the code-snippet are contracts :)
I kept the order that (I think) @schanzer requested in the planning doc; if you want to swap it, that's trivial and fine by me.
Where should these functions live? In a helper library? In essentials####? Somewhere else? time-now
is defined by runtime itself, since it's a JS primitive, but these others are Pyret utility functions.
Hm. I think I'd make a new module called timing
. Re-export time-now
and define and export these two?
We have
time-now
, that returns the current time in milliseconds since the epoch. We should addthat are more usable/informative.