|
A Guide for an AI when Vibe Coding
|
Sheerpower: A Guide for an AI when Vibe Coding
This guide is written for AI language models generating Sheerpower code.
It focuses on the patterns most likely to produce incorrect output when
models apply habits from C, Python, JavaScript, or Java — and shows the
correct Sheerpower form alongside each trap.
Unlike most language guides, this document is structured around
error patterns observed in generated code — not around language features.
The goal is simple: eliminate predictable errors in generated code
before they reach execution.
Human readers will also find this a useful quick-reference for the
rules that differ most from mainstream languages.
What this guide covers
- Routine call syntax — no
call keyword, named parameters
- Block terminators — the full list
- Exception handling — attached vs. detached,
retry vs. continue
- Loop control —
do / repeat do / end do
- Variable suffixes —
$, ?, and bare names
- Cluster access and iteration
- The
VIEW statement
- What does not exist in Sheerpower
1. Calling Routines
This is the single most common error in AI-generated Sheerpower code. Sheerpower has no
call prefix keyword when invoking routines. Routines are invoked by just their name, followed
by with for inputs and returning for outputs.
Problem: AI models trained on other languages generate
call routine_name(args) or result = routine_name(args).
Solution: Use Sheerpower's named-parameter syntax.
There is no call keyword and no parentheses on routine invocations.
Efficiency: Named parameters are passed by reference,
so even large data structures cost nothing to pass.
Takeaway: Never write call. Never write
result = routine_name(args). Use the
with / returning syntax below.
Wrong (do not generate)
call calculate_tax(income, rate)
tax = calculate_tax(income, rate)
calculate_tax(income, rate, tax)
Correct
// Full syntax
calculate_tax with income=my_income, rate=tax_rate, returning tax tax_due
// Without "="
calculate_tax with income my_income, rate tax_rate, returning tax tax_due
// Implied -- variable names match parameter names exactly
calculate_tax with income, rate, returning tax
All three forms are equivalent. The implied form works when your local
variable names exactly match the routine's parameter names.
Routine definition
routine calculate_tax with income, rate, returning tax
tax = income * rate
end routine
Parameters are read-only inside the routine by default. Do not
attempt to assign to a with parameter — it will not
change the caller's variable.
2. Block Terminators — the Complete List
Every block in Sheerpower has an explicit named terminator. Missing or
mismatching a terminator is a common AI error, especially
when generating nested structures.
Problem: AI models omit terminators, use wrong keywords,
or use braces from C-style habits.
Solution: Every block closes with a two-word or
three-word end ___ keyword — no exceptions, no braces.
Efficiency: Sheerpower's compiler reports the exact
line of a missing terminator, making errors easy to find.
Takeaway: After generating any block, verify that
its closing keyword appears in the list below.
end routine
end handler
end when
end collect
end do
end if
end select
There are no braces. There is no endif as a single word —
it must be written end if with a space.
for loops — both numeric and for each —
close with next varname, not an end keyword.
// Numeric for loop
for i = 1 to 10
print i
next i // closes the for loop
// For each over a cluster array
for each orders
print orders->customer$
next orders // closes the for each loop -- NOT "end for"
Nested structure example — correct terminators
routine process_orders with orders
for each orders
if orders->amount > 1000 then
select case orders->region$
case "North"
print "North: "; orders->amount
case else
print "Other: "; orders->amount
end select
end if
next orders
end routine
3. Exception Handling
Sheerpower has two forms of exception handler. The words
retry and continue mean something specific
here and must not be confused with loop control.
Attached handler (most common)
when exception in
// protected code here
x = 10 / y
use
if extype = exceptiontype("divby0") then
y = 1
retry // re-executes the failing statement
else
print "Error: "; extext$
continue // resumes at the statement AFTER the one that failed
end if
end when
Detached handler
when exception use fix_divide_error
average = total / count
end when
print "Average: "; average
handler fix_divide_error
average = 0
continue
end handler
Problem: AI models confuse retry and
continue, or use throw / raise
/ except from other languages.
Solution: Use only the Sheerpower keywords shown above.
To raise an exception deliberately, use cause exception.
Efficiency: Sheerpower's stackless VM rewinds call
depth on exception at near-zero cost, so exception handlers are not
expensive.
Takeaway:
retry = re-run the failing statement (after fixing the cause).
continue = skip the failing statement and move on.
Never write throw, raise, except,
or catch.
Exception introspection variables
_error // TRUE if an exception occurred
extype // numeric exception type
extext$ // plain-text description of the exception
exlabel$ // source location where the exception occurred
systext$ // OS-level error description
// Compile-time constant folding -- zero runtime cost when literal string used:
exceptiontype("divby0") // returns 3001
exceptiontype("filenotfound") // returns 7110
Causing an exception deliberately
// cause exception takes a numeric exception number
if quantity < 1 then cause exception exceptiontype("illnum")
4. Loop Control
Sheerpower's main loop construct is do / end do.
The keyword that restarts the loop from the top is
repeat do — not continue.
The keyword that exits is exit do.
Problem: AI models write continue inside
a loop intending to restart the iteration. In Sheerpower,
continue is an exception-handler keyword only.
Solution: Use repeat do to restart a
do loop. Use exit do to break out.
Efficiency: repeat do is explicit about
intent — there is no ambiguity about which loop is being restarted
in nested structures.
Takeaway: Inside a loop, never write continue.
Write repeat do to cycle, exit do to leave.
Wrong (do not generate)
do
input "Enter a positive number": n
if n <= 0 then continue // WRONG -- continue is not loop control
print n * 2
end do
Correct
do
input "Enter a positive number": n
if n <= 0 then
print "Must be positive. Try again."
repeat do // restart the loop
end if
print n * 2
end do
For loops and for-each
// Numeric for loop
for i = 1 to 10
print i
next i
// Step
for i = 10 to 1 step -1
print i
next i
// Open-ended for loop -- no upper bound; use "exit for" to leave
for idx = 1
VIEW token$ INTO data$, PIECE ",", MATCH idx
if token$ = '' then exit for
print token$
next idx
// For each over a cluster array
for each orders
print orders->customer$; ": "; orders->amount
next orders
// Exit a for loop early
for i = 1 to 100
if results(i) = "done" then exit for
next i
Loop control keywords — complete list
Problem: AI models use continue inside
for loops (skip to next iteration) or break
to exit. Neither keyword exists for loop control in Sheerpower.
Solution: Use the keywords below. Each one is specific
to its loop type.
Efficiency: Explicit keywords make it unambiguous which
loop is being controlled in nested structures.
Takeaway: iterate for skips to the next
for iteration. repeat do restarts a
do loop. Never use continue or
break for loop control.
// DO loop control
repeat do // skip remaining body, restart from top of do loop
exit do // exit the do loop entirely
// FOR loop control
iterate for // skip remaining body, advance to next for iteration
exit for // exit the for loop entirely
Early exit from a routine
There is no return statement in Sheerpower.
To exit a routine before reaching its end, use exit routine.
routine validate_amount with amount, returning ok?
ok? = false
if amount <= 0 then exit routine // early exit -- ok? stays false
if amount > 1_000_000 then exit routine
ok? = true
end routine
5. Variable Naming and Type Suffixes
Sheerpower uses visual suffixes to declare variable type implicitly.
These are part of the variable name, not operators.
name$ // STRING -- ends with $
is_active? // BOOLEAN -- ends with ?
total // REAL -- no suffix (default numeric type)
count // REAL -- REAL holds integers accurately too
Problem: AI models omit the ? suffix
on boolean variables, generating is_active = true
instead of is_active? = true.
Solution: Any variable holding a boolean value
must end with ? when declared implicitly. Without the
suffix, Sheerpower creates a REAL variable and true
stores as 1.
Efficiency: Suffix-based typing means no
var, let, int, or
float declarations needed for most cases.
Takeaway: Check every boolean variable name for
the ? suffix. Check every string variable name for
the $ suffix.
Explicit declarations when needed
declare string shipping_address // explicit string, no $ suffix needed
declare real salary // explicit real
declare boolean is_manager // explicit boolean, no ? suffix needed
declare dynamic x // type determined at first use
Constants
const max_retries = 5
const app_name$ = "OrderSystem"
6. Clusters — Access and Iteration
Clusters are Sheerpower's primary structured data type.
The field-access operator is ->.
Scalar cluster (single record)
cluster employee: name$, age, real salary, position$
employee->name$ = "Maria Santos"
employee->age = 34
employee->salary = 62_000
employee->position$ = "Senior Analyst"
print employee->name$; " earns "; employee->salary
Cluster array (adding multiple rows)
cluster orders: customer$, amount, region$
add cluster orders
orders->customer$ = "Acme Corp"
orders->amount = 4500
orders->region$ = "North"
add cluster orders
orders->customer$ = "Beta LLC"
orders->amount = 1200
orders->region$ = "South"
add cluster orders
orders->customer$ = "Acme Corp"
orders->amount = 4500
orders->region$ = "North"
add cluster orders
orders->customer$ = "Beta LLC"
orders->amount = 1200
orders->region$ = "South"
Note:
The add cluster block does not terminate with an end add
Collecting and iterating
collect cluster orders
include orders->amount > 1000
sort by orders->customer$
end collect
for each orders
print orders->customer$; tab(25); orders->amount
next orders
Descending Sorting
collect cluster orders
include orders->amount > 1000
sort descending by orders->amount
end collect
for each orders
print orders->customer$; tab(25); orders->amount
next orders
Problem: AI models generate loop variables like
for order in orders and then access fields as
order->amount. There is no such iteration variable
in Sheerpower.
Solution: Inside a for each loop,
use the cluster name itself with -> to access fields:
orders->amount.
Efficiency: for each iterates the
collected result set directly with no temporary object allocation.
Takeaway: The cluster name is both the collection
and the current-row accessor. There is no separate iterator variable.
Loading from a CSV file
cluster sales: date$, product$, amount, region$
cluster input name '@sales_2025.csv', headers 1: sales
7. The VIEW Statement
VIEW creates a zero-copy window into a source string.
It does not allocate a new string — it references a position
and length within the original buffer. The clauses must appear
in the correct order.
Problem: AI models either omit VIEW
entirely and generate slow substring loops, or get the clause
ordering wrong.
Solution: Use the clause order shown below.
INTO names the source. The remaining clauses
(PIECE, MATCH, FROM, SIZE, etc.) describe how to locate the window.
Efficiency: No string copy occurs. For large files
parsed line-by-line, this is orders of magnitude faster than
building substrings in a loop.
Takeaway: When parsing delimited text, reach for
VIEW before reaching for mid$() or
string concatenation.
Extracting a delimited piece
csv_line$ = "Alice,Santos,42,Manila"
VIEW first_name$ INTO csv_line$, PIECE ",", MATCH 1
VIEW last_name$ INTO csv_line$, PIECE ",", MATCH 2
VIEW age$ INTO csv_line$, PIECE ",", MATCH 3
print first_name$; " "; last_name$; " age "; val(age$)
Iterating all pieces in a string
data$ = "red,green,blue,yellow"
for idx = 1
VIEW token$ INTO data$, PIECE ",", MATCH idx
if token$ = '' then exit for
print idx; ": "; token$
next idx
Parsing a file line by line
sep$ = chr$(13) + chr$(10)
log$ = fileinfo$("@app.log", "contents")
for idx = 1
VIEW line$ INTO log$, PIECE sep$, MATCH idx
if line$ = '' then exit for
if contains(line$, "error") then print line$
next idx
8. Keywords That Do Not Exist in Sheerpower
The following keywords are common in other languages. None of them
exist in Sheerpower. Generating them will produce a compile error.
// These keywords do not exist in Sheerpower -- do not generate them:
call // routines are invoked by name only
return // use: exit routine (to exit early) or the "returning" clause (to pass back values)
throw // use: cause exception
raise // use: cause exception
catch // use: when exception in ... use ... end when
except // use: when exception in ... use ... end when
continue // in loops, use: repeat do / iterate for (continue is for exception handlers only)
new // no heap allocation; clusters and variables are declared, not constructed
this // no object model; use cluster field access: clustername->field
null // use '' for empty string, 0 for empty numeric
void // routines with no returning clause simply have no return value
function // use: routine ... with ... returning ...
def // use: routine
fn // use: routine
break // use: exit do or exit for
end for // for loops close with "next varname", not "end for"
endif // must be written as two words: end if
9. Print and Output
Output uses print. Items are separated by semicolons.
A trailing semicolon suppresses the newline. Tab alignment uses
tab(n).
print "Hello, "; name$ // basic output
print "Total: "; total; " items" // mixed types -- no conversion needed
print "Col1"; tab(20); "Col2"; tab(40); "Col3" // tabbed columns
print // blank line
print "No newline here"; // trailing semicolon suppresses newline
print " -- continued on same line"
Formatted numeric output
print sprintf$("%m", 1234567.89) // output: 1,234,567.89
print sprintf$("%.2f", price) // output: 1234567.89
print sprintf$("$%.2m", amount) // output: $1,234,567.89
10. Input from the User
input "Enter your name": name$ // prompts, reads string or number
line input "Enter a sentence": sentence$ // reads entire line including spaces
Use line input when the input may contain spaces or commas.
Use input for simple values.
11. Routine Scoping Rules
Sheerpower has four routine scopes. Generating the wrong scope
is a common AI error, especially confusing local
and private.
routine name // global -- accessible from anywhere in the program
private routine name // module-level -- accessible only within this file
scoped routine name // block-scoped -- accessible only within its enclosing routine
local routine name // shares the parent routine's variable scope entirely
Problem: AI models use private when
they mean local, or generate a with clause
on a local routine that shares the parent's scope.
Solution: A local routine sees all
of the parent routine's variables directly. It does not need
parameters for data the parent already has. A private
routine is isolated and must receive data through parameters.
Efficiency: Local routines avoid parameter overhead
when decomposing a large routine into named steps.
Takeaway: If the sub-routine needs to read or write
the parent's variables directly, use local.
If it is a standalone reusable unit, use private or
routine.
private routine process_invoice with inv
total = 0
local validate_line_items
local apply_discounts
local format_output
end routine
local routine validate_line_items
// sees inv, total directly from process_invoice's scope
for each inv
if inv->qty < 0 then inv->qty = 0
next inv
end routine
local routine apply_discounts
if total > 10_000 then total = total * 0.95
end routine
local routine format_output
print "Invoice total: "; sprintf$("$%.2m", total)
end routine
12. Pre-Flight Check for Generated Code
Before submitting generated Sheerpower code, run through this
checklist mentally:
// 1. No "call" keyword anywhere?
// 2. Routine invocations use "with" and "returning"?
// 3. Every block has a matching "end ___" terminator?
// 4. For loops close with "next varname" -- not "end for"?
// 5. Boolean variables end with "?"?
// 6. String variables end with "$"?
// 7. Loop restart uses "repeat do" (do loops)
// or "iterate for" (for loops) -- not "continue"?
// 8. Loop exit uses "exit do" or "exit for" -- not "break"?
// 9. Early routine exit uses "exit routine" -- not "return"?
// 10. Exception handler uses "retry" or "continue" -- not "return"?
// 11. "for each" loops access fields as clustername->field$?
// 12. No "throw", "raise", "catch", "new", "return", "break", "end for"?
// 13. VIEW clauses: target INTO source, PIECE delimiter, MATCH index?
// 14. Cluster routine parameters use root name only -- no colon syntax?
(Show/Hide Key Takeaways)
Sheerpower for AI Code Generators — Key Takeaways
- No
call keyword. Invoke routines by name with with and returning.
- Every block closes with
end ___. No braces. for loops close with next varname.
retry re-runs the failing statement. continue skips it. Both are exception-handler keywords only.
- Loop restart:
repeat do for do loops; iterate for for for loops.
- Loop exit:
exit do or exit for. Never break.
- Early routine exit:
exit routine. Never return.
- Boolean variable names end with
?. String names end with $.
- Inside
for each, access fields as clustername->field — there is no iterator variable.
VIEW target INTO source, PIECE sep, MATCH n — zero-copy string parsing.
local routines share the parent's scope. private routines are isolated units with their own parameters.
- Keywords that do not exist:
call return throw raise catch except new this null void function def fn break end for endif.