Skip to content
New issue

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

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

Already on GitHub? # to your account

DIP 01: Modules #3

Open
z80dev opened this issue Sep 20, 2022 · 0 comments
Open

DIP 01: Modules #3

z80dev opened this issue Sep 20, 2022 · 0 comments

Comments

@z80dev
Copy link
Member

z80dev commented Sep 20, 2022

Modules

This is a big one. The idea is mainly to enable a multi-file workflow where Vyper currently pushes you to a single-file workflow.

Vyper's imports are currently limited to interfaces.

We want to support the following features:

  • import code (internal+external functions)
  • import structs
  • import events

We have a dumb implementation now: we have a c-style include! macro now that does what it sounds like. Notably, this is also how solidity's imports work when not specifying an object to import from the target file

Features to maybe implement❓🤨

Multiple imports of the same module

Does it make sense for a module to be imported twice? Kinda a contrived example but in theory could happen.

Let's say we have a contract that manages two sets of internal ERC20 logic/state. How should we handle this❓🤨

It wouldn't be too hard to write a macro that nests all the imported logic one level deeper into a hashmap where the lookup key represents "which" ERC20 module we're dealing with. Messy and ugly, but so is importing the same module twice

Import specific named items

Import a specific struct, function, event, etc.

Override an imported entity

So something like, import all the code from this file, but replace _____ with this thing

(import! "otherfile.dasy"
  :overrides [symbol (fn [] ...)])

or something

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

No branches or pull requests

1 participant