Fork me on GitHub
#clr
<
2023-05-30
>
dangercoder19:05:09

I think the new .NET framework and how things are built makes things way more easier to consume from a functional programming language like clojure-clr. No more classes and inheritance is needed. We need some better interop, the only thing that's "blocking me" from using this in anger is async/await. • There's no way to await a task. Sometimes the frameworks/libraries gives you a task. example: https://github.com/Dangercoder/potion/blob/master/examples/dotnet-api/src/dotnet_api/main.cljr#L69 Imagine this: C#

app.MapGet("/todoitems", async (TodoDb db) =>
    await db.Todos.ToListAsync());
Clojure-CLR (with better interop capabilities)
(.MapGet app "/todoitems", ^:async (fn [^TodoDb db]
                                     (await (-> db
                                                .-Todos
                                                (.ToListAsync)))))

👍 2
dangercoder19:05:09

I think the new .NET framework and how things are built makes things way more easier to consume from a functional programming language like clojure-clr. No more classes and inheritance is needed. We need some better interop, the only thing that's "blocking me" from using this in anger is async/await. • There's no way to await a task. Sometimes the frameworks/libraries gives you a task. example: https://github.com/Dangercoder/potion/blob/master/examples/dotnet-api/src/dotnet_api/main.cljr#L69 Imagine this: C#

app.MapGet("/todoitems", async (TodoDb db) =>
    await db.Todos.ToListAsync());
Clojure-CLR (with better interop capabilities)
(.MapGet app "/todoitems", ^:async (fn [^TodoDb db]
                                     (await (-> db
                                                .-Todos
                                                (.ToListAsync)))))

👍 2
isak20:05:43

I'm trying to get it ClojureCLR to work in Linqpad (5 - the .NET Framework version) because I think this could be a really good playground for it. I'm getting this error with the latest Clojure + Spec:

isak20:05:50

Here is the Linqpad file:

isak20:05:08

I tried adding this code before the call to the clojure api, since it looked the files are not the folder the clojure code expects, but I get the same error.

string baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    foreach (var nugetRef in Util.CurrentQuery.NuGetReferences) {
        foreach (var asmPath in nugetRef.GetAssemblyReferences()) {
            var filename = Path.GetFileName(asmPath);
            try {
                File.Copy(asmPath, Path.Combine(baseDir, filename));
            } catch (IOException ex) when (ex.HResult == -2147024816 /* file exists */) {
            }
        }
    }

isak20:05:21

Just tested with Linqpad 7 (the .NET 5+ , non-framework version), and that does work. Very cool.

🙌 2