I like to request some features to make YueScript easier to copy code and use with AI assistant code like ChatGPT and Github Copilot, Tabnine!

未关闭
#152 21 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
20/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
lua
领域
compilers

调研方向

未指定文件、测试或入口点。将这六个语法提案视为独立的设计任务,首先确定哪些请求与 YueScript 现有的语法和编译模型兼容。要视为完成,需要达成一致的范围、记录语法,并为每个接受的功能编写测试。

由索引模型根据 Issue 内容生成。

描述

Well...
I use YueScript daily to write tools and script games as a hobby, but I also work in other languages like Python, javascript, C# and GDScript as a dev. I extend use Github Copilot and sometime ChatGPT. The AI really helpful but they just keep suggest with Python or Lua code. It is a chore to convert them back to YueScript. It is the same when I want to 'borrow' codes online.

Then one idea pop into my mind, why not make YueScript more AI and copy friendly by support more Python, Lua or other lanagues common syntax, notation and make it easier to convert code to YueScript. I think it will be a great feature for YueScript and make it more popular.
Here are some I think will be helpful:

  1. Support create list like table with syntax: arr = []
    YueScript only support [] in list comprehension like Python. It is kind of a wasteful syntax and it is like a chore to must convert all [] => {}. Support [] make code look better, easier to see, AI Copilot friendly and easier to copy, convert from code of other languages like: Python, javascript, json, GDScript, etc.

  2. Support Lua table syntax: {key = val}
    It copies Lua's code table or accepts AI's suggested code without the need to edit it would be nice. And it is a nice style, even GDScript supports it then why won't YueScript support it?

  3. Support declare function style like: function myfunction(parm1, param2) or func myfunction(parm1, param2) or def myfunction(parm1, param2) would be nice.
    It is a common syntax in many languages like Python, Lua, GDScript, etc. It looks better than myfunction = () ->. Yuescript is very nice but I think that humans and AI prefer it more.

  4. I like to write yuescript to make some local tools to process my assets. My OS is Windows, I prefer to use YueScript/Lua over bat/cmd. It would be nice if YueScript supports more template string because "${exe} #{arg1} #{arg2}" is not good on Windows: exe ad arg1/arg2 can have space in the path and require quotes with '"'. It would be nice if YueScript supports raw template string like:

    os.execute [["#{exe}" "#{arg1}" "#{arg2}"]]  -- that maybe confilct with current yuescript raw string
    -- or adopt Python style raw string
      os.execute """
        "{exe}" "{arg1}" "{arg2}"
      """
    -- or adopt js style
      os.execute `"${exe}" "${arg1}" "${arg2}"`
    -- or just add support template to '' string as
      os.execute '"${exe}" "${arg1}" "${arg2}"'
    
  5. Add support 'var' keywords like javascript, GDScript: with feature hoisting as JavaScript's default behavior of moving declarations to the top of functions or global scope. It solves the problem of using a variable before it has been declared without need to use local *:

a = ->
  print "a"
  b!
b = ->
  print "b"
a!  -- attempt to call a nil value (global 'b')

It is the pain when writing utility scripts that have many functions and depend on each other

  1. Add 'elif' as 'elseif'. Well... I code a lot in python, so I make a lot of silly mistake like use 'elif' in Yue.

Thank you and regards!

主要语言
Lua
星标
620
派生
45
平均合并
9 小时 5 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

IppClub/YueScript 的其他 Issue

查看 IppClub/YueScript 的全部 Issue

相似的 Issue

更多 Lua Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。