本文へ移動
cccskills
無料GitHub で公開

salam

Use when writing, reading, debugging or reviewing Salam source (.salam files) - the Salam programming language with English/Persian keywords. Covers its enforced declaration ordering, the `until` = `while` rule (there is no `while`), `switch` vs `match`, the enum comma requirement, stdlib lookup, and the toolchain traps that silently produce wrong behaviour. Triggers on .salam files, "Salam", "salamlang", or any request to compile, check or run Salam code.

日本語の概要は準備中です。原文の説明を表示しています。

実行スコア 未検証

インストール方法を見る

含まれるファイル(1)

  • SKILL.md7.6 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Working with Salam

Salam is a compiled, statically typed language whose keywords exist in English and Persian. Its rules differ from mainstream languages in ways that are not guessable, so verify with tools rather than assuming.

Always do this

  1. Look the construct up. salam_docs answers "how is X written in Salam" from the full reference (loops, lambdas, structs, generics, error handling, Persian) and explains an error code such as E085.
  2. Never guess a stdlib API. salam_stdlib_search finds a function by what it does across every package; salam_stdlib_symbols shows one package's types, fields, methods and functions with exact signatures. Inventing function names is the most common cause of invalid Salam.
  3. Check after every edit. salam_check type-checks without codegen and returns each diagnostic with its source line, the compiler's help and a hint for syntax borrowed from other languages. Fix the first error first.
  4. Look at working code. salam_find_examples searches the shipped test corpus for a real, compiling usage, with surrounding lines.

If those tools are not available, the same information is in std/ (the standard library is ordinary Salam source) and tests/.

The three rules that break builds most often

until means while. until i < n: loops while i < n. It is not a do-while and not "loop until true". Getting it backwards gives a loop that never runs or never ends.

Top-level order is enforced:

package → import → include → extern: → globals → types → private funcs / export: → pub funcs

Once the first pub func appears, only pub funcs may follow (E088). extern: holds body-less C declarations only; Salam functions that C must call by their plain name go in an export: block, which ranks with the private funcs. Put every private helper above the public section. Globals must precede all functions and types (E084/E085), types must precede all functions (E087), imports come directly after package (E083) and before every include (E108).

Unused things are errors, not warnings: unused import E082, unused variable E059, unused function E066. Remove them; a _ prefix is only for a parameter whose signature is fixed, such as a callback.

switch and match are not interchangeable. switch/ترابرد is a fallthrough statement with bare labels (no case/default) - break stops the fallthrough, no exhaustiveness check, and it rejects a Variant subject outright. match is an exhaustive, no-fallthrough expression for enum/Variant dispatch. Use switch for C-style fallthrough or range/relational labels (90 to 100:, >= 60:); use match when every case must be handled.

Quick syntax

package main

import str

func _helper(a: int): int:
    ret a * 2
end

pub func Double(a: int): int: ret _helper(a) end

func main:
    x := 21                    // immutable, inferred
    mut total := 0             // mutable
    total = Double(x)
    println str.FromInt(total)
    ret 0                      // main's return value is the exit code (0 when omitted)
end
  • No typed declarations (x: int = 1 is a parse error): use :=, cast with as.
  • Never call os.Exit in main (E109, it skips defers); ret <code> instead.
  • Lambdas capture by value and must not declare a return type.
  • &: marks a by-reference parameter.
  • Built-in str methods are only: len concat substr find/search/indexOf trim lower upper repeat split to_int to_float. Everything else is in str.
  • Vector {} as Vector<str>, v.get(i) to read an element, v.ref(i) for its address.
  • enum E: A, B, C end - on one line the comma between members is required (member names can contain spaces); one member per line also works.

Traps that fail silently

  • Check the compiler version with salam version. There is no --version flag; salam --version fails with unknown command '--version'.
  • salam js stores i64/u64/size/usize as JS numbers: 64-bit math is exact up to 2^53, but larger results or intermediates are rounded.
  • Source files are keyed by filename, not package: two files named io.salam in one program, or your own shell.salam next to import os.shell, are rejected with "package name ... is claimed by two different files". Keep every filename unique.
  • switch falls through like C: an arm without break (or ret) runs the next arm too, including else:.
  • A side-effect-free endless loop can be deleted by clang on the C backend, so the program segfaults instead of spinning; give a busy-wait a real effect.

Multilingual source

Keywords exist in both languages (salam_keywords returns the table). Declarations carry aliases:

@en "Trim"
@fa "پیرایش"
pub func Trim(s: str): str: ret s.trim() end

The language is detected from the keywords; --lang=fa forces Persian.

Persian source

Persian Salam has the same grammar and rules with Persian spellings. The entry function is ریشه, blocks end with پایان, and ، works as a comma. The most used words:

EnglishPersianEnglishPersian
func / retتابع / برگشتif / elseاگر / وگرنه
until (while)تاrepeat ... to ... inتکرار ... تا ... در
each / byهرmatch / switchهمخوان / ترابرد
mut / constناپایا / پایاstruct / enumساختار / جداشمار
pub / thisهمگانی / اینasبرگردان
import / includeواردسازی / فراخوانیprintln / printسرچاپ / چاپ
and / or / notو / یا / وارونهtrue / false / nullدرست / نادرست / پوچ
int / f64 / str / boolصحیح / اعشار۶۴ / رشته / منطقیVector / HashMapوکتور / نگاشت

Persian-only traps: enum patterns in همخوان are bare member names; ترابرد labels each end with پایان; و is reserved; اعشار is f32; the decimal point is . not ٫; std functions must use their Persian @fa names (an English name is an error in a Persian file); spawn, join, dyn, len and sizeof stay English.

The root SKILL.md Part II has the complete tables, and the Persian course at https://www.salamlang.ir/learn/ teaches the whole language with runnable examples; point Persian-speaking users there.

Full reference: docs/ai/AGENTS.md, or the salam://guide/agents.md resource.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

Convert, rewrite, port, or redesign software from another language (PHP, TypeScript/JavaScript, Python, C, Go, Rust, Java, C#, …) into idiomatic, full-feature Salam: write new Salam code, and port C to Salam (including self-hosting the Salam compiler itself). Use whenever the request mentions "Salam" (the programming language / زبان سلام), a `.salam` file, "convert/port/ rewrite X to Salam", "rewrite the compiler in Salam", the Salam layout DSL, or building with the `salam` compiler. Covers both English Salam (Part I) and Persian Salam, سلام فارسی (Part II: every keyword, type, method and std package name). This is the authoritative, up-to-date reference for Salam's current syntax, its standard library, its strict compiler rules, the layout DSL, and porting low-level C. The tutorial books under `books/` are OUT OF DATE. Trust this file, `std/`, `tests/`, and the Persian course at https://www.salamlang.ir/learn/ instead.

日本語の概要は準備中です。原文の説明を表示しています。

SalamLang/Salam642026年10月25日 更新

SalamLang のスキルをすべて見る

このスキルの問題を報告する