Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve docs #216

Merged
merged 8 commits into from
Oct 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move operators to types
  • Loading branch information
mr-zwets committed Oct 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit e17543f6833b5354009e408d78de00afa1dc3bd3
27 changes: 1 addition & 26 deletions website/docs/language/functions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Global Functions & Operators
title: Global Functions
---

CashScript has several built-in functions for things like cryptographic and arithmetic applications, and it includes many common arithmetic and other operators that you would expect in a programming language.
@@ -99,29 +99,4 @@ bool checkDataSig(datasig s, bytes msg, pubkey pk)

Checks that sig `s` is a valid signature for message `msg` and matches with public key `pk`.

## Operators
An overview of all supported operators and their precedence is included below. Notable is a lack of exponentiation, since these operations are not supported by the underlying Bitcoin Script.

| Precedence | Description | Operator |
| ---------- | ----------------------------------- | ------------------------ |
| 1 | Parentheses | `(<expression>)` |
| 2 | Type cast | `<type>(<expression>)` |
| 3 | Object instantiation | `new <class>(<args...>)` |
| 4 | Function call | `<function>(<args...>)` |
| 5 | Tuple index | `<tuple>[<index>]` |
| 6 | Member access | `<object>.<member>` |
| 7 | Unary minus | `-` |
| 7 | Logical NOT | `!` |
| 8 | Multiplication, division and modulo | `*`, `/`, `%` |
| 9 | Addition and subtraction | `+`, `-` |
| 9 | String / bytes concatenation | `+` |
| 10 | Numeric comparison | `<`, `>`, `<=`, `>=` |
| 11 | Equality and inequality | `==`, `!=` |
| 12 | Bitwise AND | `&` |
| 13 | Bitwise XOR | `^` |
| 14 | Bitwise OR | \| |
| 15 | Logical AND | `&&` |
| 16 | Logical OR | \|\| |
| 17 | Assignment | `=` |

[bip146]: https://github.com/bitcoin/bips/blob/master/bip-0146.mediawiki
27 changes: 26 additions & 1 deletion website/docs/language/types.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Types
title: Types & Operators
---

CashScript is a statically typed language, which means that the type of each variable needs to be specified. Types can also be implicitly or explicitly cast to other types. For a quick reference of the various casting possibilities, see [Type Casting](#type-casting).
@@ -186,3 +186,28 @@ VM numbers follow Script Number format (A.K.A. CSCriptNum), to convert VM number
:::caution
When casting bytes types to integer, you should be sure that the bytes value fits inside a 64-bit signed integer, or the script will fail.
:::

## Operators
An overview of all supported operators and their precedence is included below. Notable is a lack of exponentiation, since these operations are not supported by the underlying Bitcoin Script.

| Precedence | Description | Operator |
| ---------- | ----------------------------------- | ------------------------ |
| 1 | Parentheses | `(<expression>)` |
| 2 | Type cast | `<type>(<expression>)` |
| 3 | Object instantiation | `new <class>(<args...>)` |
| 4 | Function call | `<function>(<args...>)` |
| 5 | Tuple index | `<tuple>[<index>]` |
| 6 | Member access | `<object>.<member>` |
| 7 | Unary minus | `-` |
| 7 | Logical NOT | `!` |
| 8 | Multiplication, division and modulo | `*`, `/`, `%` |
| 9 | Addition and subtraction | `+`, `-` |
| 9 | String / bytes concatenation | `+` |
| 10 | Numeric comparison | `<`, `>`, `<=`, `>=` |
| 11 | Equality and inequality | `==`, `!=` |
| 12 | Bitwise AND | `&` |
| 13 | Bitwise XOR | `^` |
| 14 | Bitwise OR | \| |
| 15 | Logical AND | `&&` |
| 16 | Logical OR | \|\| |
| 17 | Assignment | `=` |