-
-
Notifications
You must be signed in to change notification settings - Fork 414
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
Question about Option<int> #10
Comments
Hi Kasajian. There is a lazy Option type in the library, and that is
|
Thank you for the explanation. And I agree with you that that's the purpose of the Lazy class, for momization. I was just saying that if put aside as to how the value get inside of Lazy or Option, they are similar in that:
Lazy doesn't create inner Value until you attempt to access it via the Value property. If you use the version of Lazy where you provide an initialization function, then you can simply access the Value property to force it to contain a value when one exists. To illustrate, take a look a simple usage of it as an alternative to TryGetValue for Dictionary: (my alias is zumalifeguard) I can't disagree with you if your position is that using Lazy in this way is hackish and you may not want to rely on it for your framework. I was just curious if that, in fact, your stance. |
As I say the behaviour is different. Using a |
Thank you. You're right. When you have Option in your library, it's ideal. I was suggesting that without such library, if one wishes to return a value from a method that may be an object, null or no-value, then Lazy can be as an internal implementation that mimics Option. The client only sees a version of Lazy with a value or without a value. They don't use it to perform deferred instantiation. Anyway, I think I got the answer to my question. Thanks for your time. |
Forward events to JS process log
Very nice work.
I read the justification for Option<> and it occurred to me that it if you simply look at the basic Option class, without the extensions, it smells a lot like Lazy<>. I would curious what disadvantage there would be using Lazy<> instead of Option<> and making the rest of the framework base on that?
The text was updated successfully, but these errors were encountered: