-
Notifications
You must be signed in to change notification settings - Fork 58
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
feat(lightpush): add waku lightpush protocol client #1295
Conversation
Jenkins BuildsClick to see older builds (2)
|
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.
LGTM 😁
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.
some minor comments
|
||
if node.wakuRelay.isNil: | ||
if node.wakuRelay.isNil(): |
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.
Just a question.
Is there a common consensus on weather to use isNil
, isOk
or isNil()
and isOk()
? Can see both usages across the repo, and afaiu its exactly the same, just like echo x
or echo(x)
I guess.
Both are fine for me just wondering which one to use. I can actually see that nimbus also mixes both.
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 don't think there is consensus yet, maybe a good addition to the nwaku style guide?
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.
invoking @jm-clius then, since he is writing a style guide :)
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.
Right, I don't have a strong preference here. Personally I find echo x
to be the most readable, but for more obvious templates and procedures I like isNil()
and isOk()
with ()
(also because my editor highlighting works better this way).
I'm happy to add this (or whatever we have consensus on) to the coding/style guide.
However, Nim syntax inherently allows for some flexibility. In some cases where there is a clear benefit to preferring one alternative above the others, we should be prescriptive. Example here would be to avoid using result
returns, avoid overly long lines, use std/
prefix for standard imports, etc.
I'm worried though that being prescriptive everywhere where there's flexibility, would tie contributors up in trying to follow a pedantic style guide rather than just understanding the language and its usage. An example here would be if we become prescriptive in using explicit return
vs expression based returns. Not sure where the empty proc/template invocations above would fit in, but imo the impact of one choice above the other is low. The coding guide should be a simple reference, rather than keep us occupied with endless refactoring. Wdyt?
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.
yeap, totally agree. no need to be overly pedantic nor too strict in the coding guide.
imho agreeing that there is no consensus on isOk/isOk()
is an actual consensus.
Perhaps add just a suggestion. "in these occasions we tend to use isOk and in these isOk() because of this". But no need to enforce it.
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 have an strong opinion on this. I am following these rules for the sake of consistency and readability:
- Verbs must be followed by the parenthesis, since it denotes a "question" (e.g.,
isSomething()
,isOk()
,isNil()
) - Nouns must go without the parenthesis. A
proc
with a noun name should go without parenthesis. They describe "properties" (or "derived properties" in theproc
with a noun name) of certain object. (e.g.,Result.error
,Result.value
)
I prefer languages more opinionated in this sense. Nim is a language prone to style inconsistency.
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.
@LNSD, fair point. I think this is a good general guideline for us to add.
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.
LGTM!
df62ce7
to
24a4b5d
Compare
24a4b5d
to
5711b25
Compare
Merging this PR. @kaiserd, feel free to comment here after the changes are merged. I will address any concerns or suggestions in any of the upcoming PRs |
This refactoring was hastened due to the upcoming Dandelion++ support for the waku lightpush protocol.