Code

Ore was developed to be a very flexible language. It has many of the traditional programming features, but includes a wealth of modern features, along with its own unique concepts. This documentation explains a lot of what Ore has to offer, but introduces the new concepts in appropriate sections. Visit the features section of the Language page to see those features all in one place.


Syntax

Code in Ore can be written in several different ways. This section will feature different components of Ore, how to use them, and different styles in using them. Styles can be compounded and used together to the comfort of the developer.

Basic Syntax

Starting with the basics, most languages have ways to calculate, compare, and output data to a user using commands, variables, and mathematical functions.

Commands

Note that this section is under construction

Using Variables

Note that this section is under construction

Some Calculations

Note that this section is under construction

Comparisons

Note that this section is under construction

[Mention compound comparisons]

Control

Programs can be declarative where they specifically state the steps and instructions for a computer to follow. Instructions are always followed in order. However, using choices or loops in our code allows us to make our programs more dynamic. Ore offers several traditional, and even primitive control options, along with some new concepts. This allows for imperative programming in Ore. These choices and loops are described below.

Conditional

Note that this section is under construction

a = true
if a == true
	say "This code will run"
	say "Isn't that cool?"
if a == false
	say "This code does not run"
	say "Darnit!"

a = true
if a == true
	say "This code will run"
	say "Isn't that cool?"
else
	say "This code does not run"
	say "Dang..."

a = true
say "This code will run" if a == true

a = true
say "This code will run" & say "And so will this code!" if a == true

a = true
unless a == true
	say "This code will not run"
	say "Dangit..."
if a == true
	say "But this code will run!"
	say "Isn't that cool?"

a = true
unless a == true
	say "This code will not run"
	say "Drats!"
else
	say "This code will run"
	say "Isn't that cool?"

a = false
say "This code won't actually execute!" unless a == true

a = true
b = false
say "This code will run" if a == true unless b == true

Loops

Note that this section is under construction

loop
	say "This will repeat forever!"
	say "Isn't that cool?"

loop 23
	say "This will repeat 23 times!"
	say "Isn't that cool?"

say "This will repeat 28 times!" loop 28

a = 20
loop a
	say "This will repeat 20 times!"
	say "Isn't that cool?"

loop 25
	say "This will repeat 25 times!"
after
	say "This ise said only once!"
	say "That was fun!"

a = 0
loop a to 20
	say "The value of a is " + a
	say "Isn't that cool?"

a = 0
loop a 17
	say "The value of a is " + a
	say "Isn't that cool?"

a = { 2, 5, 7, 8, 12 }
loop a
	say "This will loop once for each item in a!"
	say "Isn't that cool?"

loop { 2, 5, 7, 8, 12 }
	say "This will run 5 times since there are 5 values!"
	say "Isn't that cool?"

for 20
	say "This will repeat for 20 times!"
	say "Isn't that cool?"

a = 0
for a to 20
	say "The current value of a is " + a
	say "Isn't that cool?"

a = { 2, 6, 7, 12, 43, 75 }
for a
	say "This will repeat for each number in a!"
	say "Isn't that cool?"

for { 2, 6, 7, 12, 43, 75 }
	say "This will repeat for each number in a!"
	say "Isn't that cool?"

a = { 2, 6, 7, 12, 43, 75 }
for b in a
	say "This will repeat for each value in a"
	say "The value of b changes to the next number each iteration"
	say "The value of b is " + b

for b in { 2, 6, 7, 12, 43, 75 }
	say "The value of b is " + b
after
	say "All of the values were looked at!"

say "The value of b is " + b for b in { 2, 5, 7, 9, 4 }

while true
	say "This will also repeat forever..."
	say "and ever..."

a = true
while a == true
	say "This will also repeat forever..."
	say "and ever..."

ask bool a
while a == true
	say "If a is true, then this will repeat forever!"
else
	say "If a is false, then this will repeat forever!"

mynumber = rand 10
say "I came up with a random number..."
say "I'll let you try to guess it..."
while yourguess != mynumber
	say "What do you think it is?"
	ask yourguess yourguess
after
	say "You got my name correct!"

say "Give me a positive number"
ask number yournumber while yournumber > 0
say "Your number was " + yournumber

a = true
b = false
say "This code will run forever!" if a == true while b == false

until yournumber > 0
	say "Give me a positive number"
	ask number yournumber
