Io的method_mission

当你把消息发送给对象的时候,对象将完成下列事情:
1.计算所有参数,这些参数其实就是消息;
2.获取消息的名称,目标和发送者;
3.尝试用目标上的消息名称读取槽;
3.如果槽存在,返回其数据或触发其包含的方法;
4.如果槽不存在,则把消息转发给它的方法。

用Io代码来表示XML数据
即将
    <body>
    <p>
    This is a simple paragraph.
    </p>
    </body>
变成
    body(
        p("This is the simple paragraph.")
    )
我们把这种新的语言称作LispML
代码如下:
    Builder := Object clone

    Builder forward := method(
        writeln("<", call message name, ">")
        call message arguments foreach(
            arg,
            content := self doMessage(arg);
            if(content type == "Sequence", writeln(content)))
        writeln("</", call message name, ">"))

    Builder ul(
        li("Io"),
        li("Lua"),
        li("JavaScript"))
发布了40 篇原创文章 · 获赞 7 · 访问量 1075

猜你喜欢

转载自blog.csdn.net/BobDay/article/details/104137089