With an object declaration like
type
Question = ref object
what: string
answer: int
is anybody using in procedures operating on these types Python (self) or JavaScript (this) style naming of the object paramter, e.g.:
proc setToStandard(self: Questions) =
self.what = "What's the answer?"
self.answer = 42
self/this as parameter name would indicate that the procedure setToStandard is thought of as a method to the "class" type Question.
Or is this "uncool" in Nim circles?
Self or this is impractical since there could be more then one self or this. When you have a proc in a proc etc.
I would ever go for a descriptive name. In case of "Questions" I would use "questions"
I use this quite a bit, there was/is a deprecated feature {.this:self.} which made this really nice to use.
{.this:self.}
type
Question = ref object
what: string
answer: int
proc setToStandard(self: Questions) =
what = "What's the answer?"
answer = 42
sadly for me, this is deprecated now, but it's still usable. but I guess it'll go away in a future version.
I use this as a first param (I don't like using using).
I think it's fine, why not?
Another example that theindex is not discoverable and we need a better search in Nim docs. cc @haxscramper
doc search has its flaws (there are already open issues for it), and I'm all for better search features (eg using karax, better spell correcting, and more advanced query options), but in this case IMO it's a user error, with is the 1st thing that shows up with you type with in search bar.
I do not use self/this I think its better to use a descriptive name. This seems to be the style of other nim code.
proc setToStandard(question: Question) =
question.what = "What's the answer?"
question.answer = 42