Created
December 20, 2010 17:11
-
-
Save draegtun/748656 to your computer and use it in GitHub Desktop.
Charging Objects in Io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Charging Objects in Io | |
# | |
# See "Charging Objects in Ruby" | |
# - http://timeless.judofyr.net/charging-objects-in-ruby | |
# - http://news.ycombinator.com/item?id=2022107 | |
Rules := Object clone do ( | |
rules := list() | |
+ := method (obj, | |
obj setCharge("positive") | |
rules append(obj) | |
obj | |
) | |
- := method (obj, | |
obj setCharge("negative") | |
rules append(obj) | |
obj | |
) | |
url := method (value, | |
Rule clone setKind("url") setValue(value) | |
) | |
run := method ( | |
rules foreach (println) # just print for now | |
) | |
) | |
Rule := Object clone do ( | |
kind ::= nil | |
value ::= nil | |
charge ::= "neutral" | |
) | |
Rules do ( | |
+ url("http://timeless.judofyr.net/*") | |
- url("http://timeless.judofyr.net/") | |
- url("http://timeless.judofyr.net/changelog/*") | |
) | |
Rules run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment