Thread overview | |||||
---|---|---|---|---|---|
|
April 25, 2020 Blog Post #0108: D-specific Stuff for GUI Programming IV | ||||
---|---|---|---|---|
| ||||
More about arrays and how they can help with programming GUIs and it's right over here: https://gtkdcoding.com/2020/04/25/0108-snippets-iv-arrays.html |
April 25, 2020 Re: Blog Post #0108: D-specific Stuff for GUI Programming IV | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ron Tarrant | On 25.04.20 15:01, Ron Tarrant wrote:
> More about arrays and how they can help with programming GUIs and it's right over here: https://gtkdcoding.com/2020/04/25/0108-snippets-iv-arrays.html
I don't follow your stuff, but I had a look at this one and a couple things stood out to me:
* You're casting a `MyButton` to `MyButton*` in two places. That doesn't make sense. Cast to `void*` if you want to see the class reference as a pointer.
* The text says "for() loop", but you're actually using `foreach` in the code.
* If `newButton` "lasts the lifetime of the for() loop", then better declare it in the loop, not as a field of the class.
* `return(index);` - Lose the parentheses. `return` is not a function.
* You're converting `lastButtonID` from int to string and back to int. That's some pointless back-and-forth.
|
April 25, 2020 Re: Blog Post #0108: D-specific Stuff for GUI Programming IV | ||||
---|---|---|---|---|
| ||||
Posted in reply to ag0aep6g | On Saturday, 25 April 2020 at 13:31:38 UTC, ag0aep6g wrote:
> * You're casting a `MyButton` to `MyButton*` in two places. That doesn't make sense. Cast to `void*` if you want to see the class reference as a pointer.
>
> * The text says "for() loop", but you're actually using `foreach` in the code.
>
> * If `newButton` "lasts the lifetime of the for() loop", then better declare it in the loop, not as a field of the class.
>
> * `return(index);` - Lose the parentheses. `return` is not a function.
>
> * You're converting `lastButtonID` from int to string and back to int. That's some pointless back-and-forth.
Thanks for pointing all this out. I'll add these changes to my todo list.
|
Copyright © 1999-2021 by the D Language Foundation