News for hackers. Stuff that matters.
Re:Groovy Array: it just keeps going...and going... by Groxx on Monday November 29, 2010 @06:54PM (#1952379)
I'm curious: Why don't people just use `new Object[]{arg1, arg2...}` ?

It's one letter longer than `createArray(arg1, arg1...)`, doesn't require you to include that chunk of code, is infinite in length, and allows you to statically-type it in your type of choice. Heck, it's the same code, just removing a layer of indirection.

edit: noticed it's one character longer, not the same length. Maybe that's why?

Re:Groovy Array: it just keeps going...and going... by chrisbroadfoot on Monday November 29, 2010 @07:38PM (#1952523)
This isn't regular code. This is code for the groovy runtime.
Re:Groovy Array: it just keeps going...and going... by Groxx on Monday November 29, 2010 @08:25PM (#1952652)
So, why don't the Groovy runtime programmers just write `new Object[]{arg1, arg2...}` ?
Re:Groovy Array: it just keeps going...and going... by tedunangst on Tuesday November 30, 2010 @02:08AM (#1953400)
I suspect this is code meant to be called by generated bytecode, and generating the bytecode to call said function is easier than generating the bytecode to make a new object[]?
Re:Groovy Array: it just keeps going...and going... by wlievens on Tuesday November 30, 2010 @06:29AM (#1953796)
It's been a while since I generated JVM bytecode (oh my, five years), but I don't recall there being array initializer instructions. In other words, the new Object[] {...} statement probably translates to a whole bunch of array-write operations on the caller side whereas with a method call you just push them all on the stack and invoke the utility method.