Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Clojure have an equivalent of Java's import package.*?

Tags:

Or do I have to specifically enumerate every class that I import?

I'm just learning Clojure now, and it seems useful to be able to do something like this in the REPL:

(import '(java.io *))

Not that this is valid syntax, but it would be nice to have something that does the equivalent. It would save some typing, especially when tinkering around. In actual production code I always enumerate each class that I'm importing, regardless of the language, but it's pretty convenient not to have to do so.

like image 824
Jeff Avatar asked Jan 02 '10 05:01

Jeff


People also ask

Can clojure use Java libraries?

Clojure programs get compiled to Java bytecode and executed within a JVM process. Clojure programs also have access to Java libraries, and you can easily interact with them using Clojure's interop facilities.

Is import Java util * A package?

Util package in Java is a built-in package that contains several pre-written utility classes and interfaces. The import java. util. *; statement can be used to load the contents of the Util package in a Java program.

What is import * in Java?

import is a Java keyword. It declares a Java class to use in the code below the import statement. Once a Java class is declared, then the class name can be used in the code without specifying the package the class belongs to. Use the '*' character to declare all the classes belonging to the package.

Which character is used to import the whole package?

Importing an Entire Package To import all the types contained in a particular package, use the import statement with the asterisk (*) wildcard character.

What is CL Clojure-Java interface?

Clojure - Java Interface. As we already know, Clojure code runs on the Java virtual environment at the end. Thus it only makes sense that Clojure is able to utilize all of the functionalities from Java. In this chapter, let’s discuss the correlation between Clojure and Java.

Is there a correlation between Clojure and Java?

As we already know, Clojure code runs on the Java virtual environment at the end. Thus it only makes sense that Clojure is able to utilize all of the functionalities from Java. In this chapter, let’s discuss the correlation between Clojure and Java.

Is Clojure a good language to learn?

Because Clojure has interoperability with Java, there is a high dependency on the Java libraries rather than libraries written in Clojure. So, even though Clojure is a practical and functional language, most programs use Java libraries that tend to be less functional and have other side effects.

What are the types in Clojure?

The types are represented according to the specification of Java Field Descriptors . For example, byte arrays (byte-array []) have a type of " [B". Clojure has support for high-performance manipulation of, and arithmetic involving, Java primitive types in local contexts.


1 Answers

Rich Hickey explains why it is not possible.

like image 150
miaubiz Avatar answered Sep 28 '22 03:09

miaubiz