Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions language/assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ Conceptually each operand is a bag of `(policy, asset_name, amount)` entries; ad

The value attached to an input or reference participates in the same arithmetic: `source - Ada(quantity) - fees` makes sense because `source` is an asset value.

## Scaling

Multiplying an `AnyAsset` by an `Int` scales every entry's amount. The `Int` may be on either side, and `*` binds tighter than `+` and `-`:

```tx3
StaticAsset(50) * quantity
Ada(2000000) + StaticAsset(1) * count
```

## Reading asset components

An `AnyAsset` exposes three properties:
Expand Down
6 changes: 4 additions & 2 deletions language/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ The operator surface is small.
| `expr.identifier` | Property access. Available on records, variant struct cases, `AnyAsset`, and `UtxoRef`. |
| `expr[expr]` | List indexing. The index expression must have type `Int`. |
| `!expr` | Arithmetic negation. Applies to `Int`. |
| `a * b` | Multiplication. `Int * Int` multiplies integers; `AnyAsset * Int` (and `Int * AnyAsset`) scales asset quantities. |
| `a + b` | Addition. `Int + Int` adds integers; `AnyAsset + AnyAsset` aggregates asset values. |
| `a - b` | Subtraction. Same shapes as `+`. |

Precedence, from tightest to loosest:

1. Postfix `.` and `[…]`.
2. Prefix `!`.
3. Infix `+` and `-`.
3. Infix `*`.
4. Infix `+` and `-`.

Parentheses override precedence. There are no comparison, logical, multiplication, division, or ternary operators in this version of the language.
Parentheses override precedence. There are no comparison, logical, division, or ternary operators in this version of the language.

## Constructors

Expand Down