0

[The] auto-close-on-collection feature of files is not part of the language definition... and may not work the same in other Python implementations whose garbage collectors may not reclaim and close files at the same points as standard CPython.

-- (294) "Learning Python" by Mark Lutz

My understanding is that language references describe the structure and syntax of the programming language--what functions are supported and how they can be used.

I'm not sure how this differs from language definition.

I included the source of my confusion above to contextualize. If a certain behavior occurs, doesn't that mean it was defined? Or is he saying that because it is not included in the language definition, different implementations can play with how this particular aspect of the language works?

All of this is to ask, what is the difference between definition and reference?

I tried looking to this source I found, but couldn't understand it: Forms of language specification

wjandrea
  • 28,235
  • 9
  • 60
  • 81
bhp
  • 101
  • 1
  • 7
  • 2
    CPython is one (reference) *implementation* of the Python *language*. Any implementation of Python needs to fulfill the definitions to actually be a "valid" implementation of the Python language. But such an implementation does *not* need to implement auto-close-on-collection. That is implementation-specific to CPython. – Jan Christoph Terasa Jun 13 '20 at 17:05
  • 1
    *"because it is not included in the language definition, different implementations can play with how this particular aspect of the language works?"* - yes, exactly – wjandrea Jun 13 '20 at 17:14
  • Can you clarify why you are asking about language definition *versus reference*? The quote does not mention the reference (implementation) as such, only "standard CPython". – MisterMiyagi Jun 13 '20 at 17:23

0 Answers0