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
The <- binding syntax introduced by PR #1147 makes with_ names less nice. While
with_state init \x.
...
read reasonably ok, the new style
x <- with_state init
...
reads pretty poorly.
The fundamental reason for this is that when the continuation is indented and the function is first, it's fairly clear that the name refers to what it does to the continuation as a whole; whereas when the continuation is not indented and the binder is first, there is a pretty strong message that the function's name is about the kind of object it produces, and its effect on the continuation isn't very important --- fades into the background, takes care of itself.
Therefore, I think it's worth thinking about new names for those functions. Particularly the ones whose names currently start with with_ all have the flavor of introducing some resource, and maybe some type-level restrictions on how that resource is to be used, and then cleaning the resource up when the block ends. This means they will probably be used predominantly with the <- syntax. Here are all the with_ functions in the current Dex corpus:
with_state
with_reader
with_dynamic_buffer
with_alloc
with_file
with_temp_file
with_temp_files
with_c_string
with_table_ptr
The name of with_state I currently dislike pretty substantially, because it names the (ahem) effect it has on the continuation rather than the resource it provides. It's also used a great deal, so its name matters to the feel of the language. (Aside: It also annoys me that the binder is almost everywhere named ref instead of being named after its contents, but I can fix that along the way.) How about these other names for with_state:
var
variable
reference
new_reference
new_variable
new
box
Thoughts? The only down-side I can see is obscuring the relationship between with_state and its cousins yield_state and run_state. But run_state is almost completely unused in the corpus (except to implement with_state and yield_state), so we can call it anything we want, and we could reconsider the name yield_state as well.
I dislike with_reader for the same reason as with_state but it doesn't matter because it's unused.
The others are all of the same flavor: they provide some resource in the IO effect, and then clean it up when the continuation ends, returning the value of the continuation unchanged. Ergo, they will likely be used exclusively with <- syntax, so should read well in it. We could reasonably
Just remove the with_ prefix, leaving x <- dynamic_buffer ..., x <- c_string "foo", etc.
Change with_ to new_ to emphasize that something is being created or provided
Perhaps auto_, following C++ auto-pointers, which are auto-freed when they leave scope?
Thoughts?
The text was updated successfully, but these errors were encountered:
The
<-
binding syntax introduced by PR #1147 makeswith_
names less nice. Whileread reasonably ok, the new style
reads pretty poorly.
The fundamental reason for this is that when the continuation is indented and the function is first, it's fairly clear that the name refers to what it does to the continuation as a whole; whereas when the continuation is not indented and the binder is first, there is a pretty strong message that the function's name is about the kind of object it produces, and its effect on the continuation isn't very important --- fades into the background, takes care of itself.
Therefore, I think it's worth thinking about new names for those functions. Particularly the ones whose names currently start with
with_
all have the flavor of introducing some resource, and maybe some type-level restrictions on how that resource is to be used, and then cleaning the resource up when the block ends. This means they will probably be used predominantly with the<-
syntax. Here are all thewith_
functions in the current Dex corpus:The name of
with_state
I currently dislike pretty substantially, because it names the (ahem) effect it has on the continuation rather than the resource it provides. It's also used a great deal, so its name matters to the feel of the language. (Aside: It also annoys me that the binder is almost everywhere namedref
instead of being named after its contents, but I can fix that along the way.) How about these other names forwith_state
:Thoughts? The only down-side I can see is obscuring the relationship between
with_state
and its cousinsyield_state
andrun_state
. Butrun_state
is almost completely unused in the corpus (except to implementwith_state
andyield_state
), so we can call it anything we want, and we could reconsider the nameyield_state
as well.I dislike
with_reader
for the same reason aswith_state
but it doesn't matter because it's unused.The others are all of the same flavor: they provide some resource in the
IO
effect, and then clean it up when the continuation ends, returning the value of the continuation unchanged. Ergo, they will likely be used exclusively with<-
syntax, so should read well in it. We could reasonablywith_
prefix, leavingx <- dynamic_buffer ...
,x <- c_string "foo"
, etc.with_
tonew_
to emphasize that something is being created or providedauto_
, following C++ auto-pointers, which are auto-freed when they leave scope?Thoughts?
The text was updated successfully, but these errors were encountered: