본문으로 건너뛰기
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 / 1,000자

이 양식은 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월 24일 업데이트

SalamLang의 스킬 모두 보기

이 스킬의 문제 신고