5 ms·
Well, given that Rust and C# also have these features I think the likelihood that the patent is upheld is unlikely. I guess they could threaten you with it sinc
by kbsletten 8y ago
Well, given that Rust and C# also have these features I think the likelihood that the patent is upheld is unlikely. I guess they could threaten you with it since lawyers are expensive, but it seems silly to me.
- masklinn 8y agoFWIW Rust does not have optionals chaining, except in the monadic sense (in which case ML and Haskell have optionals chaining). That is, in Rust you'd use Option::map or Option::and_then, there is no equivalent to the `?.` and `?[]` operators, the `?` operator (or `try!` macro) is a shortcut for an "unwrapping guard".
- lalaithion 8y agoRight, but isn't `?.` just syntactic sugar on `Option::and_then`? Is this a patent on a piece of syntactic sugar, or is it a patent on the idea of chaining optional values?
- saghm 8y agoRuby does seem to have the exact thing: http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/ http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/
- _Codemonkeyism 8y agoGroovy had null (optional) chaining https://therealdanvega.com/blog/2013/08/20/groovys-null-safe-operator https://therealdanvega.com/blog/2013/08/20/groovys-null-safe...
- tasubotadas 8y agoand Kotlin https://kotlinlang.org/docs/reference/null-safety.html https://kotlinlang.org/docs/reference/null-safety.html
- vorg 8y agoIn Apache Groovy you need to write `a?.b?.c` for nullsafe chaining on both `b` and `c`. In the past, its project managers have discussed propagating nullsafety down the chain so you'd only need to write `a?.b.c` to make both `b` and `c` nullsafe, but they've never implemented it. Not sure if that's in Rust, Kotlin, C#, or Ruby, or in Groovy's Antlr 4 parser.
- dep_b 8y agoI'm also pretty sure I had it in C# before Swift was introduced.
- dotuser 8y agoone thing though, in swift you can actually mutate fields using optional chaining, e.g. person?.name = "Bob". you can't do that in c#. not sure about rust but in scala you would unwrap the optional with a foreach or something.
- rhodysurf 8y agoYeah and using optionals in rust vs swift makes rust super annoying to use because of that.
- zmmmmm 8y agoIn Groovy you can mutate through optional (null-safe) chaining, eg: x = [ foo: [ bar: 1] ] x.foo.bar // 1 x.boo?.bar // null because x.boo is null x.boo?.bar = 1 // succeeds even though x.boo is null x.boo // still null
- dotuser 8y agoI knew I had seen this somewhere else. I don't understand why C# doesn't support this since most C# code is mutable anyway. I can see why it doesn't fit well with functional languages but C# usually espouses pragmatism over purity and having this would clean up a lot boilerplate null checking.
- pnw_hazor 8y agoDo Rust and C# implement these features the same exact way as Apple claims in this patent? Patents protect how you something, not what you do.
- dotuser 8y agoTechnically speaking, C# does not have optionals so I don't think it can be argued that C# violates the patent unless it's generalized to include null propagation which operates on reference types.
- int_19h 8y agoC# Nullable<T> is optional for all purposes (a struct with .Value and .HasValue), it's just restricted to value types.
- dotuser 8y agoright, c#'s nullable types are the ultimate in syntactic sugar in that you can just use them like regular value types in most places without realizing they are monads underneath.
- int_19h 8y agoI wouldn't say they have substantially more syntactic sugar than other languages with the same. If you need to use them in the context that is not optional, you need to use HasValue/Value, or casts, or (since recent versions) pattern matching to extract the value. The only special sauce I can think of is that C# also implements null-lifting for most operators in the language, which is not necessarily a good thing because it treats null as "unknown" rather than "missing" - e.g. a + b works on int?, and will produce null if either a or b is null. With Boolean operators, it's even clearer - false & null is false, true | null is true, but true & null is null, and false | null is null. But quite often this is not what I actually want! If null really means that the value is missing, then a + b shouldn't even compile for optionals. But in practice, I'd say that vast majority of all uses of Nullable are to denote missing rather than indeterminate values.