Senpai
Jump to navigation
Jump to search
Senpai is a stack-based, dynamically typed esolang created by User:4gboframram.
Features
- Has an arbitrary number of stacks that can be created and manipulated at runtime.
- Conditionals (if, if-else, while loop)
- Variables
- Functions
- Importing modules
- Standard IO
- Line comments with
#
Variables
- Variables are declared with
Senpai? Can I see your {name}?
, and assigned to a value withYour {name} is very {expression}!
. - Variable names follow the same format as Python (and most programming languages)
- Variables can be deleted with
Get rid of {name}!
- If a variable is used before it is declared, it should raise an error.
- An unassigned variable should be Falsey
- Pushing an unassigned variable to the stack is undefined behavior. In both of the official Python implementations, pushing an unassigned variable to the stack results in a Python
None
on top of the stack.
- Pushing an unassigned variable to the stack is undefined behavior. In both of the official Python implementations, pushing an unassigned variable to the stack results in a Python
- Variables are defined in the module scope. There is no special scoping. When importing a module, the variables of the module get transferred to the current module after running, so be sure to remove any unwanted variables.
Expressions
- Senpai Expressions are arithmetic expressions that can take numbers, strings, and variables as operands
- Expressions can be grouped with parentheses
- Precedence of operators follow the standard mathematical priority
- Bitwise operators have the same precedence as addition and subtraction
- Strings can be created with
"{words}"
or'{words}'
. The presence of escape codes in strings is dependent on the implementation. Strings can also be concatenated using the addition operator - You can convert an expression to a character (from integer) with
[{expression}]
- Modulus has the same precedence as multiplication and division
- Unary operators a placed before the value
Here is the list of arithmetic operators:
Operator | Keyword |
---|---|
Addition |
and
|
Subtraction |
minus
|
Multiplication |
times
|
Division |
divided by
|
Bitwise or |
or
|
Bitwise and |
combined
|
Bitwise xor |
exclusively or
|
Modulus</code |
mod
|
Unary Negative |
negative |
Bitwise Not |
flipped
|
Here is the list of logical operators. They can be used in normal arithmetic expressions:
Operator | Keyword |
---|---|
Equality |
is equal to
|
Inequality |
is not equal to
|
Less Than |
is smaller than
|
Less Than or Equals |
is less than or equal to
|
Greater Than or Equals |
is greater than or equal to
|
Logical Or |
either or
|
Logical And |
and also
|
Major Builtin Datatypes
The 5 major (accessible) datatypes in Senpai are Integers, Decimals, Strings, Booleans, and Functions. Others may (and should be) added through modules.
- In Senpai, integers, and decimals have arbitrary precision
- A value of zero is falsy
- Strings contain text data and should be truthy unless the string's length is 0
- Functions are always considered truthy
- Booleans: When printed to standard output, should say
True
orFalse
Stack Operations
Show me your {name}!
: Pushes the value of the variable onto the current stack. Changing the value of an item on a stack should not change the value on the variable.I don't like it anymore!
: Pops the top of the current stackLet's switch things up a bit!
: Swaps the top 2 items on the stackLet's really switch things up!
: Rotates the top 3 items on the stack clockwiseLet's take it to the {name}!
: Switches the current stack to be the stack with {name}. If that stack does not exist, create an empty stack with that name and switch the current stack to that stackLet's bring this to {name}!
: Transfers the value of the item on top of the current stack to the variable with a name of {name}.- The name of the default stack is "bedroom"
Conditionals
If Statements
- If
expression
is Truthy, execute code block
If you likey {expression}: {code block} Let's move on now!
- If
expression
is Falsy, execute code block
If you no-likey {expression}: {code block} Let's move on now!
.
- If
expression
is Truthy, execute code block, otherwise execute other code block. The same can be applied for no-likey.
If you likey {expression}: {code block} Otherwise: {other code block} Let's move on now!
Loops
- Standard while loop. Executes code block while expression is truthy. You can also use no-likey
Let's keep this going as long as you likey {expression}:" {code block} We can stop now!
Functions
Basic Info
- In Senpai, functions do not have return values. They manipulate the stack.
- Depending on the context, the top items on the stack after the function is executed can be treated as a return value.
- Extension modules written in other languages should push results on the top of the stack in order if there are return values
- Defining a function sets a variable with its name to be the value of the function.
- All names that are used for arguments have temporary variables created in the module's scope with their name.
- This means that if you have a variable that shares a name with a function argument and call the function, that variable will be overwritten and deleted. (Can vary by implementation.)
Definitions
To define a function that passes no arguments:
{name} is my idea! Here it is: {code} That's it!
To define a function that passes arguments. Notice the commas and the "and" before the last argument. There is no comma if there is only 2 arguments:
{name} is my idea! It needs a, b, c, and d to do it! Here it is: {code} That's it!
Calling Functions
- Functions written in Senpai can only have a finite and non-varying number of arguments, but extension modules may have a variable number of arguments
- To call a function, push the arguments in reverse order onto the current stack, push the function onto the current stack, and then call the function with
Notice me, senpai!
where the number of arguments is the number of exclamation points (!).- The function and the arguments get popped from the stack and then the function is called
For example, to call a function named test
with arguments of 1, 2, and 3:
Senpai? Can I see your h? # temporary variable to allow pushing onto the stack Your h is very 3! Show me your h! Your h is very 2! Show me your h! Your h is very 1! Show me your h! Show me your test! Notice me, senpai!!!
Module Import
- Senpai code can be imported from other files with
Senpai? Do you see "{file_path}"?
- The module's code is executed and the variables from the module are added to the current module. Duplicate names are overridden
Standard Builtin Functions
- These are functions that must exist on every implementation and be available without importing
Name | Number of arguments | Effect |
---|---|---|
love |
variable |
Print its arguments, separated with spaces, ended with a newline, to standard output.
|
reason |
0 or 1 |
If an argument is passed, print the argument to standard output and read a single line from standard input. If no arguments are passed, read a single line of standard input.
|
crash |
0 or 1 |
Crashes the program. If an argument is passed, it should be an integer and will be the exit code for the process.
|
Examples
Hello World!
Senpai? Can I see your cock? Your cock is very "Hello World!"! Show me your cock! Show me your love! Notice me, senpai!
Cat
Show me your reason! Notice me, senpai Show me your love! Notice me, senpai!
Truth Machine
Senpai? Can I see your h? Show me your reason! Notice me, senpai Let's bring this to h! If you likey h is equal to "0": Show me your h! Show me your love! Notice me, senpai! Otherwise: Your h is very 1! Let's keep this going as long as you likey 1: Show me your h! Show me your love! Notice me, senpai! We can stop now! Let's move on now!
FizzBuzz
Senpai? Can I see your range? Your range is very 100! Senpai? Can I see your d? Your d is very 0! Senpai? Can I see your b? Let's keep this going as long as you no-likey d is equal to range: Your d is very d and 1! If you likey (d mod 5 is equal to 0) and also (d mod 15 is not equal to 0): Your b is very "Buzz"! Show me your b! Otherwise: If you likey (d mod 3 is equal to 0) and also (d mod 15 is not equal to 0): Your b is very "Fizz"! Show me your b! Otherwise: If you no-likey d mod 15: Your b is very "FizzBuzz"! Show me your b! Otherwise: If you likey (d mod 3) either or (d mod 5): Show me your d! Let's move on now! Let's move on now! Let's move on now! Let's move on now! Show me your love! Notice me, senpai! We can stop now!
Quine
(Trailing newline because there is no alternative for now)
Senpai? Can I see your i? Your i is very "Your i is very 'Senpai? Can I see your i? Your i is very ' and [34] and i and [34] and [33] and i! Show me your i! Show me your love! Notice me, senpai!"!Your i is very 'Senpai? Can I see your i? Your i is very ' and [34] and i and [34] and [33] and i! Show me your i! Show me your love! Notice me, senpai!
External Resources
- Official Python Implementation: https://github.com/4gboframram/PySenpai/
- Official Python Transpiler: https://github.com/4gboframram/Senpython
- Scala implementation in a many esolang interpreter https://github.com/Dash-Lambda/Eso