Beta
Callchain - Decorators
Loading description...
Decorator
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
How does inserting multiple callbacks with different
n
s work? Depending on the meaning ofn
it can mean one of these things:n
is the priority of the callback; callbacks are order byn
, then register order. This means usingcallback(1)
after manycallback(0)
will not affect the ones registered withcallback(0)
n
is the order of the callback stack at the moment; callbacks are treated as a list that can be inserted anywhere. This means usingcallback(1)
after manycallback(0)
will push all registeredcallback(0)
callbacks except the last registered one after this callbackIn the current design it implies the latter (from the default value being
n
, andn
called atnumber of callbacks
), but this design is unhinged and absolutely nightmarish to use.Also, note that the test only tests a single use of
n = 0
, so it doesn't touch any of the scenario above, and both implementations will pass. This needs to be explicitly tested.Random tests have fixed structures with randomized arguments, which is not acceptable. It is very easy to hard code against this (especially since it is the same structure as the sample tests).
The semantics of result passing and arity handling is not defined anywhere. Apparently
root
can be in any arity, while every callback function must have arity 1 (and every returned result is directly passed to the next function). Having different handling for root and branch nodes is certainly not expected (also technically you can pass around multiple arguments by spreading an array, like in JS), and should be specified.Cool kata!
I would include in the description that parameterless uses of the
callback
decorator should act the same as if called withn > number of callbacks
. Right now it's unclear what order something like the following should produce:Thank you very much for your feedback ✌ I edited the description to include that point