| || | submitted by /u/pein_sama
Spedn is a high level smart contracts language for Bitcoin Cash. A new major version 0.2 has just been released.
This is 15th Nov 2019 hard-fork compatibility update with a bunch of changes and new features.
- Introducing an array type with syntax
[type; length], for example
[Sig; 3] signatures, [byte; 10] message. The compiler type-checks the lengths so for example a type of
message . message expression will be inferred as
- Syntax for tuple assignment now allows its items to be of different type:
(int a, Sig b, PubKey c) = expr;
- Array elements can be accessed with
- Introducing a
bit type. In practice only arrays of bits are useful, as they represent a type of
checkbits argument in the
checkMultiSig function which was upgraded for Schnorr support. Bit array literal is also introduced, ex.
[bit; 5] checkbits = 0b00110.
- As mentioned -
checkMultiSig accepts an additional
checkbits argument, as described in Nov 15 hard-fork spec.
- For a byte array of unknown size there is
[byte] type which replaces the former
- Introducing (UTF-8) string literals, ex.
[byte] message = "Hello, World";.
- Introducing custom type declarations (type aliases) which can be placed before contract declarations and then used as any other type in the contract. Ex.
type Message = [byte; 10];. Actually,
TimeSpan are defined internally as aliases.
separator; statement that compiles to
fail; statement that compiles to
checkSize(x) function that returns
true if the runtime size of a byte array matches the declared type.
- Variable names can now contain underscores, ex.
For developers of v0.1 there's a short migration guide which shows how to adjust an old contract code to the new syntax.