We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Freestajlo

From Esolang
Jump to navigation Jump to search

Freestajlo is a Turing-complete programming language made by User:LEOMOK. Its name comes from https://www.youtube.com/watch?v=EygTFFhVBf8, which is the first video uploaded by the music YouTuber Waterflame. It is inspired by other stack-based programming languages like FALSE. Whitespace is a nop and allowed anywhere.

Freestajlo operates on an array of stacks of and indexed by unbounded, signed integers, as well as an unnumbered one for temporary storage and to transport values between stacks. Popping off an empty stack returns 0.

Instructions

Unless specified, "the stack" refers to the stack currently being operated on.

Literals

  • 0-9 - push a nonnegative integer onto the stack, multidigit allowed.
  • ' - push the next character's Unicode value onto the stack.
  • " - push 0, then the Unicode values of each character after the quote reversed (a null-terminated string).

Arithmetic Operators

  • + - pop a, b, push a+b.
  • - - pop a, b, push b-a.
  • * - pop a, b, push a*b.
  • / - pop a, b, push b/a, rounded towards 0.
  • % - pop a, b, push b%a, with the sign of a.
  • ^ - pop a, b, push b^a, negative exponents return 0.
  • _ - pop a, push -a.

Logical And Bitwise Operators

  • = - pop a, b, push -1 if a==b, else 0.
  • < - pop a, b, push -1 if b>a, else 0.
  • > - pop a, b, push -1 if b<a, else 0.
  • ` - pop two values and push their bitwise NOR.

Stack Operations

  • $ - duplicate the top stack value.
  • # - pop the stack and discard.
  • \ - swap top two stack values.
  • & - pop a, dup stack item a from the top, 0-indexed.
  • ~ - pop a, b, insert b at position a of stack from the top, 0-indexed
  • | - push the current stack length.

Input And Output

  • : - print the top of the stack as decimal, popping it.
  • . - print the top of the stack mod 0x10FFFF as a Unicode character, popping it.
  • ; - scan the input stream until a valid decimal integer is found, then push it onto the stack. 0 on EOF.
  • , - get a codepoint of input and push its Unicode value. -1 on EOF.

Control Flow

Zero is falsy, all other values are truthy.

  • {...} - codeblocks.
  • ? - if statement (pops first). Syntax: ?{then} or ?{then}{else}
  • @ - while loop (does not pop). Syntax: @{loop body}

Interstack Management

  • ! - pop a, move to stack number a.
  • ( - pop a value from the unnumbered stack and push it onto the stack.
  • ) - pop a value from the stack and push it onto the unnumbered stack.

Functions

  • A-Z, a-z: if followed by a codeblock, define a function, else run said function.

Miscellaneous

  • [...] - a comment.

Turing-Completeness Proof

Branflakes programs can be translated into Freestajlo this way:

Branflakes Translation
< 1_!1+
> 1_!1-
+ 1_!$!1+
- 1_!$!1-
. 1_!$!.
, 1_!$!,
[ 1_!$!@{
] 1_!$!}

(sorry for any mistakes)

Examples

Hello, World!

   "Hello, World!"@{.}

Truth-Machine

   ;@{$:}:

FizzBuzz until input value

   1!;0! [set up input value]
   0 1! [set up loop]
   @{
     $15%0=?{"FizzBuzz"@{.}$} [15 = 3*5]
     {$3%0=?{"Fizz"@{.}$}
     {$5%0=?{"Buzz"@{.}}
     {$:}}}
     10. [print newline] 
     1+0!1-1! [next iteration]
   }