Types

Rockstar uses a similar type system to that defined by the ECMAScript type system, except undefined doesn’t sound very rock’n’roll so we use mysterious instead.

  • Number - Numbers in Rockstar are fixed-precision , stored according to the IEEE 754 standard. (An earlier version of this spec proposed that Rockstar used the DEC64 numeric type. This is a perfect example of something that seemed like a great idea after a couple of beers but turns out to be prohibitively difficult to implement…)
  • Boolean - a logical entity having two values true and false.
    • rightyes and ok are valid aliases for true
    • wrongno and lies are valid aliases for false
  • Function - used for functions.
  • Null - the null type. Evaluates as equal to zero and equal to false. The keywords nothingnowherenobody, and gone are defined as aliases for null
  • Mysterious - the value of any variable that hasn’t been assigned a value, denoted by the keyword mysterious.

Strings

Rockstar strings are surrounded by double quotes. A string literal includes everything up to the closing quote, including newlines. To include a double quote in a string, use a pair of double quotes. Rockstar strings are stored internally as UTF-16, and support the full Unicode character set.

The keywords emptysilent, and silence are aliases for the empty string ("")

Print "this is a string literal"

Print "This string includes ""quotes"""

Print "This string
contains
line
breaks"

Print "Стріляй!
Скажи, чому боїшся ти
Зробити цей останній крок?"

Print "🎸✨🎆💔🌃🐍💘🌾🍾"

Print empty

Print silence

Numbers

Number literals are written as ordinary digits; decimals and negative numbers are supported:

Print 1 (prints: 1)
Print 0.5 (prints: 0.5)
Print +8 (prints: 8)
Print -10 (prints: -10)
Print -.4 (prints: -0.4)
Print 1.000000000 (prints: 1)
Print 1.2. (prints: 1.2)

A Rockstar number is a 128-bit fixed-precision decimal, between -79,228,162,514,264,337,593,543,950,335 and +79,228,162,514,264,337,593,543,950,335.

You get 29 digits, a minus sign if you need it, and a a decimal point you can put anywhere you like:

Print   +79228162514264337593543950335
(prints: 79228162514264337593543950335)
Print    -79228162514264337593543950335
(prints: -79228162514264337593543950335)

Print   +0.0000000000000000000000000001
(prints: 0.0000000000000000000000000001)
Print     -.0000000000000000000000000001
(prints: -0.0000000000000000000000000001)

Print   +10000000000000.000000000000001
(prints: 10000000000000.000000000000001)
Print    -10000000000000.000000000000001
(prints: -10000000000000.000000000000001)

Numbers with more than 29 digits will be rounded to 29 digits if they have a decimal part:

Print   +1000000000000000.00000000000001
(prints: 1000000000000000)
Print    -1000000000000000.00000000000001
(prints: -1000000000000000)

Print   +79228162514264337593543950335.1
(prints: 79228162514264337593543950335)
Print    -79228162514264337593543950335.1
(prints: -79228162514264337593543950335)

Print +0.00000000000000000000000000001 (prints: 0)
Print -0.00000000000000000000000000001 (prints: 0)

Booleans

Rockstar supports the Boolean literals true (aliases: yes, ok, right) and false (aliases: no, wrong, lies).

Print true (prints: true)
Say OK (prints: true)
Scream yes (prints: true)
Shout right (prints: true)
 
Print false (prints: false)
Say no (prints: false)
Shout wrong (prints: false)
Scream lies (prints: false)

Null

Rockstar null represents an expression which has no meaningful value. Aliases for null are nothing, nowhere, nobody and gone:

Print true (prints: true)
Say OK (prints: true)
Scream yes (prints: true)
Shout right (prints: true)
 
Print false (prints: false)
Say no (prints: false)
Shout wrong (prints: false)
Scream lies (prints: false)

Variables and Assignment

Rockstar variables are dynamically typed. There are three different ways to assign a variable in Rockstar.

  1. <variable> is <expression>. Valid aliases for is are are, am, was, were, and the contractions 's and 're
  2. put <expression> into <variable>
  3. let <variable> be <expression>
x is 1. Print x (prints: 1)
Y was 2. Print y (prints: 2)
The limit's 55. Print the limit. (prints: 55)

Put 12 into a variable. Print a variable. (prints: 12)
Let my variable be 34. Print my variable (prints: 34)

Put nothing into the fire. Print the fire. (prints: null)
Let the fire be silence. Print the fire. (prints: )


Rockstar variables are function scoped - see variable scope in the section on functions for more about how this work.

Variable names

Rockstar supports three different kinds of variable names.

Simple variables can be any valid identifier that isn’t a reserved keyword. A simple variable name must contain only letters, and cannot contain spaces. Note that Rockstar does not allow numbers or underscores in variable names - remember the golden rule of Rockstar syntax: if you can’t sing it, you can’t have it. Simple variables are case-insensitive.

x is 2
pi is 3.14159
greeting is "hello world"

say x (prints: 2)
say pi (prints: 3.14159)
say greeting (prints: hello world)

Common variables consist of one of the keywords aanthemyyour or our followed by whitespace and an identifier. The keyword is part of the variable name, so a boy is a different variable from the boy. Common variables are case-insensitive.

Common variables can include language keywords, so you can have variables called your scream, my null, the silence.

The greeting is "hello world"
SHOUT THE GREETING (prints: hello world)

A number is 12
Our flag is "death"
print a number (prints: 12)
print our flag (prints: death)

The variable is 1
my variable is 2
Your variable is 3
Say the variable (prints: 1)
Say my variable (prints: 2)
Say your variable (prints: 3)

