Is this an inaccurate description of function purity?

I think this description of function purity is inaccurate.

From the docs

A function is pure if it does not access any persistent storage. Conversely, the function is impure if it does access any storage.

Shouldn’t a pure function also exclude reading from the blockchain, such as height, timestamp, msg_sender, etc…?

https://fuellabs.github.io/sway/v0.42.0/book/blockchain-development/purity.html

2 Likes

Hey @tsk appreciate you for bringing this up. Had some interesting internal discussions around your comment and the final response from the compiler team was

“Purity is a very overloaded term. It could mean the narrow sense that relates only to storage, which is what is actually being checked and what the linked docs are talking about or some larger sense of interaction with the blockchain.
We even use it in the docs in some places to talk about some different feature predicates used to have. So I don’t think there’s a clear defined meaning at this time.”

2 Likes

thanks for the clarification

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.