BlockstreamResearch / simfony

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

Update byte strings #43

Closed uncomputable closed 3 months ago

uncomputable commented 3 months ago

Make byte strings compatible with Rust by disallowing nibbles and strings longer than 16 bytes. Display erratic length for easier debugging. Allow underscores for visual separation inside the string.

apoelstra commented 3 months ago

Done reviewing 490e388e1eea1882239b52eb753407b008ace1a6. I guess this is ok. Rust's awful support for hexadecimal literals is one of its worst syntactic problems, and possibly the only one that has continually bothered me for over a decade without ever getting better or my getting acclimated to it.

So I guess, if this is the only compromise we make for "Rust compatibility" that's okay.... but it's a really big compromise and it makes me want to drop that goal, so we should be mindful if we find ourselves making other bad syntactic choices like this.

ACK other than grammar nits.

uncomputable commented 3 months ago

I expect that Simfony will never be 100% syntactic Rust because of missing generics or something else that Simfony doesn't support. There will be a mechanical translation of Simfony source code to Rust source code, where we could also convert longer hex literals into shorter, Rust-compatible ones.

uncomputable commented 3 months ago

I was planning to remove u256 in favor of [u8; u32] or more specialized types like PublicKey, but I just realized that this will make Simplicity's 256-bit arithmetic jets really hard to use. It is really annoying to manipulate 256-bit values in Rust. So, I chose to keep u256 and its hex literals.