Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Feature idea: strict modules #406

Open
@rurban

Description

@rurban

https://instagram-engineering.com/python-at-scale-strict-modules-c0bb9245c834 argues that certain properties violate strict modules.
The problems:

  • slow startup and reload
  • unsafe import side effects
  • mutable global state

The compiler already detects such misuse, using wrong times when code is executed. i.e. INIT vs BEGIN, or global code.

  • no side-effects when loading a module, "no code on load":
    like io, changing global state - excluding adding functions. compared to doing that in the importer.
    i.e. no global print, no assignments, no if. just declarations and setting $VERSION, @ISA, ...
  • Immutability and slots: classes and fields should be immutable by default with cperl. (the never implemented use oo :closed perl6 pragma)

The biggest violator would be Moose, that's why it became uncompilable in recent years with its new maintainer. Because global code inside modules was executed on load, and not on import.
A new strict mode for modules would detect that.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions