Repository navigation
Add const keyword - #452
LesterEvSe wants to merge 5 commits into
Conversation
0155419 to
75deb43
Compare
fbc9738 to
d8401ca
Compare
stringhandler
left a comment
There was a problem hiding this comment.
One thing I'm not sure about:
Is it possible to add const inside a function body? If so, how is that different from let?
I'm confused about what the difference is. A pure function and a const should compile identically. (I know they don't, and that functions are always compiled to evaluate all their code even if they could be elided and replaced by a const word or a lookup, but this is an optimization bug.) We could add a |
|
Side note here, but I didn't see any relationship to #451, even though the description mentions it |
No, The difference from One limitation is writing |
It's just easier for me to resolve the merge conflicts here rather than in the errors branch |
|
But we can do it in another order. It is not critical |
dcb5f9a to
7983356
Compare
d8426dc to
efe06b4
Compare
Agreed, codegen isn't the reason, I'll fix the description. The reason is the guarantee, where a |
efe06b4 to
063cc08
Compare
063cc08 to
2aa4312
Compare
Previously, this functionality was deleted in #323 along with the old
modkeyword support, but the lexer and parser still support this. So now we reintroduceconst.A
constis a named, compile-time value. Its initializer must be a constant expression, and each use compiles to the precomputed value. Unlike a zero-argument function, which can read the transaction (e.g.jet::num_inputs()), aconstis guaranteed to be fixed data. Constants can bepuband imported withuse, like other items.A motivating example is sha256_paddings.simf in the price-oracle repo.
So now we can do something like this:
Checklist
fixtures/kitchen_sink.simf(see its header).