Movatterモバイル変換


[0]ホーム

URL:


leafo.net

My projects

View more →

Recent guides

View all →

Recent posts

MoonScript v0.2.0

PostedDecember 11, 2011 by leafo (@moonscript)
Tweet

Exactly 3 months ago I releasedMoonScript. The CoffeeScript inspiredlanguage that compiles to Lua. Since then I've both written a lot of MoonScriptand enhanced the MoonScript compiler.

Today I'm proud to release v0.2.0. I've got a handful of new features and bugfixes:

Thanks for checking it out,follow me on twitter for updates orcomplaints.

Changes

  • , is used instead of: for delimiting table slice parts.
  • Class objects store the metatable of their instances in__base.__base isalso used in inheritance when chaining metatables.

New Things

The Language

  • Addedkey-value table comprehensions.
  • Added aswitch statement.
  • The body of a class can contain arbitrary expressions in addition toassigning properties.self in this scope refers to the class itself.
  • Class objects themselves support accessing the properties of the superclassthey extend (like instances).
  • Class objects store their name as a string in the__name property.
  • Enhanced thesuper keyword in instance methods.
  • Bound methods can be created for an object by usingobject\function_name asa value. Calledfunction stubs.
  • Addedexport * statement to export all assigned names following thestatement.
  • Addedexport ^ statement to export all assigning names that begin with acapital letter following the statement.
  • export can be used before any assignment or class declaration to exportjust that assignment (or class declaration).
  • Argument lists can be broken up over several lines with trailing comma.
  • :hello is short hand forhello: hello inside of table literal.
  • Added..= for string concatenation.
  • table.insert no longer used to build accumlated values in comprehensions.

The API

  • Addedloadfile,loadstring, anddofile functions tomoonscript moduleto load/run MoonScript code.
  • Addedto_lua function tomoonscript module to convert a MoonScript codestring to Lua string.

The Tools

Standard Library

I'm now including a small set of useful functions in a single module calledmoon:

require"moon"

Documentation isavailable here.

Bug Fixes

  • Windows line endings don’t break the parser.
  • Fixed issues when using... within comprehensions when the compiled codeuses an intermediate function in the output.
  • Names whose first characters happen to be a keyword don’t break parser.
  • Return statement can have no arguments
  • argument names prefixed with@ in function definitions work outside ofclasses work with default values.
  • Fixed parse issues with the shorthand values within awith block.
  • Numerous other small fixes. Seecommit log.

Other Stuff

Since the first release, I've written one other project in MoonScript (otherthan the compiler). It’s a static site generator calledsitegen. It’swhat I now use to generate all of my project pages and this blog.

leafo.net · Generated Sun Oct 8 13:02:35 2023 bySitegenmastodon.social/@leafo


[8]ページ先頭

©2009-2025 Movatter.jp