Skip to content

Commit e9f240a

Browse files
committed
char type upgrade doc
1 parent 6aedf00 commit e9f240a

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

README-EN-source.adoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,21 @@ include::./src/test/java/com/alibaba/qlexpress4/Express4RunnerTest.java[tag=poll
925925

926926
For details, refer to the link:#semicolons[Semicolons] chapter.
927927

928+
=== Obtaining char Type
929+
930+
In QLExpress 3, single characters wrapped in single quotes were parsed as char type, not String.
931+
932+
This caused much confusion for users, for example, the result of `"a"=='a'` would be `false`.
933+
934+
So later in QLExpress 3, the `ExpressRunner.setIgnoreConstChar` option was added. When set to `true`, all characters wrapped in single quotes and double quotes would be parsed as String type. However, this option was turned off by default and required users to manually enable it.
935+
936+
Considering that script users rarely use the `char` primitive type, we directly removed this option in QLExpress 4. All characters wrapped in single quotes and double quotes are now parsed as String type.
937+
938+
If you still need to use `char` type in scripts, you can obtain it through two methods:
939+
940+
* Type casting: `(char) 'a'`
941+
* Type declaration: `char a = 'a'`
942+
928943
== Appendix II How to Contribute?
929944

930945
QLExpress is completely open to community changes. Any suggestions and modifications will be welcome, and after discussion, reasonable ones will be accepted into the main branch.

README-source.adoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,21 @@ include::./src/test/java/com/alibaba/qlexpress4/Express4RunnerTest.java[tag=poll
927927

928928
具体参考 link:#分号[分号] 章节。
929929

930+
=== 获得 char 类型
931+
932+
在 QLExpress 3 中,单引号包裹的单个字符会被解析为 char 类型,而不是 String。
933+
934+
这个给用户带来了不少困惑,比如 `"a"=='a'` 的判断结果是 `false`。
935+
936+
所以后来 QLExpress 3 中新增了 `ExpressRunner.setIgnoreConstChar` 选项,设置为 `true` 后,所有的单引号和双引号包裹的字符都会被解析为 String 类型。但是这个选项默认是关闭的,需要用户手动开启。
937+
938+
考虑到脚本用户很少会使用到 `char` 这种底层类型,我们在 QLExpress 4 中直接取消了这个选项,所有的单引号和双引号包裹的字符都会被解析为 String 类型。
939+
940+
如果您在脚本还是需要使用 `char` 类型,可以通过两种方法获得:
941+
942+
* 类型强转:`(char) 'a'`
943+
* 类型声明:`char a = 'a'`
944+
930945
== 附录二 如何贡献?
931946

932947
QLExpress 对社区的更改完全开放,任何建议和修改,都会受到欢迎,讨论后合理最后会被接纳到主干中。

src/main/java/com/alibaba/qlexpress4/runtime/MemberResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ private static int resolveArgPriority(Class<?> paramType, Class<?> argType) {
235235
if (argType.isPrimitive() && paramType == Object.class) {
236236
return MatchPriority.EXTEND.priority;
237237
}
238-
238+
239239
if (argType == Nothing.class || paramType.isAssignableFrom(argType)) {
240240
return MatchPriority.EXTEND.priority;
241241
}

src/test/java/com/alibaba/qlexpress4/test/property/Parent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public class Parent implements Value {
2222
private static final String staticFinal = "staticFinal";
2323

2424
public String sex = "man";
25-
25+
2626
public int lockStatus;
27-
27+
2828
public Integer lockStatus2;
2929

3030
public Parent() {

0 commit comments

Comments
 (0)