dtolnay / dtolnay/watt

Addressing crate local state for procedural macros problem

Open
#43 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.5k
Forks
31
PR merge metrics
No merged PRs in 30d

Description

Hi! Thank you for this cool work!

I think that this approach could also address this [issue](https://github.com/rust-lang/rust/issues/44034). More precisely, I mean persistent data storage for all macros. This could be obtained by Wasm multimodules approach and sharing the same memory for one modules. Moreover, [SQLite](https://github.com/fluencelabs/sqlite) or [Redis](https://github.com/fluencelabs/redis/tree/wasm) could be used to save state. All of them compiled in such a way to work like in-memory db without any imports. With our proc macro they could be used in the following way:

```rust
#[invocation_handler(side_modules = redis)]
fn run(arg: String) -> Vec {
redis::call("SET A 1")
}

#[invocation_handler(side_modules = sqlite)]
fn run(arg: String) -> Vec {
sqlite::call("SELECT * FROM Table")
}
```
And I can adapt them to any convention.

What do you think about that? I haven't look at the internals of `watt`, so can't estimate how many should be add to support this idea.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading watt's internals and Rust issue #44034 to understand procedural-macro local state and the proposed shared-memory model. Compare the invocation_handler side_modules examples with the SQLite and Redis WebAssembly approaches; done means reaching a maintainer-backed decision on feasibility and scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
redis, rust, sqlite, wasm
Domain
compilers, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.