def __init__(self, env=None): if env is None: env = global_env.sprout() Actor.__init__(self, env, maildir_script, True) # XXX the following might run before env is initialized, when # restoring from a snapshot. We should just throw out this # env hack and make something better. for key in env.locals: self.script.add_element(Example(key))
def make_account(): from actors import Expression # XXX circular module dependency root_env = global_env.sprout() sender_script = \ Script([Method('send:', ['message'], 'inbox <- ([message] + inbox get)')]) mailbox_script = \ Script([Method('first', [], 'inbox get at: 1'), Method('removefirst', [], 'inbox <- (inbox get from: 2)'), Method('sender', [], 'sender')]) makemailbox_run = \ Method('run', [], Expression('let inbox = makebox holding: []. make sender. make mailbox', {'sender': sender_script, 'mailbox': mailbox_script})) root_env.define('makemailbox', Actor(root_env, Script([makemailbox_run]))) root_env.define('maildirectory', maildir_actor) root_actor = \ Actor(root_env, Script([Text('Welcome to your new account. You should bookmark this page if you ever intend to return, because going back and clicking "Go!" again would create another new account with a different URI.\n\nIn Hmph, everything is an object, and every object has a page with a generated URI. For example, the number 2 is an object. Below, we send it the message "+ 3" and it adds 3 to itself, yielding 5:'), Example('2 + 3'), Example('(3*3) + (4*4)'), Text('The syntax is related to Smalltalk, but not the same. To make a new type of object, decide on what to call it in the local scope, such as Foo, and enter "make Foo":'), Example('make Foo'), Text('You can also give a local name to any other object using "let name = expression". For example:'), Example('let box = makebox holding: true'), Example('box get'), Example('box <- false. box get'), Example("['hello']"), Text("""There's a public directory of message boxes for other users, in maildirectory:"""), Example('maildirectory'), Text('You can create your own mailbox:'), Example('let mailbox = makemailbox run'), Text("""To add it to the directory, enter "maildirectory at: 'alice' put: mailbox sender" into the "Add example" field below, changing alice to some single-word identifier of your choice. (This will fail and return false if that identifier is already taken.) Then inspect "mailbox" to see how to get your messages. A message can be any object, not just plain text."""), Text("""Have fun exploring! Don't put much work into it, at least yet, because this account *will* get zapped during code upgrades; I'm not ready to commit to continuity yet. There will be actual documentation real soon now. Please send feedback to Darius Bacon <*****@*****.**>. Thanks!""") ])) return get_editor(root_actor)