[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] Cratera Compiler v1.0.0
- From: Egor Skriptunoff <egor.skriptunoff@...>
- Date: Thu, 1 Aug 2019 00:09:59 +0300
On Wed, Jul 31, 2019 at 7:07 AM Soni "They/Them" L. wrote:
Cratera is a language very similar to Lua, and as such most of the Lua
manual applies to it. Additionally, it supports the following syntax
sugar, called "traits":
which is equivalent to:
Is this feature really needed?
Please show an example.
Am I able to invoke a method by its name from a variable in Cratera?
local methodname = "close"
Cratera's feature could be generalized further.
The following two simple rules look like a natural extension to Lua syntax:
- There could be multiple colons in a chain
- Each colon means "use current value as extra argument"
a:b[c].f(x) -> a.b[c].f(a, x)
a.b:[c].f(x) -> a.b[c].f( a.b, x)
a.b[c]:f(x) -> a.b[c].f( a.b[c], x)
a:b[c]:f(x) -> a.b[c].f(a, a.b[c], x)
a.b[c].f:(x) -> a.b[c].f( a.b[c].f, x)
a:b:[c]:f:(x) -> a.b[c].f(a, a.b, a.b[c], a.b[c].f, x)
c:() -> c(c)
It's not a monkey smile in the last line, variable "c" contains a "callable object"