Skip to content

Instantly share code, notes, and snippets.

@guilhermesilveira
Created December 1, 2010 15:55
Show Gist options
  • Save guilhermesilveira/723676 to your computer and use it in GitHub Desktop.
Save guilhermesilveira/723676 to your computer and use it in GitHub Desktop.
pimp_my_language.guilhermecaelum

Ximp

The following code shows the Ximp language output for some specific input, showing some of the benefits from using such a nice language.

Defining something

 an Account
      is positive? { @amount >= 0 }
      withdraw { (amount is (@amount - value)) }

      my_account is Account (amount is 1000)
      my_account is positive?
      new_account is (withdraw from my_account (value is 300))
      new_account is my_account after withdraw (value is 300)

Another type:

 a Manager

Ximping a type

 ximp my Account
      with a Manager

Creating something

 my_account is Account(owner is "guilherme", amount is 50)

 paulo is Manager(name is "Paulo Silveira")

 my_account's manager is paulo

Output

 print my_account's manager's name

Paulo Silveira

Easy to extend

The following examples show how it is easy to define new macros.

Input

 yo, tell me my_account's manager's name

Carlos

State

 my_account, sup dawg?

my owner is guilherme, amount is 50, manager's name is Carlos

Comments

 Hmmm "if you want to contribute, just fork me!"

whatever

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