[Python-Dev] Re: 3.10 change (?) for __bool__

2021年1月14日 03:48:55 -0800

Hello,
On 2021年1月14日 22:05:37 +1100
Steven D'Aprano <[email protected]> wrote:
> On Wed, Jan 13, 2021 at 08:17:26PM +0300, Paul Sokolovsky wrote:
> 
> > > Besides, we probably don't want to prohibit side-effects in
> > > `__bool__`. That would prohibit useful tricks such as putting
> > > logging calls into a method you are trying to debug. 
> > 
> > Surely, if we do that, we wouldn't use Haskell's definition of
> > purity ;-). Rather, a practical definition of purity,
> > Python-style. 
> 
> It's not *Haskell's* definition, it's pretty much *everyone's* 
> definition of pure.
> 
> https://en.wikipedia.org/wiki/Pure_function
> 
> 
> 
> > For example, print() would be considered "pure", as its purpose is
> > to provide program output, not arbitrarily change program state 
> 
> 
> Is writing to an external file a change to program state? Keep in
> mind that programs can get state from external files.
Please reread the reply about "not having non-local side
effects". NotHavingNonLocalSideEffects is a bit longish for an
annotation identifier though...
> 
> I would say that what you are describing is not a distinction between 
> pure and impure functions,
You say that as if you propose some better identifier for
annotation ;-). I personally would be fine if the annotation is:
def print(*Any) -> PythoniclyPure: ...
I'm talking about small-scale semantic distinctions required for capture
needed large-scale semantic effect. Naming, when it comes to it, will
be subject of long, looooooong bikeshedding. (Which already started,
thanks!)
> based on whether or not they can be safely 
> optimised away without a change in visible behaviour. The distinction 
> you are proposing is into two arbitrary sets of functions, some of
> which can be optimized away and some which can't, regardless of
> whether or not that optimisation leads to change in visible behaviour.
> 
> If you want to argue for that, fine, do so, but don't call impure 
> functions "pure".
[]
-- 
Best regards,
 Paul mailto:[email protected]
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/QBWTRDJZHDXYAOY42DZMETRNPOLHPFZH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to