---
title: "转换显式"
---

> Documentation Index
> Fetch the complete documentation index at: https://koine.systems/llms.txt
> Use this file to discover all available pages before exploring further.

# 转换显式

## 背景

度量衡和货币转换可以内置在类型系统里，也可以要求用户显式声明。

## 选项

- 类型系统隐式转换。
- 只允许同一类型运算。
- 显式 `conversion` 声明。

## 决定

转换显式。度量衡和货币转换必须用 `conversion` 声明；动态转换用 `using relation` 查当前世界。

## 理由

- 隐式转换会让 agent 需要更多上下文判断结果类型。
- 转换是可审计的业务规则，不是语言魔法。
- 单向声明让汇率、精度和方向都可见。

## 后果

跨单位运算要先声明转换，代码更长。转换方向单向，反向要单独声明。没有隐式度量衡或货币转换。

Source: https://koine.systems/notes/decisions/0010-explicit-conversion/index.mdx