after
	"Your number was " + yournumber

b = rand 100 until b > 50

b = rand 100 as b < 50
c = rand 100 while c < 50

Breaking & Continuing

Note that this section is under construction

checker = true
while checker == true
	say "This will appear!"
	continue
	say "This will never appear!"

a = 0
loop a to 50
	say "a is equal to " + a
	if a == 10
		break
	say "It isn't 10, so let's loop again!"

say "Would you like to test some numbers?"
ask bool choice
while choice
	ask number givennumber
	unless givennumber == 0
		if givennumber < 0
			say "The given number is negative!"
		if givennumber > 0
			say "The given number is positive!"
	else
		say "Some people say that 0 isn't even or odd!"
	say "Would you like to test another number?"
	ask bool choice
else
	say "Darnit! I wanted to test some numbers!"
	break
after
	say "That was fun!"

Labels & Redirection

Note that this section is under construction

label a
say "Label a was accessed!"
label b
say "Label b was accessed!"
label c
say "Label c was accessed!"

say "I am about to jump to label b!"
goto b
say "This line is not used..."
label b
say "Label b was accessed!"
say "Yay!"

say "I am about to jump to label b!"
goto b
label a
say "Label a will be skipped!"
goto d
label b
say "Label b was accessed!"
goto d
label c
say "Label c will be skipped!"
goto d
label d
say "Yay!"

Functions

Note that this section is under construction

Functions

Note that this section is under construction

Subroutines

Note that this section is under construction

Aliases, Anonymous Functions & Functional Assignment

Note that this section is under construction

Entry

Note that this section is under construction

Parameters

Note that this section is under construction

Entry Points

Note that this section is under construction

Comments

Comments are very useful to programmers and developers because they are ignored whenever your code is being interpreted. Because of this, comments are often used to explain the purpose of parts of code or to leave notes for developers. They are especially helpful whenever code is being worked on by multiple people.

To insert a comment into code, use two forward slashes like // in order to denote the comment. Anything following those slashes will be ignored. This means that you can use comments on their own line or you can add them to the end of a line of code.

//This program computes the hypotenuse of a triangle
//Jonathan Holmes
ask number a //Ask the user for the first number
ask number b //Ask the user for another number
c = hypot a b //The hypot function computes the hypotenuse of a triangle given two side lengths
say "The hypotenuse was calculated to be " + c //And now we show it to the user

In Ore, you can use the a special keyword called the yada-yada operator in order to signify a section of code is yet to be implemented. To do this, use the ... keyword. Whenever Ore reads this, the line is skipped and not executed. Note that if this is is used inside of an inline loop or condition, the loop or condition will still be executed.

//This program is unfinished
ask number a
ask number b
if a == b
	say "Input another a since a and b cannot be the same."
	ask number a
	...
else
	b += 5 + a
	a = pi * 2
say "a = " + a
say "b = " + b

Other Keywords

Note that this section is under construction

Aliases

Note that this section is under construction

Variables & Datatypes

Note that this section is under construction

Operators & Symbols

Note that this section is under construction

Advanced Syntax

Note that this section is under construction

[Mention compounding lines of code using &, ;, |, or then] [Mention the that keyword]

Datatypes

Note that this section is under construction

Boolean

Note that this section is under construction

Numbers

Note that this section is under construction

Strings

Note that this section is under construction

Array

Note that this section is under construction

Time

Note that this section is under construction

Casting

Note that this section is under construction

[triangle.png]

Explicit Casting

Note that this section is under construction

Implicit Casting

Note that this section is under construction

[scaleuptriangle.png]

[scaledowntriangle.png]


Variables & Constants

Note that this section is under construction

Variables

Note that this section is under construction

(Mention freezing!)

Constants

Note that this section is under construction

Literals

Note that this section is under construction

Access By Address

Note that this section is under construction

(Mention referencing interned functions and interned strings)

Global Variables

Note that this section is under construction

Arrays

Note that this section is under construction

(Mention yada-yada!)

Commands

Note that this section is under construction

Standard

Note that this section is under construction

Ore

Note that this section is under construction

Math

Note that this section is under construction

Variables & Constants

Note that this section is under construction

Control

Note that this section is under construction

Math

Note that this section is under construction

File

Note that this section is under construction

String

Note that this section is under construction

Array

Note that this section is under construction

Misc.

Note that this section is under construction