Falcon is a multithreaded, multi-paradigm interpreted programming language, with a focus on readability and simplicity. It is dynamically typed, and has automatic garbage collection based on reference counting and a tri-generational garbage collector. In comparison to other languages, it a hybrid of Python and C, with the benefits of Python and the syntax of C.
Falcon is implemented in C++. However, although the compiler and virtual machines do not use object oriented features and could mostly be compiled in C, the lexer and parser make heavy use of such features.
print
__build_class__
id
input
repr
iter
next
round
enumerate
range
zip
globals
locals
alllocals
len
copyright
exit
isinstance
eval
super
getattr
setattr
iscallable
reverse
isiter
min
max
map
abs
method
classmethod
staticmethod
property
getannotation
sum
hasattr
dir
bin
hex
ord
chr
unicode_name
time
math
random
threading
sys
os
sockets
simpleserver
builtins
json
Exceptions
Exception
TypeError
ValueError
AttributeError
KeyError
NameError
IndexError
MemoryError
RecursionError
StopIteration
FileNotFoundError
InvalidOperationError
ImportError
KeyboardInterrupt
AssertionError
ZeroDivisionError
func
class
return
if
else
elif
raise
try
except
finally
for
break
while
import
from
del
assert
continue
lambda
yield
with
:
- Global variable access::
- Nonlocal variable access<name>
:<type>
- Type annotations in function arguments or assignment<function definition> : <type> {
- Type annotation for function return valuef"Text {code}"
- Format strings using code snippetsb"Text"
- Creates a bytes object from string\uXXX
- Unicode escape, whereXXXX
represents a 4 digit hexadecimal string (mandatory)\N...
- Unicode name literal, where...
represents a valid name that represents a unicode code point
- Dunder Attributes
- Types of functions
- Equivalent C++ Types to Falcon Types
- Builtin type methods
- Conventions
Program
m="Placeholder value"
class Falcon{
var=m
func sound(self){
print("Sound!")
}
}
class Peregrine(Falcon){
var=m
func __new__(self){
print("__new__ called")
return super(self).__new__(self)
}
func __init__(self){
print(self)
}
func f(self){
print(self.var)
}
}
x=Peregrine()
y=Peregrine()
a=Peregrine.var
x.var=5
y.var="Value"
b=x.var
x.f()
y.f()
x.sound()
print(x.__bases__)
func f(x,c="A"){
print("Function f says: ","")
print(c)
}
f(1)
dictionary={1:[1,2,3], 2:{1:"A"}, "Hello":"World", [123]:2}
l=list(1,2,3,4,5)
x=object()
y=object()
true = x == y
maybe = x is y
same = x is x
print(500==500)
print("Done")
print(l[3])
print(dictionary[[123]])
try{
if 500 is 200{
raise Exception("500 is not the same object as 200")
}
elif 500 is 500{
raise TypeError("500 is not the same object as 200, but is the same as 500")
}
else{
raise NameError("Else condition reached")
}
}
except Exception e{
print(e)
}
i=0
func x(){
i=i+1
print(i)
if (i==3){
raise ValueError("I is 50!")
}
x()
}
try{
x()
}
except Exception e{
print(e)
}
val=2
print(val.__mul__(5))
func fib(n){
if (n<=1){
return n
}
else{
return fib(n-1)+fib(n-2)
}
}
print(fib(10))
pi=238649.2131693410000000
x=pi*100
print(str(pi))
print(int("1234"))
print(float("10.222"))
for n in [10,20,30]{
print(n)
}
i=0
while i<10{
print(i)
i+=1
}
print(True and False)
print(True or False)
print(not 1==1)
print(100^2)
print(100^2*3)
print(100^6)
When run with ./fpl.exe program.fpl
Output
__new__ called
<Peregrine @ 0xba7a98>
__new__ called
<Peregrine @ 0xba7b40>
5
Value
Sound!
[<class 'Falcon'>, <class 'object'>]
Function f says:
A
True
Done
4
2
500 is not the same object as 200, but is the same as 500
1
2
3
I is 50!
10
55
238649.213169341
1234
10.222
10
20
30
False
True
False
102
98
98
Build Falcon in debug mode
./build.cmd
Build Falcon in release mode
./release.cmd
Run a script
./fpl program
Enter REPL
./fpl
Help
./fpl -h
- Pepper Lang
- py-myopl-code
- BigInt (Used for
int
type) - CPython
- Computed GOTOs
- NXJSON