Skip to content

Instantly share code, notes, and snippets.

@mwja
Last active October 30, 2016 12:35
Show Gist options
  • Save mwja/3c630c87cc9ccbe2c8089534e4b2b3a3 to your computer and use it in GitHub Desktop.
Save mwja/3c630c87cc9ccbe2c8089534e4b2b3a3 to your computer and use it in GitHub Desktop.

Dynamically typed language called Stitch (filetype .st or .stitch) based of Ruby, Python and JavaScript. Spaces are new lines (except for stringed spaces and other cases) which allows for minification. Comments are double quotes and multilined, while strings are single quotes.

To print hello: print('hello')

To get name and print hello $name

name=input('name: ')
print('hello (name)') "to actually print ( and ) do \( and \) respectively"

To differentiate from executing and defining functions you need to specify wether the function is public (accessible by anything) or private (only accessible by the same namespace). It is done by specifying using the syntax public#functionName() and private#functionName(). Default is public.

To make a function which prints hello

public#sayHello()
  print('hello')
end

To make a function which prints hello $name

public#sayHelloTo(name)
  print('hello (name)')
end

To make a class with the property's width and height

ClassName
  public#init() "init function"
    this.width=10
    this.height=10
  end
end

Variable=ClassName()

To extend the class Animal with the name Dog

Animal
  public#init()
    this.name='myAnimalName'
  end
end

Animal.Dog
  public#action()
    print('Bark!')
  end
end
"Dog can do the Animal init() function and action() function. It is called via Dog"

pet=Dog()

Most functions like == for equals and ! for not like in JavaScript apply. To import is a bit like in Python import('filename'), except it runs the code as the source, so A class in file.stitch would not be accessible from file.Class, it would just be Class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment