lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

A new Meatlua tutorial is available, which shows through a concrete example how to write a language extension. It introduces runtime type-checking into Metalua, allowing to write things such as:

----------------------------------
function sum (x :: list(number)) :: number
  local s = 0
  for _, n in ipairs (x) do s = s + n end
  return s
end

list = {1, 2, 3, 4, 5}
list_sum = sum (list)
print ("Sum value:", list_sum)
----------------------------------

(I chose '::' rather than ':', because I really wasn't interested into handling ambiguities between type assertions and method invocations)

The tutorial is available at http://luaforge.net/docman/view.php/227/164/tutorial.typecheck.pdf, and the corresponding sources at http://luaforge.net/docman/view.php/227/165/tutorial.typecheck.src.tgz

Feedbacks welcome.

--
Fabien Fleutot
+-- France:
| 11 rue Ferrus
| 75014 Paris
| home:   +33 1 53 80 47 44
| office: +33 1 46 29 40 39
| mobile: +33 6 28 06 09 97