magic icon indicating copy to clipboard operation
magic copied to clipboard

define generic functions

Open nasser opened this issue 6 years ago • 0 comments

(defn foo [^:T t]
  (let [lst (new List (type-args T))]
    (.Add lst t)
    lst))

(foo 90) ;; => List<long>

should compile to something along the lines of

using System;
using System.Collections.Generic;

public class foo_function {
    public List<T> invoke_magic<T>(T t) {
        var lst = new List<T>();
        lst.Add(t);
        return lst;
    }
    
    public object invoke_clojureclr(object t)
    {
        return invoke_magic(t);
    }
}

nasser avatar May 13 '19 18:05 nasser