Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Create developer guide for Python, remove leading whitespace from designs folder name #783

Open
wants to merge 5 commits into
base: main-1.x
Choose a base branch
from

Conversation

lucasmcdonald3
Copy link
Contributor

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@lucasmcdonald3 lucasmcdonald3 changed the title docs: Create developer guide for Python docs: Create developer guide for Python, remove whitespace from designs folder name Feb 5, 2025
@lucasmcdonald3 lucasmcdonald3 changed the title docs: Create developer guide for Python, remove whitespace from designs folder name docs: Create developer guide for Python, remove leading whitespace from designs folder name Feb 5, 2025
@lucasmcdonald3 lucasmcdonald3 marked this pull request as ready for review February 7, 2025 17:38
@lucasmcdonald3 lucasmcdonald3 requested a review from a team as a code owner February 7, 2025 17:38
Copy link
Contributor

@kessplas kessplas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@texastony texastony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is brilliant.
Champion.

Comment on lines +9 to +15
1. Python imports modules based on filepath.
If a module is located at `my_project/internaldafny/generated/SomeModule.py`, it must be imported as `my_project.internaldafny.generated.SomeModule`. (There are some hacks to work around this, but these are hacks.)
This contrasts with Java/.NET, which import modules based on declared namespace. (ex.) Java might have a file at `dafny-generated/SomeModule/SomeClass.java` , but that class declares `package SomeModule` . To import this class, you would write `import SomeModule.SomeClass`.
2. Python links externs to generated code at runtime.
When a Dafny-Python module is imported, it runs initialization glue code that will 1) import all of its generated Dafny (in a topological order to avoid circular dependencies), 2) import all of its externs.
Then, each extern class must 1) extend the generated class, 2) override the generated class with the extern class.
This contrasts with Java/.NET, where the externs extend partial/base generated classes, and link together at compile time.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Praise: this is clear. Well done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants