你喜欢这样定义类吗?这就是 eisa 的 def

// Also: Man = type(function(name)...)
def type Man(name = "Unnamed"):
    @name = name
end
def Man.prototype.say(something):
    tracel @name + ': ' + something
end
var tom = Man.new 'Tom';
tom.say 'Hello'
// Also: Priate = outof(Man)(function(name, spname)...)
def outof(Man) Priate(name = "Unnamed", spname = "Unknown"):
    Man.call this, name
    @spname = spname
end
var beard = Priate.new 'Peter', 'Blue Beard'
tracel beard.spname
beard.say 'Yarr!'
This entry was posted in Discussion, Original, 中文 and tagged , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

3 Comments

  1. j1anb1n
    Posted October 28, 2011 at 2:31 am | Permalink

    outof给人不祥的感觉…
    考虑强制缩进,把end去掉呗

    • Posted October 28, 2011 at 6:08 am | Permalink

      我本来是想用 ex 的,但是太短了……于是改用 outof。
      缩进想过,只是因为有花括弧等形式,所以没用。

  2. Posted November 10, 2011 at 7:05 am | Permalink

    你好,我也非常喜欢你研究的这块东西,比如说编译原理,一直想整个语法比较清晰的静态语言(编译成javascript),
    希望和你交流下心得

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>