But I don't think I really needed the ! operator, for example.
But I don't think I really needed the ! operator, for example.
Roberto Ierusalimschy, the creator of Lua, believes that "Local by default is wrong." [1].
I don't necessarily agree that local-by-default is inherently wrong, but every implementation of local-by-default that I've seen has had flaws.
It looks like MoonScript is no different - its scoping rules seem to suffer from the same "madness" as CoffeeScript [2].
-- will print:
-- 15
-- 0
-- 15
-- 10
y = 0
goodfun = (x) ->
local y
y = 10
y + x
badfun = (x) ->
y = 10
y + x
print(goodfun(5))
print(y)
print(badfun(5))
print(y)Just
let x
? That looks weird. Or we're back to "var". Or throwing another keyword at x? let x exist
Also weird. I've often dreamed of a nice lua-like math with syntax aimed at being familiar to a first year college math student, and "let" is an obvious keyword for variable declaration, but unless you go pure functional you need to be able to pre-declare variables.It sounds like you've been pondering the same problems I have.
In my case it's because I've been working on a rules-engine for scientists and currently we're using SQL for the rule language and some of the syntactic warts of SQL are tripping us up.
I keep meaning to learn enough Racket Scheme to experiment with implementing such a language in macros.
Maybe Datalog could make a cleaner base for your project? Just a random thought; bound to be lots more considerations.
Yeah, I have a project right now too where these questions come up -- https://github.com/darius/squeam -- though it's not really ready for anyone.