-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Use accessors macros for lazy initialization #255
Conversation
I didn't know about initializers in property macros, and I don't like it, I prefer the explicitness of actual methods. |
@ysbaddaden To me it's weird at least since it's a prime example of dogfooding, lazy block initialization is in stdlib since some time already and found its way into the codebase throughout the place, including compiler. Most recently I've seen it being used by @RX14. Attitude like this IMO will lower confidence in stdlib features for no reason other than your personal preference. That's sad since you do great job on technical side, yet it seems to me that you treat shards as (only) your personal project and accept almost no external input, or at least discussion regarding the style or new features. |
These things are not mutually exclusive. And I'm not arguing, I'm just trying to use the features that Crystal's stdlib provides, in order to cut down on boilerplate code... I mean c'mon, why choose the unnecessarily longer way... class Foo
@foo : String?
def foo
@foo ||= compute_foo
end
def foo=(@foo)
end
end
# vs
class Foo
property(foo : String) { compute_foo }
end |
I agree with @Sija . But I also agree with @ysbaddaden : this is mostly his project (even though it's in the |
@ysbaddaden is the maintainer of shards, and has been doing a fantastic job of it. I'm more than happy for him to set the style of the whole project. Arguing that it will "lower confidence in stdlib features" is a big stretch. |
From the technical perspective I'd fully agree, yet OSS is more than one person's viewpoint. What bothers me is lack of openness, discussion and collaborative approach to anything that @ysbaddaden doesn't agree with (i.e. closing PRs with nothing more than "I don't like it." response). I admit that's his right, no one said you ought to act nice towards contributors, it's just that such attitude is disenchanting. Summing up this already long comment, it's not that much about why, but how.
Perhaps, yet seeing willingly divergent approaches under an umbrella of one organization begs asking question why is it so? If another maintainer from the same org happens to purposefully avoid certain features from stdlib, one might conclude that there's sth wrong with the features themselves... Lack of cohesiveness from within the core team might throw a shadow on the organization/language itself. |
Well, if you don't know anything about |
There is |
I apologize for closing so fast after barely looking at the patch. I'm not saying this is bad, it may eventually be the standard way to lazy initialize class/instance variables safely in a MT Crystal (assuming it's updated to deal with sync/races). I'll be happy to make the change then. Maybe I'll even adopt it in new projects or when we'll rework Shards internals —which are messy and not suited for a library. But today? This is just the same. No benefit to the Shards application. It's a mere stylistic (thus opinionated) change that will pollute the Git history... again. Having one stylistic change ain't much, but having more and more makes digging through the history (like searching for why was I'm closing stylistic refactors fast and barely look at the patch. Let's make these changes as we rework the code instead, that is along with an actual technical enhancement (app feature, API rework). |
I've noticed an opportunity to reduce boilerplate code with accessors macros.
Not a big deal and you can call it pedantic but imo it improves code readability and cuts down on footprint and eye-strain ;)