
On Jul 24, 2018, at 7:37 AM, Rhodri James <rhodri@kynesim.co.uk> wrote:
On 24/07/18 12:02, David Mertz wrote: Every use I've suggested for the magic proxy is similar to: NullCoalesce(cfg).user.profile.food Yes, the class is magic. That much more so in the library I published last night that utilizes wrapt.ObjectProxy. But it's also pretty explicit in that an actual*word* announces that funny stuff is going to happen on the same line.
Foo(cfg).user.profile.food
Is that explicit that funny stuff is going to happen on the same line? I wouldn't generally assume so, I'd just assume the coder created a throwaway object to get at an attribute. You have to know that "NullCoalesce" does magic before it is at all explicit that funny stuff will happen. Thinking about it, NullCoalesce() may be *less* explicit than ?. because at least that doesn't look like ordinary attribute reference.
I'm still of the opinion that both approaches are trying to solve a problem that's too niche to merit them, BTW.
-- Rhodri James *-* Kynesim Ltd
The fact that you changed NullCoalesce into Foo to show lack of explicitness seems a straw-man. Words are FULL of meaning, while symbols are less so. The biggest issue I see with the use of ? here is that ? does have some meaning, it says we are going to be (or have) asked a question, it doesn’t tell us what the question is. Most of the other symbols used have a long history of meaning (yes = has the problem that historically it has had two possible meanings). To me, ? gives no indication that it is going to ask about Nullness. ?. has some indication that we are doing an attribute access that is in some way conditional, but a?.b could mean that we are conditional on a not being null, or it could be asking to suppress any and all error in getting b, even if a is an int and thus doesn’t have a b. The words carry a lot more meaning.