The silence is nothing
Scream the silence (prints: null)
Your scream is "aargh!"
Scream your scream (prints: aargh!)

Proper variables are multi-word proper nouns: words which aren’t language keywords, each starting with an uppercase letter, separated by spaces. (Single-word variables are always simple variables.) Whilst some developers may use this feature to create variables with names like Customer IDTax Rate or Distance In Kilometres, we recommend you favour idiomatic variable names such as Doctor FeelgoodMister CrowleyTom Sawyer, and Billie Jean.

A note on case sensitivity in Rockstar

Rockstar keywords and variable names are all case-insensitive, with the exception of proper variables. Proper variables are case-insensitive apart from the first letter of each word, which must be a capital letter.

  • TIMEtimetIMeTIMe are all equivalent. Simple variables are case-insensitive.
  • MY HEARTmy heartMy Heart - are all equivalent; the keyword my triggers common variable behaviour
  • Tom SawyerTOM SAWYERTOm SAWyer - are all equivalent; the capital S on Sawyer triggers proper variable behaviour
  • DOCTOR feelgood is not a valid Rockstar variable; the lowercase f on feelgood does not match any valid variable naming style and so the variable name is not valid.

Pronouns

As well as referring to variables by name, you can refer to them using pronouns. The keywords itheshehimhertheythemzehirziezirxexemve, and ver refer to the current pronoun subject.

The pronoun subject is updated when:

  • A variable is declared or assigned:

    My heart is true. Say it - it here refers to my heart

  • A variable is the left-hand side of a comparison used as the condition in an if, while or until statement

    If my heart is true, give it back, yeah - it refers to my heart

The number is 1. Shout it (prints: 1)
It is 2. Shout it (prints: 2)
The string is "hello". Print it (prints: hello)
It is "world". Print it (prints: world)
Print the number (prints: 2)
Print the string (prints: world)

Doctor Feelgood is right. Scream Doctor Feelgood (prints: true)
He is wrong. Scream Doctor Feelgood (prints: false)

The Darkness are 1. Shout the darkness (prints: 1)
They are 2. Shout them (prints: 2)

Alpha is 1
Beta is 2
If alpha is 1 print it (prints: 1)

Gamma is 3
Delta is 4
While gamma ain't nothing, write it. Knock it down, yeah. (writes: 321)



(Please don’t file issues pointing out that 80s rockers were a bunch of misogynists and gender-inclusive pronouns aren’t really idiomatic. You’re right, we know, and we’ve all learned a lot since then. Besides, Look What The Cat Dragged In was recorded by four cishet guys who spent more money on lipgloss and hairspray than they did on studio time, and it’s an absolute classic.)

The Thing About “Her”

her is where Rockstar runs smack into one of the English language’s most delightful idiosyncrasies, because the feminine third person pronoun and the feminine possessive are the same word.

Give him his guitar. Give them their horns. Give her her bass

There is therefore a very specific restriction in the Rockstar grammar: you can’t use her as a common variable prefix if the second part of the variable is a keyword.

You can have variables called the times, your lies, my right, even though times, lies and right are language keywords, but you can’t have her times or her lies because they’d create ambiguous expressions:

A girl is 123
Her times are trying
Say her
Say her times 456

Poetic Literals

One of Rockstar’s unique features is the ability to initialise variables using song lyrics.

Poetic Numbers

A poetic number begins with the like or so keyword, followed by a series of words. The Rockstar parser takes the length of each word and interprets it as a decimal digit:

Shout like a big bad monster (prints: 1337)
Scream like a banshee (prints: 17)

Papa was like a rolling stone. Shout Papa. (prints: 175)

The night is like a shadow, the stars are like the rain
Shout the night (prints: 16353434)

My dreams are so dark
Scream my dreams (prints: 4)

Words of 10 or more letters are counted modulo 10, so you can use 10-letter words for 0, 11 letters for 1 and 12 letters for 2. Hyphens - are counted as letters, so demon-haunted is treated as a 12-letter word. Apostrophes are not counted, so nothing counts as 7 but nothin' counts as 6. A poetic number counts every word until the end of the current statement (indicated by a newline or punctuation .!?;) If you need a poetic number with a decimal point, use an ellipsis ... or the Unicode equivalent U+2026 as the decimal.

Tommy's like a panther, he ain't talkin' 'bout love. Shout Tommy. (prints: 1724644)
He's like a wild animal.
Shout Tommy (prints: 146)

My heart was like ice... a life unfulfilled, wakin' everybody up, taking booze and pills.
Say it. (prints: 3.1415926535)

e is like my… darkest nightmarish longings, my cravings, a symphony of suff'ring that lasts life-long.
Say it. (prints: 2.718281828459)

Carrie's like a wolf. Danny's like a child. Print Carrie. (prints: 14)
Print Danny. (prints: 15)

Poetic strings

You can initialise string variables without quotes by using the says or said keyword. This will skip exactly one space character and then capture the rest of the line as a literal string. If the character immediately following the says keyword is not a space, it will be included in the string literal.

Tommy says we've got to hold on to what we've got.
Gina says it doesn't make a difference if we make it or not.

Print Tommy (prints: we've got to hold on to what we've got.)
Print Gina (prints: it doesn't make a difference if we make it or not.)

A variable says, I start with a comma.
Print a variable(prints: , I start with a comma.)

A variable says: I start with punctuation.
Print a variable (prints: : I start with punctuation.)

My string said it had "quotes", 'quotes', українська, עִבְרִית, 🎸✨🎆	and	tabs
Print my string (prints: it had "quotes", 'quotes', українська, עִבְרִית, 🎸✨🎆	and	tabs)