You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, Jeeves uses do blocks after update_state.
This is flexible, as it allows you to use multiple statements after updating the state.
The README gives some examples.
This doesn't read very well to me, and it's not clear at a first glance what is a state update and what is a return value. However, if you really want to have multiple statements after updating the state, then maybe there are no alternatives.
But how often does one want multiple statements in practice?
If we don't need multiple statements, then we can drop the block and use a more descriptive keyword, like :returning.
This would give use more "user-friendly" versions:
Note that now only the keyword form is supported, and everything is made uniform.
An alternative approach would be to flip things around and have a macro (or function, depending on the way Jeeves is implemented) like return that takes a value to return and a :with_new_state keyword that allows you to write:
Unlike the update_state form, in which the new state is fundamental and the return value feels like an afterthought, in the return form, the return value is fundamental and the new state is the afterthought.
I prefer the update_state form, but that's very subjective.
These are mostly cosmetic changes to the API, and maybe they are a little irrelevant, but in my opinion they might enhance readability. Losing the ability to use do blocks doesn't feel like a big deal.
The text was updated successfully, but these errors were encountered:
Currently, Jeeves uses
do
blocks afterupdate_state
.This is flexible, as it allows you to use multiple statements after updating the state.
The README gives some examples.
Using the "full"
do
block:Using the "abbreviated"
do
block:This doesn't read very well to me, and it's not clear at a first glance what is a state update and what is a return value. However, if you really want to have multiple statements after updating the state, then maybe there are no alternatives.
But how often does one want multiple statements in practice?
If we don't need multiple statements, then we can drop the block and use a more descriptive keyword, like
:returning
.This would give use more "user-friendly" versions:
Note that now only the keyword form is supported, and everything is made uniform.
An alternative approach would be to flip things around and have a macro (or function, depending on the way Jeeves is implemented) like
return
that takes a value to return and a:with_new_state
keyword that allows you to write:Unlike the
update_state
form, in which the new state is fundamental and the return value feels like an afterthought, in thereturn
form, the return value is fundamental and the new state is the afterthought.I prefer the
update_state
form, but that's very subjective.These are mostly cosmetic changes to the API, and maybe they are a little irrelevant, but in my opinion they might enhance readability. Losing the ability to use do blocks doesn't feel like a big deal.
The text was updated successfully, but these errors were encountered: