News for hackers. Stuff that matters.
Re:The Logical Disaster of Null by RX14 on Thursday May 10, 2018 @07:21AM (#17037910)
Does swift have flow typing? The expressive power of sum types with nil is only exposed with flow typing. Also I don't think swift supports arbitrary sum types it just has a "fake" sum type syntax that only works with null. In crystal you can have an `Int32 | String` just the same as you can have an Int32?
Re:The Logical Disaster of Null by Zarel on Thursday May 10, 2018 @08:43AM (#17038312)
Swift doesn't have flow typing, unfortunately. It has a few constructs, like `guard let` and `if let`, which let you unwrap optionals in a somewhat nicer way than other languages and are sort of similar to one aspect of flow typing.
Re:The Logical Disaster of Null by AnimalMuppet on Thursday May 10, 2018 @12:37PM (#17040467)
I've seen this come up a couple of times in this discussion, so ELI5: What is "type flowing"?
Re:The Logical Disaster of Null by RX14 on Thursday May 10, 2018 @12:52PM (#17040608)
Flow typing is where the type of a variable changes based on control flow.

Consider:

    x : Int32 | String
    if x.is_a? Int32
      # typeof(x) == Int32
    else
      # typeof(x) == String
    end
Re:The Logical Disaster of Null by AnimalMuppet on Thursday May 10, 2018 @12:58PM (#17040670)
Thanks!
Re:The Logical Disaster of Null by Veedrac on Thursday May 10, 2018 @08:48AM (#17038353)
You mean "union type" where you say "sum type". AFAICT Swift does support sum types.
Re:The Logical Disaster of Null by RX14 on Thursday May 10, 2018 @10:33AM (#17039161)
yeah in crystal we call them union types. We don't have sum types so I'm not really certain on the difference.

I should have stuck to terminology I know.