killme2008 / killme2008/aviatorscript
有没有办法支持流式编程语法,或者其他的idea建议?
- Dominant language
- Java
- Stars
- 5.2k
- Forks
- 906
- PR merge metrics
- No merged PRs in 30d
Description
最典型的,如java8 Stream流式编程。
假设,我注册了几个自定义函数,分别为:
trim(charSequence),对字符串进行trim处理
toStream( listOrArray, fn1, fn2, ...fnN ) ,最终输出非空Stream
toList( Stream ),最终输出为List
则,java代码:
`
List strings = Arrays.asList("a", "b ", " c");
List trimedStrings = strings.stream().map(String::trim).toList();
`
可以用表达式表示为:
`
toList( toStream(strings, 'trim(this)') )。此处this是中间迭代时临时变量,trim(this)是表达式
`
这种配置,个人是觉得阅读起来相对比较反直觉,期望类似形式为:
`
toStream(strings, 'trim(this)').toList()。此处,上一个toStream函数的输出,默认为下一个函数toList的第1个输入。
`
或者,类似java8 Stream类似编程,假设我再新增一个自定义的map函数,作用等同于Stream.map,则写成:
`
toStream(strings).map('trim()').toList()
`
类似的玩法还可以是:
trim(string).replace('a', 'b'),表示,先对string变量进行trim处理,再进行字符a替换成字符b。
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue discusses Java 8 Stream-style syntax, custom functions such as toStream and toList, and chained expressions. Start by reviewing the language's existing expression and function-call syntax, then clarify the desired semantics with maintainers. Done would require an agreed syntax and implementation scope, but the issue does not name files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100