[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Shine-0.0.2 - A Shiny Lua Dialect
- From: Richard Hundt <richardhundt@...>
- Date: Sat, 29 Mar 2014 01:24:22 +0100
On 3/29/14 1:14 AM, Rena wrote:
>
> That sounds really cool. I wonder though what is meant by
> Destructuring assignment, parameter guards and richer type system?
>
Destructuring assignment:
local t = { answer = 42, { "a", "b" } }
local { answer = x, { y, z } } = t
print x, y, x -- prints: 42 a b
Parameter guards:
function greet(whom is String)
print "Hello", whom
end
greet(42) -- Error: bad argument #1 to 'greet' (String expected got Number)
By richer type system I mean Shine has nominal types (classes, basically):
class A end
class B extends A end
b = B()
assert b is A -- true
assert b is B -- also true
It's all in the docs ;-)