not everything is an expression (most notably assignments)

オープン
#158 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
lua
領域
compilers, web-dev

調査の方向性

オンラインコンパイラで記載された Moon の例を再現し、parser/compiler の式のケースとエディターのスタイリングに関する依頼を分ける。言語の式および代入の処理を確認し、選択したケースを生成された Lua と照合して検証する。UI 項目については prism-editor__container を調べ、textarea 全体がクリック可能であることを確認する。実装前に、より狭いスコープについて合意する。

索引モデルが issue の本文から書いたものです。

説明

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 of type(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)

image

cheers!

主要言語
Lua
スター
620
フォーク
45
平均マージ
9時間 5分
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

IppClub/YueScript のほかの issue

IppClub/YueScript の issue をすべて見る

似ている issue

Lua の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。