为什么 clojure 将名称中的破折号转换为文件系统中的下划线? [英] Why does clojure convert dashes in names to underscores in the filesystem?

查看:27
本文介绍了为什么 clojure 将名称中的破折号转换为文件系统中的下划线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 clojure 几个月了,我真的不明白为什么命名空间名称中的破折号必须在文件系统中表示为下划线.谁能向我解释一下,是否也可以在文件名中使用破折号?

I have been using clojure for a couple of months now and one thing I really don't understand is why dashes in namespace names must be represented as underscores in the filesystem. Can anyone explain this to me, and is it possible to be able to use dashes in the filenames too?

推荐答案

这是 Java 互操作性的必要解决方法.

It's a necessary workaround for Java interoperability.

当 Clojure 命名空间被 AOT(提前)编译成 Java .class 文件时,它的名称必须是有效的 Java 标识符.破折号在 Java 类名中无效,因此 Clojure 将它们转换为下划线.它还可以将 * 之类的字符转换为 _STAR_ 之类的词.

When a Clojure namespace is AOT (ahead-of-time) compiled into a Java .class file, it has to have a name that is a valid Java identifier. Dashes aren't valid in Java class names, so Clojure converts them to underscores. It also converts characters like * into words like _STAR_.

这篇关于为什么 clojure 将名称中的破折号转换为文件系统中的下划线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