nasser / magic

Morgan And Grand Iron Clojure
http://nas.sr/magic/
365 stars 18 forks source link

can't easily make a generic tuple #43

Open timsgardner opened 5 years ago

timsgardner commented 5 years ago

Would be nice if this worked:

(m/faster
  (System.Tuple/Create :a :b))

Instead, throws:

clojure.lang.ExceptionInfo: Could not find static method Create with args [clojure.lang.Keyword clojure.lang.Keyword] for type System.Tuple while analyzing form (System.Tuple/Create :a :b)
* magic/analyzer/errors/fn
* clojure.lang.MultiFn
* magic/analyzer/analyze-host-forms/analyze-host-call
* clojure.lang.Var
* clojure/tools/analyzer/passes/compile-passesfnfn
* clojure/tools/analyzer/passes/compile-passesfnfn
* clojure/core/partialfn
* clojure/tools/analyzer/ast/walkwalk
* clojure/tools/analyzer/ast/walkwalkwalk
* clojure/tools/analyzer/ast/-update-childrenfn
* clojure.lang.PersistentVector.reduce
* clojure/core/reduce
* clojure/tools/analyzer/ast/-update-children
* clojure/tools/analyzer/ast/update-children-reduced
* clojure/tools/analyzer/ast/walkwalk
* clojure/tools/analyzer/ast/walkwalkwalk
* clojure/tools/analyzer/ast/-update-childrenfn
* clojure.lang.PersistentVector.reduce
* clojure/core/reduce
* clojure/tools/analyzer/ast/-update-children
* clojure/tools/analyzer/ast/update-children-reduced
* clojure/tools/analyzer/ast/walkwalk
* clojure/tools/analyzer/ast/walkwalkwalk
* clojure/tools/analyzer/ast/-update-childrenfn
* clojure.lang.PersistentVector.reduce
* clojure/core/reduce
* clojure/tools/analyzer/ast/-update-children
* clojure/tools/analyzer/ast/update-children-reduced
* clojure/tools/analyzer/ast/walkwalk
* clojure/tools/analyzer/ast/walkwalkwalk
* clojure/tools/analyzer/utils/mapv'
* clojure/tools/analyzer/ast/-update-childrenfn
* clojure.lang.PersistentVector.reduce
* clojure/core/reduce
* clojure/tools/analyzer/ast/-update-children
* clojure/tools/analyzer/ast/update-children-reduced
* clojure/tools/analyzer/ast/walkwalk
* clojure/tools/analyzer/ast/walk
* clojure/tools/analyzer/ast/postwalk
* clojure/tools/analyzer/passes/compile-passesanalyze
* clojure/core/compfn
* magic/analyzer/analyze
* magic/faster/faster-type
* magic/api/faster
* clojure.lang.RestFn
* clojure.lang.Var
  clojure.lang.Compiler.MacroexpandSeq1 (clojure.lang.ISeq)
  clojure.lang.Compiler.macroexpand1 (object)
  clojure.lang.Compiler.Macroexpand (object)
  clojure.lang.Compiler.eval (object)
  clojure.lang.Compiler.eval (object)
* clojure/core/eval
* arcadia/internal/socket-repl/game-thread-evalfnfn

Without Magic, the following works:

(System.Tuple/Create (type-args clojure.lang.Keyword, clojure.lang.Keyword) :a :b)

but the type-args defeat the purpose, you might as well construct the Tuple directly. In Magic, this doesn't work:

(m/faster
  (System.Tuple/Create (type-args clojure.lang.Keyword, clojure.lang.Keyword) :a :b))

throws:

clojure.lang.ExceptionInfo: Could not find static method Create with args [System.Object clojure.lang.Keyword clojure.lang.Keyword] for type System.Tuple while analyzing form (System.Tuple/Create (type-args clojure.lang.Keyword clojure.lang.Keyword) :a :b)
* magic/analyzer/errors/fn
* clojure.lang.MultiFn
* magic/analyzer/analyze-host-forms/analyze-host-call
* clojure.lang.Var
* clojure/tools/analyzer/passes/compile-passesfnfn
* clojure/tools/analyzer/passes/compile-passesfnfn
* clojure/core/partialfn
* clojure/tools/analyzer/ast/walkwalk
* clojure/tools/analyzer/ast/walkwalkwalk
* clojure/tools/analyzer/ast/-update-childrenfn
* clojure.lang.PersistentVector.reduce
* clojure/core/reduce
* clojure/tools/analyzer/ast/-update-children
* clojure/tools/analyzer/ast/update-children-reduced
* clojure/tools/analyzer/ast/walkwalk
* clojure/tools/analyzer/ast/walkwalkwalk
* clojure/tools/analyzer/ast/-update-childrenfn
* clojure.lang.PersistentVector.reduce
* clojure/core/reduce
* clojure/tools/analyzer/ast/-update-children
* clojure/tools/analyzer/ast/update-children-reduced
* clojure/tools/analyzer/ast/walkwalk
* clojure/tools/analyzer/ast/walkwalkwalk
* clojure/tools/analyzer/ast/-update-childrenfn
* clojure.lang.PersistentVector.reduce
* clojure/core/reduce
* clojure/tools/analyzer/ast/-update-children
* clojure/tools/analyzer/ast/update-children-reduced
* clojure/tools/analyzer/ast/walkwalk
* clojure/tools/analyzer/ast/walkwalkwalk
* clojure/tools/analyzer/utils/mapv'
* clojure/tools/analyzer/ast/-update-childrenfn
* clojure.lang.PersistentVector.reduce
* clojure/core/reduce
* clojure/tools/analyzer/ast/-update-children
* clojure/tools/analyzer/ast/update-children-reduced
* clojure/tools/analyzer/ast/walkwalk
* clojure/tools/analyzer/ast/walk
* clojure/tools/analyzer/ast/postwalk
* clojure/tools/analyzer/passes/compile-passesanalyze
* clojure/core/compfn
* magic/analyzer/analyze
* magic/faster/faster-type
* magic/api/faster
* clojure.lang.RestFn
* clojure.lang.Var
  clojure.lang.Compiler.MacroexpandSeq1 (clojure.lang.ISeq)
  clojure.lang.Compiler.macroexpand1 (object)
  clojure.lang.Compiler.Macroexpand (object)
  clojure.lang.Compiler.eval (object)
  clojure.lang.Compiler.eval (object)
* clojure/core/eval
* arcadia/internal/socket-repl/game-thread-evalfnfn
nasser commented 5 years ago

Notably the following also breaks

(m/faster (System.Tuple/Create|[System.Int64 System.Int64]| 1 2))