为什么 parenscript 函数全部改为小写?

发布于 2024-08-08 23:23:01 字数 293 浏览 2 评论 0原文

使用 parenscript 时,如果我执行

(parenscript:ps 
 (slot-value ($ "#mytextarea") 'selectionStart))

它会生成 javascript

$('#mytextarea').selectionstart;

请注意,selectionStart 现在是 selectionstart。它丢失了 Start 上的大写 S! 如何保留大写的 S?

When using parenscript if I execute

(parenscript:ps 
 (slot-value ($ "#mytextarea") 'selectionStart))

It produces the javascript

$('#mytextarea').selectionstart;

Note that selectionStart is now selectionstart. It lost the uppercase S on the Start!
How do I keep that uppercase S around?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沫尐诺 2024-08-15 23:23:01

Parenscript 会自动从 lisp 命名约定(用破折号分隔单词)转换为 CamelCase,因此

(parenscript:ps 
 (slot-value ($ "#mytextarea") 'selection-start))

"$('#mytextarea').selectionStart;"

Parenscript will automatically convert from the lisp naming convention (dashes separating words) to CamelCase, so:

(parenscript:ps 
 (slot-value ($ "#mytextarea") 'selection-start))

results in

"$('#mytextarea').selectionStart;"
温柔女人霸气范 2024-08-15 23:23:01

正如 Pillsy 所说,当 Lisp 编译器读取所有符号时,它们默认都是大写的。不过,有一种方法可以关闭它。请参阅 CLHS,23.1.2(Readtable 大小写对 Lisp 阅读器的影响), 以及访问器的描述 readtable-case了解详细信息。例如,您可以通过将以下内容放入 Lisp 源文件中来启用“反转”模式(这可以说是唯一区分大小写的实用设置):

#.(setf (readtable-case *readtable*) :invert)

不幸的是,ParenScript 似乎并没有太多使用自定义readtable-case 设置,尽管它可以(并且在我看来应该)这样做。

As Pillsy remarked, all symbols are upper-cased by default when they are read by the Lisp compiler. There is a way of turning that off, though. See the CLHS, 23.1.2 (Effect of Readtable Case on the Lisp Reader), and the description of the accessor readtable-case for details. As an example, you can enable the “invert” mode (which is arguably the only practical setting that is also case-sensitive) by putting the following into your Lisp source file:

#.(setf (readtable-case *readtable*) :invert)

Unfortunately, ParenScript does not seem to make much use of a custom readtable-case setting, even though it could (and, in my opinion, should) do so.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文