-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add docs and tests for as-> macro #1141
Conversation
relates to hylang#1047
|
||
.. note:: | ||
|
||
In these examples, REPL will report a tupple as result: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tuple? (Also, missing the before REPL.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, tuple is one of those words that I consistently misspell.
The previous result is thus available in the subsequent form. Returns the final | ||
result, and leaves the name bound to it in the local scope. This behaves much | ||
like the other threading macros, but requires you to specify the threading | ||
point per form via the name instead of always the first or last arument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...this is kind of confusing. I mean, I'm guessing that there will likely never be a "simple" explanation for something like this. I think maybe at minimum the example should use something more descriptive than x
; maybe assigned_name
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, assigned-name
is much better. I'll try to think better explanation, but currently I'm drawing a blank.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree that assigned-name
is better. Perhaps you could use it in the first example just to point out which argument is which, but certainly not for all of them. The whole point of as->
is an alternative to ->
and ->>
, but where the insertion point can be anywhere in the list, instead of the first or last argument only. For deeply nested calls, this name may have to be repeated many times. Therefore, idiomatic usage is with a very short name, perhaps one or two letters. (This is not a problem for ->
and ->>
where the point is implied by the position.)
Perhaps the documentation would be clearer if you demonstrated how to accomplish a ->
using as->
. You can also look at Clojure's community documentation for clarification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of assigned-name
I could also us it
as it's short and generic enough. I'll try to come up with a better examples still, that would highlight usage of as->
better (as now the example could be easily rewritten with ->
).
.. note:: | ||
|
||
In these examples, REPL will report a tupple as result: | ||
('Sepia prashadi', 'Sepia prashadi'), but the actual value returned is just |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be surrounded by double-backticks for formatting? The sentence could also be worded a bit differently, like:
In these examples, the REPL will report a tuple (e.g. `('Sepia prashadi', 'Sepia prashadi')`) as the result, but only a single value is actually returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll update this
This might be a good time to fix that typo in the last word of the |
Good catch with the typo @gilch. I hadn't fixed it in both locations. |
Polished the documentation a bit again. Anything else that needs some cleaning up here or would this soon be good to go? |
👍 |
1 similar comment
👍 |
As this has multiple thumbs up already, I'll merge this one too (even if I'm the originator). |
Adds docs and tets for as-> macro. I had trouble running tests locally, but now that I tried to reproduce it to write down the error message they passed. So please check if that happens on your machine too.
relates to #1047