[swift-evolution] Proposal: An assignment operator := that ensures nil before assignment.

Craig Cruden ccruden at novafore.com
Sat Feb 27 10:20:17 CST 2016


I am confused.  This is a magical operator that does two things…. if it is a very special case of nil before then it asserts - but if it does not it assigns?

I would think you would simply do an assert (condition) and potentially an error text.  

nil / nul exceptions (java experience) makes up more than 50% of defects (due to the original lack of optionals), but the that is what the optional in Swift is suppose to take care of through a the type system.  

nil is actually not “nil” in the traditional sense but “None” as in the optional of it.  




> On 2016-02-27, at 23:10:37, Amir Michail via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> 
>> On Feb 27, 2016, at 11:07 AM, Stephen Celis <stephen.celis at gmail.com> wrote:
>> 
>> 
>>> On Feb 27, 2016, at 10:57 AM, Amir Michail <a.michail at me.com> wrote:
>>> 
>>>> On Feb 27, 2016, at 10:39 AM, Stephen Celis <stephen.celis at gmail.com> wrote:
>>>> 
>>>>> On Feb 27, 2016, at 10:38 AM, Amir Michail <a.michail at me.com> wrote:
>>>>> 
>>>>> I think this := would be used so often that it should be part of the language/standard library.
>>>> 
>>>> Would you please justify this? Would you please answer the questions from my reply?
>>> 
>>> See: http://research.microsoft.com/apps/pubs/default.aspx?id=70290
>> 
>> See what part? This document provides no justification for any kind of assignment/assertion operator. Please provide additional context around links you share and how they relate to your actual proposal.
> 
> The justification for assertions in general is empirical and the Microsoft paper provides it.
> 
> To explore how useful := assertions are in particular would need a study like the Microsoft one that focuses exclusively on := assertions.
> 
>> 
>> In this case your proposal still needs justification. Would you, again, please answer these questions to provide it?
>> 
>> - Why do you want this feature?
>> 
>> - Would you please provide a better, real-world example (perhaps code extracted from a real-world project you've worked on that would benefit) that demonstrates the benefits of your suggestion?
>> 
>> - Can you go into more detail on the the design of the proposal? How it may be implemented? Caveats? Alternatives considered?
>> 
>> --
>> Stephen
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160227/42331402/attachment.html>


More information about the swift-evolution mailing list