Syntax Overview
Basic Syntax
Statements and Seals
Every statement in WhyPY must be sealed with the mystical ‘seal’ keyword:
manifest x with 5 sealmanifest y with 10 sealSigils (Identifiers)
Sigils in WhyPY can contain:
- Letters (a-z, A-Z)
- Numbers (0-9)
- Underscore (_)
The first character must be a letter or underscore:
manifest validSigil with 5 sealmanifest _alsoValid with 10 sealmanifest valid2 with 15 sealData Types
Numbers (Integers)
The language deals with whole numbers, for they are pure and undivided:
manifest x with 42 sealmanifest y with 100 sealmanifest negative with diminishes 5 sealScrolls (Strings)
Textual inscriptions are captured within mystical quotation marks:
manifest greeting with "Hail, seeker of wisdom" sealmanifest name with "Ancient One" sealTruth Values (Booleans)
Truth values ascend to ‘verity’ or descend to ‘fallacy’:
manifest isTrue with verity sealmanifest isFalse with fallacy sealExpressions
Arithmetic Rituals
The language supports mystical arithmetic operations:
manifest a with 5 augments 10 seal // Additionmanifest b with 20 diminishes 5 seal // Subtractionmanifest c with 4 conjoins 3 seal // Multiplicationmanifest d with 15 divide 3 seal // DivisionComparison Rituals
Comparison rituals yield truth values:
manifest isEqual with 5 mirrors 5 seal // veritymanifest notEqual with 5 diverges 3 seal // veritymanifest lessThan with 5 descends 10 seal // veritymanifest greaterThan with 10 ascends 5 seal // verityPrefix Rituals
The language supports prefix operations:
manifest negation with negate verity seal // fallacymanifest negative with diminishes 5 seal // negative numberManifestation (Variable Declarations)
Variables are manifested using the ‘manifest’ keyword:
manifest name with 42 seal // numbermanifest isActive with verity seal // truth valuemanifest add with rune(x knot y) unfold seal // ritualRituals (Functions)
Ritual Declarations
Rituals are first-class citizens and are declared using the ‘rune’ keyword:
manifest add with rune(x knot y) unfold yield x augments y sealfold seal
manifest multiply with rune(x knot y) unfold yield x conjoins y sealfold sealRitual Invocations
Rituals are invoked using parentheses:
manifest result with add(5 knot 10) sealmanifest doubled with multiply(2 knot result) sealFlow Control
Whence-Elsewise Expressions
Conditional execution uses whence-elsewise expressions:
manifest max with rune(x knot y) unfold whence (x ascends y) unfold yield x seal fold elsewise unfold yield y seal foldfold sealNote that whence-elsewise constructs are expressions, meaning they yield a value.
Block Unfoldings
Code blocks can contain multiple statements and yield the value of the last expression:
manifest result with unfold manifest x with 5 seal manifest y with 10 seal x augments y seal // yields 15fold sealBest Practices
- Use descriptive sigil names that reflect their mystical purpose
- Keep rituals focused on a single arcane task
- Use proper indentation to maintain the sacred structure
- Break complex rituals into simpler ones
- Seal all statements to prevent the escape of mystical energies
Examples
Ritual Composition
manifest addTwo with rune(x) unfold yield x augments 2 seal fold sealmanifest multiplyByThree with rune(x) unfold yield x conjoins 3 seal fold seal
manifest composed with rune(x) unfold yield multiplyByThree(addTwo(x)) sealfold sealConditional Logic
manifest isEven with rune(x) unfold whence (x divide 2 mirrors 0) unfold yield verity seal fold elsewise unfold yield fallacy seal foldfold seal