For example, how can I use System.Console.WriteLine from clojure-clr? In general, what's the rule for exporting/importing functions/classes from other languages such as C#/F# from/to Clojure-clr?
2 Answers
System.Console is loaded by default. You can simply use:
(System.Console/WriteLine "Hello World!")
Another example, using a static class:
(import (System.IO Path))
(println (Path/GetFullPath "."))
2 Comments
Quazi Irfan
is it different from the Java type? or am I missing something?
Maurits Rijk
I don't think there is a difference, although I haven't looked into detail.
in Java, instantiating the Date object, then calls its toString() method, you have to write like the following,
user=> (. (new java.util.Date) (toString))
1 Comment
Torbjørn
While this example works, note that it can also be written as
(. (new java.util.Date) toString) or (.toString (new java.util.Date)).