Icarus
Icarus is an attempt at a completely typeless programming language.
Description
Variables
Each variable does not really have a type. Instead, they have multiple interpretations.
For example, if you set a
to 3
, it could be interpreted as the number three, a string consisting entirely of the the character 3 (ASCII code 51), or perhaps a regular expression that checks for instances of the character 3, if I decide to implement regular expressions.
Variables can be truthy or falsy. If one of a variable's interpretations is truthy, all of them are. Otherwise, they are all falsy.
Anyway, setting or declaring a variable is easy; just do the following:
a = 3
Falsy literals
0
,"0"
, etc.""
Operations
Operation | Description | Example | Evaluation of example |
---|---|---|---|
. | String Concatenation | "a"."b" | "ab" |
+ | Numeric Addition | 1+2 | 3 |
- | Numeric Subtraction | 1-2 | -1 |
* | Numeric Multiplication | 1*2 | 2 |
/ | Numeric Division | 1/2 | 0.5 |
** | Numeric Exponentiation | 1**2 | 1 |
[] | Subscript (gets character in a string) | "Hello"[0] | "H" |
Control Flow
Control flow is somewhat C-like.
if(condition1){ //Code here only executes if condition1 is truthy }else if(condition2){ //Code here only executes if condition1 is falsy, but condition2 is truthy }else{ //Code here only executes if both condition 1 and condition2 are falsy }
while(condition){ //Code here repeats until condition is falsy }
try{ //Code here will try to execute }catch{ //If the code in the try block throws an error, the code here will execute }
Functions
Functions are declared with the function statement, like so:
function functionName(parameter1, parameter2, ...){ //Function code }
Functions are not first-class variables.
There are also built-in functions, such as `print` and `input`.
Examples
Tests if a value is a number
a = input() try{ b = a + 1 print("You entered a number") }catch{ print("You did not enter a number") }