Re: [julia-users] Understanding Nullable as immutable

2016-09-21 Thread Fengyang Wang
Yes, I've been meaning to submit a PR. The last one contained several other changes which were substantially more controversial. My plan was to split the PR up into smaller changes. On Wednesday, September 21, 2016 at 4:48:21 PM UTC-4, Páll Haraldsson wrote: > > On Wednesday, September 21, 2016

Re: [julia-users] Understanding Nullable as immutable

2016-09-21 Thread Páll Haraldsson
On Wednesday, September 21, 2016 at 4:50:26 PM UTC, Fengyang Wang wrote: > > but type piracy is bad practice. This method should really be in Base. > As always, if something, should be in Base or Julia, then I think a PR is welcome. [Maybe I do not fully understand this (yes, type piracy I

Re: [julia-users] Understanding Nullable as immutable

2016-09-21 Thread Randy Zwitch
OH! That makes a big difference in usability. :) On Wednesday, September 21, 2016 at 12:50:26 PM UTC-4, Fengyang Wang wrote: > > There is no need to modify a copy; only the Nullable is immutable and not > its underlying value. Just instead of modifying ec.title, modify > get(ec.title). Like

Re: [julia-users] Understanding Nullable as immutable

2016-09-21 Thread Fengyang Wang
There is no need to modify a copy; only the Nullable is immutable and not its underlying value. Just instead of modifying ec.title, modify get(ec.title). Like setfield!(get(ec.title), k, v). In short scripts, I often define getindex(x::Nullable) = get(x) so that I can write ec.title[] instead

Re: [julia-users] Understanding Nullable as immutable

2016-09-21 Thread Randy Zwitch
So get() to check if a value is there, and if there is modify a copy then overwrite? If that's the case, it might be worth the mental overhead to use Nullable types when mentally I'm viewing everything as a consistently mutating object until the desired result is achieved. On Wednesday,

Re: [julia-users] Understanding Nullable as immutable

2016-09-21 Thread Yichao Yu
On Sep 21, 2016 9:42 AM, "Randy Zwitch" wrote: > > I frequently have a design pattern of Union{Title, Void}. I was thinking that I could redefine this as title::Nullable{Title}. However, once I try to modify fields inside the Title type using setfield!(ec.title, k,