[swift-evolution] [Proposal idea] Support for pure functions

Howard Lovatt howard.lovatt at gmail.com
Mon Dec 21 15:46:58 CST 2015

-1 for using -> and => to mean different types of functions, not-pure and pure respectively. In fact I dislike using symbols unless they are really well known. Keywords read a lot better. 

Sent from my iPad

> On 22 Dec 2015, at 8:37 AM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
>> On Dec 21, 2015, at 12:20 PM, T.J. Usiyan via swift-evolution <swift-evolution at swift.org> wrote:
>> I have been thinking about this proposal since the list opened up.  I think that @read(none|only) should be considered as an alternative. Just as in clang and the optimizer annotations @read(none) would be the attribute described and @read(only) could read global variables but could not write. Is it possible to generate a runtime error if we guarantee that function A is pure, only to call it and 'find out' that it isn't? If we can, then do try syntax could be considered. 
> Another approach here is an effects system. If a pure function were spelled `(T) => U`, then `readonly` could be expressed as `(T) reads => U`, and (T) -> U could remain as a synonym for (T) reads, writes => U, in the spirit of encouraging immutability without punishing mutability.
> -Joe
> _______________________________________________
> 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/20151222/1e5f3eeb/attachment.html>

More information about the swift-evolution mailing list