BlockstreamResearch / simfony

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

Update docs #29

Closed uncomputable closed 4 months ago

uncomputable commented 4 months ago

Update documentation of Simfony's syntax. Include arrays, lists, fold and loops as experimental syntax. Fixes #16

apoelstra commented 4 months ago

Overall d25f5334296262ba046c3dc6915589e3ba9320f7 looks good. Definitely an improvement over the old outdated docs. I think the List type could maybe be described more clearly by analogy to binary numbers but I can't think of language that would be clear.

I guess at some point we'd like to generalize forWhile a bit so you don't need to use 2^2^n but that's separate from this PR.

apoelstra commented 4 months ago

Also the last commit d25f5334296262ba046c3dc6915589e3ba9320f7 has trailing whitespace somewhere . You can find it with git grep ' $'.

apoelstra commented 4 months ago

Ok, great, 91633efe33a31b963ab913ee273243e7917da7ca looks much better. I think this "macro" language maybe leaks too much of the implementation (like, does the user really care that Simfony expressions are "macroized" into Simplicity? and will this even continue to be true when we add optimization passes?).

In Miniscript we have an explicit design goal that every Miniscript node corresponds exactly to a fragment of Script. But here I guess, we want the semantics of Simfony expressions to exactly match those of Simplicity. But they don't necessarily need to compile down to exactly-specified Simplicity.

uncomputable commented 4 months ago

I think we will drop the macro language once we drop macro types. I used the word "macro" because a macro and its resolved type/value/expression are interchangeable, which is potentially confusing.

Once we reorder variable declarations and drop variables as soon as we can, expressions will no longer have exactly one translation to Simplicity. An expression in one part of the program can influence the translation of another part of the program.