BlockstreamResearch / simfony

Rust-like high-level language that compiles down to Simplicity bytecode. Work in progress.
19 stars 6 forks source link

Update Scope #23

Closed uncomputable closed 3 months ago

uncomputable commented 4 months ago

Enable the scope to track environment values of arbitrary shape (in particular without an initial unit value). This makes it possible to create scopes for functions that expect a specific input type (the function's environment). Compute Simplicity expressions that translate between Simplicity values. The translation expression is compressed.

This is the first step to keep the Simplicity target program and its memory footprint small.

uncomputable commented 4 months ago

@apoelstra Feel free to take a look

apoelstra commented 4 months ago

Interesting observation that witness names are inherently unscoped. I wonder if we should require the user declare them all at the top of the file or something?

At least we should add a lint saying that they should be in all caps, or something, since they are special.

apoelstra commented 4 months ago

In 8a3ec03f3a756dcc0d1133e36416ccc7a80195b6:

I would prefer we explicitly write GlobalScope::new(Pattern::Ignore) rather than GlobalScope::default. I would even suggest dropping the Default impl from GlobalScope unless there's a strong usecase for it.

apoelstra commented 4 months ago

In 473493b409b0ac2d52912fc4caa7902be40b8af3 (final commit):

I wonder if you could use Pattern::clone rather than .clone and .cloned so that it would be clearer what type is being cloned, and easier for users to look it up and see that it's a cheap (Arc) clone.

uncomputable commented 4 months ago

Let's focus on #27 for now and come back to this after Bitcoin++