Skip to content

Instantly share code, notes, and snippets.

@jhchabran
Created July 3, 2010 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhchabran/462415 to your computer and use it in GitHub Desktop.
Save jhchabran/462415 to your computer and use it in GitHub Desktop.
Usine := Object clone do (
DummyObject := Object clone do (
Suite := Object clone do (
variantName := nil
bodyBlock := nil
eval := method(x,
context := Object clone
context setSlot(variantName, x)
bodyBlock doInContext(context)
)
)
suite := method(
s := Suite clone
s variantName = call argAt(0) name
s bodyBlock = call argAt(1)
s
)
)
factories := Object clone
suites := Object clone
create := method (factory,
dummy := factories getSlot(factory) clone
parentProto := dummy protos first
parentProto slotNames foreach(slotName,
value := nil
if(parentProto getSlot(slotName) type == "Suite",
if(suites getSlot(slotName),
value = suites getSlot(slotName) + 1
suites setSlot(slotName, value)
,
value = suites setSlot(slotName, 0)
)
dummy setSlot(slotName, dummy getSlot(slotName) eval(value))
)
)
dummy
)
declare := method (factory,
object := Object clone
call sender setSlot(call argAt(1) name, object)
call sender appendProto(DummyObject)
call evalArgAt(2)
factories setSlot(factory,object)
)
)
u := Usine clone
u declare("user", user,
user firstname := "John"
user lastname := "Connor"
user age := suite(a, a+2)
)
a := u create("user")
b := u create("user")
a print
b print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment