arcadia-unity / Arcadia

Clojure in Unity
http://arcadia-unity.github.io/
Apache License 2.0
1.68k stars 108 forks source link

Need support for multidimensional arrays #123

Open nasser opened 9 years ago

nasser commented 9 years ago

Some Unity API methods depend on them:

This was mentioned five years ago on the wiki and is confirmed not working:

user=> (|System.Single[,]|. 4 4)
System.InvalidCastException: Cannot cast from source type to destination type.
  at clojure.lang.ArraySeq.createFromObject (System.Object array) [0x00000] in <filename unknown>:0 
  at clojure.lang.RT.seqFrom (System.Object coll) [0x00000] in <filename unknown>:0 
  at clojure.lang.RT.seq (System.Object coll) [0x00000] in <filename unknown>:0 
  at clojure/core$seq__12702.invoke (System.Object ) [0x00000] in <filename unknown>:0 
  at clojure/core$print_sequential__18559.invoke (System.Object , System.Object , System.Object , System.Object , System.Object , System.Object ) [0x00000] in <filename unknown>:0 
  at clojure/core$fn__18967__18971.invoke (System.Object , System.Object ) [0x00000] in <filename unknown>:0 
  at clojure.lang.MultiFn.invoke (System.Object arg1, System.Object arg2) [0x00000] in <filename unknown>:0 
  at clojure/core$pr_on__15627.invoke (System.Object , System.Object ) [0x00000] in <filename unknown>:0 
  at clojure/core$pr__15635.invoke (System.Object ) [0x00000] in <filename unknown>:0 
  at clojure.lang.AFn.ApplyToHelper (IFn fn, ISeq argList) [0x00000] in <filename unknown>:0 
  at clojure.lang.RestFn.applyTo (ISeq arglist) [0x00000] in <filename unknown>:0 
  at clojure/core$apply__13030.invoke (System.Object , System.Object ) [0x00000] in <filename unknown>:0 
  at clojure/core$prn__15653.doInvoke (System.Object ) [0x00000] in <filename unknown>:0 
  at clojure.lang.RestFn.invoke (System.Object arg1) [0x00000] in <filename unknown>:0 
  at arcadia/repl$repl_eval_print$fn__197__201.invoke () [0x00000] in <filename unknown>:0 
  at arcadia/repl$repl_eval_print__204.invoke (System.Object , System.Object ) [0x00000] in <filename unknown>:0 
  at arcadia/repl$repl_eval_string__220.invoke (System.Object , System.Object ) [0x00000] in <filename unknown>:0 
  at arcadia/repl$repl_eval_string__220.invoke (System.Object ) [0x00000] in <filename unknown>:0 
  at arcadia/repl$eval_queue$fn__228__232.invoke () [0x00000] in <filename unknown>:0 
timsgardner commented 9 years ago

omg

nasser commented 9 years ago

You can create them, you just can't look at them (e.g. call seq on them or use them or anything). It's similar to the ArraySeq patch we landed a few months ago.

timsgardner commented 8 years ago

I still hate this bug. I hate it.

nasser commented 8 years ago

Yeah I don't even know what to do. It's a serious semantic difference and the standard library is designed without multidimensional arrays in mind. We'd need e.g. aget to be variadic, and that's going to slow things down some.

LispEngineer commented 8 years ago

Suggestion: Write C# helper functions that do the indexing and assignment into multidimensional arrays and call them using standard CLR interop?