digitalmars.D - Java Array --> D Array
- Brad Anderson (23/23) Jul 03 2004 I'm not terribly knowledgeable about Java arrays and all the permuatatio...
- Sam McCall (5/6) Jul 03 2004 Me neither, it's not valid java.
- Brad Anderson (13/21) Jul 03 2004 But it is in the SWT code for 3.0 M6. I can't imagine the Eclipse peopl...
- Brad Anderson (4/14) Jul 03 2004 Whoops. It was {this} in Java (curly braces). In any case, that doesn'...
- Sam McCall (3/19) Jul 03 2004 Oops, sorry, that's what I meant: the one I gave was Java, not D, sorry.
- Walter (6/10) Jul 03 2004 Try:
- Andy Friesen (4/18) Jul 03 2004 Satanic alternative:
I'm not terribly knowledgeable about Java arrays and all the permuatations of assignment and such. I don't know what to make of the following: // Java Code public class Control : Widget , IDrawable { ... Control [] computeTabList () { if (isTabGroup ()) { if (getVisible () && getEnabled ()) { return new Control [] [this]; // not sure what this is. } } return new Control [0]; } ... } The compiler complains about implicitly converting from Control to int, and I get that the array index should be integers, but what is Java doing with 'this' in the array index? My first thought was that this is actually an assignment of the new Control[] that is done inside of [ ] in Java. So I tried to use D's { }, but alas, it's not a static array. Any assistance on how to turn this into D code? BA
Jul 03 2004
Brad Anderson wrote:return new Control [] [this]; // not sure what this is.Me neither, it's not valid java. You probably want return new Control[] {this}, which creates a new Control array (dynamically) initialised to [this]. Sam
Jul 03 2004
Sam McCall wrote:Brad Anderson wrote:But it is in the SWT code for 3.0 M6. I can't imagine the Eclipse people would put something out that javac barfs on. I'll look around in the final SWT code for 3.0.return new Control [] [this]; // not sure what this is.Me neither, it's not valid java.You probably want return new Control[] {this}, which creates a new Control array (dynamically) initialised to [this].As for your suggestion, I had already tried that, but DMD said: found '{' when expecting ';' following 'return statement' I settled on this: Control[] ret; ret[0] = this; return ret; which works, but only if I understand their true intent. Thanks for the response, though BA
Jul 03 2004
Whoops. It was {this} in Java (curly braces). In any case, that doesn't work in D. Sorry for the confusion. Still wouldn't mind hearing if my work-around is on target. ThxBut it is in the SWT code for 3.0 M6. I can't imagine the Eclipse people would put something out that javac barfs on. I'll look around in the final SWT code for 3.0.return new Control [] [this]; // not sure what this is.Me neither, it's not valid java.
Jul 03 2004
Brad Anderson wrote:Oops, sorry, that's what I meant: the one I gave was Java, not D, sorry. SamWhoops. It was {this} in Java (curly braces). In any case, that doesn't work in D. Sorry for the confusion.But it is in the SWT code for 3.0 M6. I can't imagine the Eclipse people would put something out that javac barfs on. I'll look around in the final SWT code for 3.0.return new Control [] [this]; // not sure what this is.Me neither, it's not valid java.
Jul 03 2004
"Brad Anderson" <brad dsource.dot.org> wrote in message news:cc5opo$2cdr$1 digitaldaemon.com...I settled on this: Control[] ret; ret[0] = this; return ret;Try: Control[] ret = new Control[1]; ret[0] = this; return ret;
Jul 03 2004
Walter wrote:"Brad Anderson" <brad dsource.dot.org> wrote in message news:cc5opo$2cdr$1 digitaldaemon.com...Satanic alternative: return (&this)[0 .. 1]; -- andyI settled on this: Control[] ret; ret[0] = this; return ret;Try: Control[] ret = new Control[1]; ret[0] = this; return ret;
Jul 03 2004