not everything is an expression (most notably assignments)
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 613
- Forks
- 45
- PR merge metrics
- No merged PRs in 30d
Description
hi, I've been using yuescript for a little bit now so I feel pretty familiar with the language. here are some example things that I thought should have worked:
-- parens not working
if (old_val = @v) != new_val
@v = new_val
-- working
old_val = @v
if old_val != new_val
@v = new_val
-- assignment not working
lala = (fn) ->
print "fn:", fn
fn(math.rand!)
lala listener = (val) -> print val -- left hand expression is not assignable
lala (listener = (val) -> print val) -- syntax error
-- working
lala = (fn) ->
print "fn:", fn
fn(math.rand!)
listener = (val) -> print val
lala listener
-- iter not returned
perm = (a) ->
co = coroutine.create ->
permgen a, #a
return -- necessary cause no way to specify no return
iter = ->
code, res = coroutine.resume co
res
-- working
perm = (a) ->
co = coroutine.create ->
permgen a, #a
return -- necessary cause no way to specify no return
iter = ->
code, res = coroutine.resume co
res
iter
-- ideally, I'd like to write:
perm = (a) ->
co = coroutine.create !->
permgen a, #a
iter = ->
code, res = coroutine.resume co
res
-- doesn't consider last expression of do-statement as module value
export default module = do
{foo: true}
-- also, it doesn't think that the assignment is an expression
module = do
lala = {foo: true}
export default module
-- working
module = do
lala = {foo: true}
lala
export default module
-- also works
export default do
{foo: true}
in general I really like the language. I've got a lot of ideas as well for improvements to the language:
- if x isnt nil (is/isnt keywords)
- type val is "function" (compiles to
type(val) == "function"instead oftype(val == "function")) - type val is \function (single backslash is single word text)
- !(var) -> ... (no return)
- !-> ... (no return)
- comma on next line extends function:
lala (v1, v1) -> print v1, v2 , var1 , var2
lastly, the online compiler is quite valuable for seeing what yue compiles to and I really like it.
however, the text area only allows me to click on the top.
this can easily be fixed by setting prism-editor__container to have min-height: 100%. (seen below)
edit: that should be 'min-height' (screenshot invalid)
cheers!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the listed Moon examples in the online compiler and separate parser/compiler expression cases from the editor styling request. Review the language's expression and assignment handling, then verify chosen cases against generated Lua; for the UI item, inspect prism-editor__container and confirm the textarea is clickable throughout. Agree on a narrower scope before implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- compilers, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100