रेंडरिंगhi

keyword-as-ident

Translation status: हिन्दी reader-locale proof. Term names and code fences follow the hi pack; supporting prose may still be English.

Unshadowed read stays the lege builtin.

Syntax: const _ input ← read

Category#

identifier

Examples#

radix/corpus/keyword-as-ident/print-binding.fab (canonical · concept)#

A binding named print used as the argument of the bare output intrinsic.

# =============================================================================
# keyword-as-ident — binding named `print`
# =============================================================================
#
# What this teaches:
#   • Binding targets accept keyword spellings — `const string print` is a
#     user name, not a reserved word.
#   • Bare `print print` is the output intrinsic of that binding.
#
# Common mistakes:
#   • Using `print(print)` here — that is a call to the identifier `print`,
#     which in this file is a string, not a function (SEM012).
#
# See also: nota, fixum, print-fn.fab, print-call.fab
# =============================================================================
#
# Operator example:
#   const string print ← "print"
#   print print
#
# GRAMMAR:
#   outputStmt :← 'print' expr
#
# EXPECTED OUTPUT:
#   print-binding.expected — print

main {
    const string print  "print"
    print print
}

Expected output:

print

radix/corpus/keyword-as-ident/print-call.fab (canonical · concept)#

Statement-initial print(...) is a user function call, not the output intrinsic.

# =============================================================================
# keyword-as-ident — user call `print(...)`
# =============================================================================
#
# What this teaches:
#   • `print(...)` at statement start is an expression statement whose callee
#     is the identifier `print` — here the user function.
#   • The exact token sequence `print(print)` is the same call form. It only
#     type-checks when the argument `print` is a string. A local binding
#     named `print` shadows the function (SEM012); passing the function
#     itself is SEM010. The runnable form below keeps the paren call and
#     supplies a string (`"print"`).
#
# Common mistakes:
#   • Expecting `print(x)` to be the output statement — that is the bare
#     form `print x`.
#
# See also: nota, functio, print-fn.fab, print-binding.fab
# =============================================================================
#
# Operator example:
#   fn print(string print) { print print }
#   print(print)            -- user call; argument must be a string
#
# GRAMMAR:
#   exprStmt :← 'print' '(' args ')'
#
# EXPECTED OUTPUT:
#   print-call.expected — print

fn print(string print) { print print }

main {
    print("print")
}

Expected output:

print

radix/corpus/keyword-as-ident/print-fn.fab (canonical · concept)#

A user function named print, with a print parameter, whose body uses the output intrinsic.

# =============================================================================
# keyword-as-ident — user function named `print`
# =============================================================================
#
# What this teaches:
#   • Name slots accept keyword spellings — `fn print` and parameter `print`
#     are ordinary identifiers.
#   • Bare `print print` inside the body stays the output intrinsic (scribe
#     family, not a recursive call).
#   • Statement-initial `print(...)` is a user call to that function.
#
# Common mistakes:
#   • Writing `print(x)` when the output statement is wanted — use the bare
#     form `print x`.
#   • Pairing `fn print` with a local `const string print` in the same scope —
#     the binding shadows the function, so `print(...)` is no longer callable.
#
# See also: nota, functio, print-binding.fab, print-call.fab
# =============================================================================
#
# Operator example:
#   fn print(string print) { print print }
#
# GRAMMAR:
#   outputStmt :← 'print' expr            -- bare: intrinsic
#   exprStmt   :← 'print' '(' args ')'    -- paren: user call
#
# EXPECTED OUTPUT:
#   print-fn.expected — hello

fn print(string print) { print print }

main {
    print("hello")
}

Expected output:

hello

radix/corpus/keyword-as-ident/read-shadowed.fab (canonical · concept)#

A binding named read wins over the lege builtin.

# =============================================================================
# keyword-as-ident — shadowed `read` binding
# =============================================================================
#
# What this teaches:
#   • Binding wins — a user binding named `read` is the value of bare `read`
#     in expression position. The lege builtin is not reserved.
#   • The binding is used (no WARN001). The program prints the string, not
#     a stdin line.
#
# Common mistakes:
#   • Assuming `read` is always the builtin once the spelling is in the
#     pack — builtin claims are defaults, not reservations.
#
# See also: lege, nota, read-unshadowed.fab
# =============================================================================
#
# Operator example:
#   const string read ← "data"
#   print read
#
# GRAMMAR:
#   readExpr :← 'read'     -- builtin only when the spelling is not bound
#
# EXPECTED OUTPUT:
#   read-shadowed.expected — data

main {
    const string read  "data"
    print read
}

Expected output:

data

radix/corpus/keyword-as-ident/read-unshadowed.fab (canonical · concept)#

Unshadowed read stays the lege builtin.

# =============================================================================
# keyword-as-ident — unshadowed `read` builtin
# =============================================================================
#
# What this teaches:
#   • When no binding named `read` is in scope, bare `read` is the lege
#     builtin (stdin line). Same rule as corpus/lege/lege.fab.
#   • No syntactic escape hatch — the builtin stays reachable by not
#     shadowing the spelling.
#
# Common mistakes:
#   • Treating this file as a stdout golden — stdin is interactive (no
#     sibling .expected), matching lege/lege.fab.
#
# See also: lege, read-shadowed.fab
# =============================================================================
#
# Operator example:
#   const _ input ← read
#
# GRAMMAR:
#   readExpr :← 'read'
#
# EXPECTED OUTPUT:
#   none — interactive stdin, same class as lege/lege.fab
#
# BACKEND:
#   Rust/Go/roundtrip e2e follow the lege/lege.fab stdin-read class.

main {
    const _ input  read
    print input
}