游戲編程語言 Squirrel

jopen 12年前發布 | 20K 次閱讀 游戲 游戲開發

Squirrel 是一種高層次勢在必行/面向對象編程語言,設計是一個強大的腳本工具,適合的大小,內存帶寬,實時性要求的應用,如游戲。它具有以下特性:

  • Open Source MIT licence
  • dynamic typing
  • delegation
  • classes & inheritance
  • higher order functions
  • lexical scoping
  • generators
  • cooperative threads(coroutines) 
  • tail recursion
  • exception handling
  • automatic memory management (CPU bursts free; mixed approach ref counting/GC)
  • both compiler and virtual machine fit together in about 7k lines of C++ code and add only around 100kb-150kb the executable size.
  • optional 16bits characters strings
  • powerful embedding api
    • eg. function/classes can be defined by scripts or in C
    • eg. objects can fully exist in the VM or be bound to native code
    • eg. classes created in C can be extended by scripts or vice-versa
    • and more

    Squirrel is inspired by languages like Python,Javascript and especially Lua(The API is very similar and the table code is based on the Lua one)

示例代碼

local table = {
    a = "10"
    subtable = {
        array = [1,2,3]
    },
    [10 + 123] = "expression index"
}

local array=[ 1, 2, 3, { a = 10, b = "string" } ];

foreach(i,val in array)
{
    ::print("the type of val is"+typeof val);
}

項目主頁:http://www.baiduhome.net/lib/view/home/1326607474515

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!