Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Notes on dragon's type system
number:
1
-1
1.0
1.5e10
400_000.40
string:
"Hello, world!"
list:
( 1, 2, 3, 4, 5 )
( "Hello!", "World!", "I", "Am", "Bob!" )
( "And", "A", 1, "Three", 3, "Four!" )
table:
( key: "value", key2: "value2" )
( name: "Kurtis", age: 23, job: "Unemployed", friends: ("John", "Wiliam", "Kitty" ) )
( ( name: "Jackie Chan", age: 42, job: "Martial Artist" ), ( name: "Michael Jackson", age: 400_000, job: "Dancer" ) )
work:
[ a b + ]
[ "String" capitalize ]
comment:
# This is a comment.
definfing words:
word_name: 4
my_rent: 400.00
name: "Kurtis Rainbolt-Greene"
defining verbs: |
verb_name: ( list, of, arguments ) => #logic here#
add: ( a, b ) => a + b
|
add: ( a, b ) do
a + b
end
types:
Number # Standard integer class
String # Standard string class, no '' strings though. Always interpolated.
List # A list of things.
Table # A list of things with keys.
Array # An immutable list of things, a list with {} instead of ()
Hash # Same as Array, but with keys.
Word # A function.
Work # Code.
Type # Regular old class class.
example 1: |
talk: ( name ) => "Hello, " + name
talk "Kurtis" # Result: "Hello, Kurtis"
example 2: |
first_name: "Kurtis"
last_name: "Rainbolt-Greene"
first_name + uppercase last_name
# Result: "Kurtis RAINBOLT-GREENE"
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.