[swift-evolution] [Pitch] Support for pure functions. Part n + 1.
T.J. Usiyan
griotspeak at gmail.com
Thu Feb 16 14:41:20 CST 2017
I held your opinion, although not terribly steadfast. Joe Groff convinced
me that I was being pedantic with
"'inout' is 'value goes in, value-prime goes out'" and the fact that it
composes; you could use pure `+=` on a local value inside another pure
function.
The specific details of `inout` mean that it is a pure implementation of an
impure concept.
On Thu, Feb 16, 2017 at 3:32 PM, Hooman Mehr via swift-evolution <
swift-evolution at swift.org> wrote:
> By its classic definition, a function that has inout parameters is not
> pure. So, again by classic definition, it should have a return value to
> have any use. But things can quickly get murky if we try to enhance and
> extend the meaning of pure. Then it becomes important to see at what level
> of abstraction the function is pure and would would be the practical effect
> of making compiler aware of it. Identifying classic pure functions helps
> compiler better optimize the code, so it would be advantageous if the
> compiler can correctly identify pure functions.
>
>
> On Feb 16, 2017, at 12:03 PM, Nicolas Fezans via swift-evolution <
> swift-evolution at swift.org> wrote:
>
>
> > If it mutates whatever the input is referencing, it would have a
> side-effect which makes it "not pure" (for my understanding of what “pure”
> means).
>
> I am not really sure of it (I have not played around with it until now)
> but I don't think that this is an issue with the swift inout, cf.
> https://developer.apple.com/library/content/documentation/
> Swift/Conceptual/Swift_Programming_Language/Declarations.html#//apple_ref/
> doc/uid/TP40014097-CH34-ID545
>
> Nicolas
>
>
> On Thu, Feb 16, 2017 at 8:55 PM, David Sweeris via swift-evolution <
> swift-evolution at swift.org> wrote:
>
>>
>> > On Feb 16, 2017, at 11:27 AM, Sean Heber via swift-evolution <
>> swift-evolution at swift.org> wrote:
>> >
>> > Doesn’t this break down if you can pass a reference as a parameter to a
>> pure function? If that’s not allowed, I guess I must have missed it. Also
>> this seems to require the function has a return value. I suppose generally
>> a pure function without a return value wouldn’t make much sense - unless
>> you pass it a reference.
>>
>> If it mutates whatever the input is referencing, it would have a
>> side-effect which makes it "not pure" (for my understanding of what “pure”
>> means).
>>
>> - Dave Sweeris
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
>
> _______________________________________________
> 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/20170216/4936f2fc/attachment.html>
More information about the swift-evolution
mailing list