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
I spent hours trying to debug a nil from phrase-first until I realized that there is a behavior difference that I find confusing. Consider the following:
First test shows that phrase is for end-user and s/explain is for developers, everything is as expected :-)
Second test shows that, when the spec is actually valid, s/explain returns string "Success!" while phrase returns nil. Although I read the docstring for phrase-first: "Returns nil if x is valid or no phraser was found." I was still confused for hours :-)
In my opinion, there is a big difference between a valid spec and no phraser found. Is there a reason for always returning nil or would it make sense to conform (pun intended) with explain here and return "Success!" ?
The text was updated successfully, but these errors were encountered:
marco-m
changed the title
Confusing difference between s/explain and phrase
Confusing difference between s/explain and phrase on success
Jul 13, 2018
Thanks for asking. I clarified things in aaa3687. The function phrase-first is just a shortcut for phrasing a problem directly with phrase. If there is no problem, you can't phrase anything. So phrase-first returns nil on success. The messages returned by phrase are supposed to be error messages. So "Success!" wouldn't be useful to present to the user. But you can implement your expected behavior using the default phraser.
Hello, thanks for phrase!
I spent hours trying to debug a
nil
fromphrase-first
until I realized that there is a behavior difference that I find confusing. Consider the following:First test shows that
phrase
is for end-user ands/explain
is for developers, everything is as expected :-)Second test shows that, when the spec is actually valid,
s/explain
returns string"Success!"
whilephrase
returnsnil
. Although I read the docstring forphrase-first
:"Returns nil if x is valid or no phraser was found."
I was still confused for hours :-)In my opinion, there is a big difference between a valid spec and no phraser found. Is there a reason for always returning
nil
or would it make sense to conform (pun intended) withexplain
here and return "Success!" ?The text was updated successfully, but these errors were encountered: