Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
aeon $ cat -n /tmp/test.aeon
1 class Integer:
2 # Overwrites the default prototype with the actual integer prototype.
3 __set_literal_attr(self, __get_integer_prototype(_), '__prototype')
4
5 def +(other):
6 __integer_add(_, self, other)
7
8 def -(other):
9 __integer_sub(_, self, other)
10
11 def /(other):
12 __integer_div(_, self, other)
13
14 def to_string:
15 __integer_to_string(_, self)
16
17 def to_float:
18 __integer_to_float(_, self)
19
20 class Float:
21 __set_literal_attr(self, __get_float_prototype(_), '__prototype')
22
23 def +(other):
24 __float_add(_, self, other)
25
26 def to_string:
27 __float_to_string(_, self)
28
29 class STDOUT:
30 def self.print(message):
31 __stdout_write(_, message.to_string)
32
33 class String:
34 __set_literal_attr(self, __get_string_prototype(_), '__prototype')
35
36 def to_string:
37 self
38
39 let sum = ((10 + 20 - 2) / 2).to_float + 0.5
40
41 STDOUT.print(sum)
42 STDOUT.print("\n")
43
44 # vim: set ft=aeon sts=2 sw=2 ts=2:
aeon $ ruby bootstrap/bin/compile /tmp/test.aeon
aeon $ cargo run -- /tmp/test.aeonc
Running `target/debug/aeonvm /tmp/test.aeonc`
14.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.