| CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Mon, 22 Dec 2025 12:04:18 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20090503083501
location: https://web.archive.org/web/20090503083501/https://andyfischer.github.com/circa/syntax-example.html
server-timing: captures_list;dur=0.519619, exclusion.robots;dur=0.047170, exclusion.robots.policy;dur=0.038354, esindex;dur=0.009036, cdx.remote;dur=5.972869, LoadShardBlock;dur=146.513738, PetaboxLoader3.datanode;dur=54.442598, PetaboxLoader3.resolve;dur=7.432719
x-app-server: wwwb-app221-dc8
x-ts: 302
x-tr: 172
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app221; path=/
x-location: All
x-as: 14061
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Mon, 22 Dec 2025 12:04:19 GMT
content-type: text/html
x-archive-orig-server: nginx/0.6.31
x-archive-orig-date: Sun, 03 May 2009 08:34:55 GMT
x-archive-orig-content-length: 6510
x-archive-orig-last-modified: Thu, 30 Apr 2009 06:45:06 GMT
x-archive-orig-connection: close
x-archive-orig-expires: Mon, 04 May 2009 08:34:55 GMT
x-archive-orig-cache-control: max-age=86400
x-archive-orig-accept-ranges: bytes
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Sun, 03 May 2009 08:35:01 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 51_9_20090503051938_crawl101-c/51_9_20090503083413_crawl101.arc.gz
server-timing: captures_list;dur=0.482561, exclusion.robots;dur=0.014671, exclusion.robots.policy;dur=0.006901, esindex;dur=0.009066, cdx.remote;dur=12.710292, LoadShardBlock;dur=240.751364, PetaboxLoader3.datanode;dur=94.931599, PetaboxLoader3.resolve;dur=226.228521, load_resource;dur=219.225723
x-app-server: wwwb-app221-dc8
x-ts: 200
x-tr: 503
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-as: 14061
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
Circa syntax examples
Circa project
links = [Home
Code
5_minute_intro
Syntax_example
Progress_report
]
Syntax examples
Here's what Circa's syntax looks like. I don't think the syntax is the most interesting part of Circa. But anyway, it is true that you can gleam a lot about the personality of a language from its syntax.
Disclaimer 1: This is not a full language reference or tutorial. (That
hasn't been written yet, sorry).
Disclaimer 2: Some of this syntax might change.
With that in mind, here we go..
-- Comments have two dashes in front of them.
-- Plain values look like this:
an_integer = 1
a_float = 5.0
a_string = "hello"
another_string = 'hi'
a_bool = true
a_hex_integer = 0xff00ff00
-- Function calls look like this:
sum = add(1,3)
print('hello')
-- Function arguments can be separated by commas, semicolons, or just spaces
s = add(1 2 3 4)
s2 = add(4; 3; 2; 1)
print('the result is: ' s+s2)
-- The -> operator is like a function call, it sends the term on the left as an input to
-- the function on the right
'hello' -> print
-- The @ operator is some syntactic sugar for rebinding an identifier to the result of the
-- overall statement.
-- These two lines do exactly the same thing:
my_number = max(my_number, 40)
max(@my_number, 40)
-- Lists are indicated by []s
-- List arguments also can be separated by commas or semicolons or spaces
names = ['Absalom','Bouffant','Chilton']
numbers = [1 2 3]
orders = [locate; evacuate; exterminate]
-- Compound types can be declared
type Point { float x, float y }
p = Point(2,3)
-- Named fields are accessed with a dot
p.x = p.y + 1
-- We can also reinterpret a list to have a given type, using the
-- colon operator. (Circa will check to make sure that the given
-- list fits this type)
untyped_list = [1 2]
untyped_list.x = 0 -- this doesn't work, we don't know which field 'x' is
as_point = untyped_list : Point
as_point.x = 0 -- this does work!
-- If blocks look like this.
-- (Blocks generally end with the 'end' keyword. Indentation is not significant)
if health < 20
print('Warning!')
end
-- For loops iterate over a list
for x in range(10)
print(x)
end
-- Functions can be declared
-- The return type is given by a trailing colon and type name
-- Values can be returned with the 'return' statement.
def sqr(float x): float
return x*x
end
def polar2cartesian(float angle, float dist, Point center) : Point
return [cos(angle), sin(angle)] * dist + center
end
-- Return types are optional
def log_warn(string msg)
print('warn: ' msg)
end
-- When calling a function that expects a compound type, you can
-- be lazy and just write it as a list. The parser will give an error
-- if the list doesn't fit in that type.
p = polar2cartesian(PI, 1, [5 5])
-- "Stateful" values can be declared with the state keyword.
-- These values are preserved across iterations of a loop. They're also preserved
-- across a script reload.
state a = 5
state loc = [10 10] : Point
-- We also have the +=, -=, *=, /= operators
a += 2
-- That's pretty much it.
-- Plain values look like this:
an_integer = 1
a_float = 5.0
a_string = "hello"
another_string = 'hi'
a_bool = true
a_hex_integer = 0xff00ff00
-- Function calls look like this:
sum = add(1,3)
print('hello')
-- Function arguments can be separated by commas, semicolons, or just spaces
s = add(1 2 3 4)
s2 = add(4; 3; 2; 1)
print('the result is: ' s+s2)
-- The -> operator is like a function call, it sends the term on the left as an input to
-- the function on the right
'hello' -> print
-- The @ operator is some syntactic sugar for rebinding an identifier to the result of the
-- overall statement.
-- These two lines do exactly the same thing:
my_number = max(my_number, 40)
max(@my_number, 40)
-- Lists are indicated by []s
-- List arguments also can be separated by commas or semicolons or spaces
names = ['Absalom','Bouffant','Chilton']
numbers = [1 2 3]
orders = [locate; evacuate; exterminate]
-- Compound types can be declared
type Point { float x, float y }
p = Point(2,3)
-- Named fields are accessed with a dot
p.x = p.y + 1
-- We can also reinterpret a list to have a given type, using the
-- colon operator. (Circa will check to make sure that the given
-- list fits this type)
untyped_list = [1 2]
untyped_list.x = 0 -- this doesn't work, we don't know which field 'x' is
as_point = untyped_list : Point
as_point.x = 0 -- this does work!
-- If blocks look like this.
-- (Blocks generally end with the 'end' keyword. Indentation is not significant)
if health < 20
print('Warning!')
end
-- For loops iterate over a list
for x in range(10)
print(x)
end
-- Functions can be declared
-- The return type is given by a trailing colon and type name
-- Values can be returned with the 'return' statement.
def sqr(float x): float
return x*x
end
def polar2cartesian(float angle, float dist, Point center) : Point
return [cos(angle), sin(angle)] * dist + center
end
-- Return types are optional
def log_warn(string msg)
print('warn: ' msg)
end
-- When calling a function that expects a compound type, you can
-- be lazy and just write it as a list. The parser will give an error
-- if the list doesn't fit in that type.
p = polar2cartesian(PI, 1, [5 5])
-- "Stateful" values can be declared with the state keyword.
-- These values are preserved across iterations of a loop. They're also preserved
-- across a script reload.
state a = 5
state loc = [10 10] : Point
-- We also have the +=, -=, *=, /= operators
a += 2
-- That's pretty much it.
Website generated by Jekyll
and hosted by the wonderful GitHub.
For the source of this site, click here
For the source of this site, click here