Created
May 21, 2011 17:50
-
-
Save b1naryth1ef/984719 to your computer and use it in GitHub Desktop.
Simple dict in Gator 3
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
<gator> | |
[.load] | |
.source | |
.eng(engine()) | |
.dict(dict()) | |
.dicty #A simple handler for the dict plugin | |
.math | |
.sys | |
.g3(self) #A _self feature was added after a bunch of python lovers complained XD | |
[/] | |
engine(){ | |
for flag[._self.request()]: | |
write.~.request():> stdout #:> is the new method of pushing elements in line. | |
#eng.init(engine()) | |
._self.eng.init #both of these ways work now. | |
} | |
dict(type,-variable:var){ #The handler for our dictionary elements, -variable loads it when: x.dict() | |
types = [variable, bool] #We don't really need this, but it allows for exstenstion | |
types.g = [._self.var(var), ._self.bool(var)] #Make sure we're using the dict() functions, not globals | |
types.link(g) #variable.g gives ._self.var() | |
if type in.match types: | |
x = match.types.g | |
x.dicty.load(._self) #TWO IN ONE! WOW! | |
else: | |
:>pass #A simple way for handleing pass's safely (AKA no stdout or breaks | |
var(var){ | |
dicty.create.var(var):>return | |
} | |
bool(var){ | |
dicty.esc(var.value) = dicty.create.bool(var) | |
~.link(x) | |
yes = loads.gatnet("~/userbase/andrei/yesno/src/types/yes") | |
no = loads.gatnet("~/userbase/andrei/yesno/src/types/no") | |
if var in.match yes: | |
x = true | |
elif var in.match no: | |
x = false | |
else: | |
:>pass | |
x:>return | |
} | |
} | |
test = "Jim" | |
test2 = "Tom" | |
test3 = "Lucy" | |
test.dict("var") | |
test2.dict("var") | |
test3.dict("var") | |
print jim #Returns "" | |
print tom #Returns "" | |
print lucy #Returns "" | |
tester = "Yes" | |
tester.dict("bool") | |
print tester #Returns true | |
exit:>._self #IF YOU USE SELF DO THIS! You'll have uncaught exceptions otherwise, and stdout spam | |
exit:>engine | |
exit:>%env% | |
<gator.exit //> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment