D - with/struct
- Carlos Santander B. (8/8) Mar 27 2003 Hi, can someone please explain to me the reasoning behind not allowing w...
- Walter (4/6) Mar 27 2003 with
- Carlos Santander B. (4/10) Mar 11 2004 Walter, what has happened with this? Still doesn't work...
- Ant (6/23) Mar 11 2004 If you ask me 'with' is up there
- Ilya Minkov (4/12) Mar 11 2004 I don't think i can follow. I come from Delphi where i came to like it.
- Ant (3/8) Mar 11 2004 nobody is perfect ;)
- J C Calvarese (10/43) Mar 11 2004 I like "with". I go out of my way to use it. I'd use it for structs,
- Ant (5/25) Mar 11 2004 As I remember on looks skips the rest of the current
- =?ISO-8859-1?Q?Sigbj=F8rn_Lund_Olsen?= (7/13) Mar 12 2004 Me too.
- J C Calvarese (24/32) Mar 12 2004 It facilitates referring to the same object repeatedly. I'll quote
- Andy Friesen (15/20) Mar 11 2004 There's a case to be made that the with() construct reduces errors as
- Ant (14/41) Mar 11 2004 but that's my point, if your are typing the same identifier over and
- Juan C (9/9) Mar 11 2004 I've never used with. Most of the time I kinda wanted to use with I was ...
- Andy Friesen (16/44) Mar 11 2004 Sounds like a bit of an overgeneralization. :)
- Ant (13/38) Mar 11 2004 Yes! Nothing makes sence on those few lines...
- Ilya Minkov (9/32) Mar 12 2004 Again, why? I think it's beautyful. And how would you like to do it
- Ant (18/55) Mar 12 2004 just create a nested function to do a similar job,
- Ant (10/10) Mar 12 2004 Well, the conclusion is,
- J C Calvarese (14/27) Mar 12 2004 It sounds like he want to use D to create another language. Part of his
- J Anderson (6/30) Mar 11 2004 I like *with* because it makes changes to the code more easy. You only
- C. Sauls (40/73) Mar 12 2004 Hmm... in a world without with...
- Ant (5/6) Mar 12 2004 Seems that every body likes 'with'.
Hi, can someone please explain to me the reasoning behind not allowing with () for structs? ------------------------- Carlos Santander --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.465 / Virus Database: 263 - Release Date: 2003-03-25
Mar 27 2003
"Carlos Santander B." <carlos8294 msn.com> wrote in message news:b5vi3m$25un$1 digitaldaemon.com...Hi, can someone please explain to me the reasoning behind not allowingwith() for structs?Oversight? :-)
Mar 27 2003
In article <b5vmge$2a17$3 digitaldaemon.com>, Walter says..."Carlos Santander B." <carlos8294 msn.com> wrote in message news:b5vi3m$25un$1 digitaldaemon.com...Walter, what has happened with this? Still doesn't work... ------------------- Carlos Santander B.Hi, can someone please explain to me the reasoning behind not allowingwith() for structs?Oversight? :-)
Mar 11 2004
On Thu, 11 Mar 2004 16:54:50 +0000, Carlos Santander B. wrote:In article <b5vmge$2a17$3 digitaldaemon.com>, Walter says...If you ask me 'with' is up there with 'goto' and 'break' and 'continue'. 'with' is an invitation to coders to expose details that should be hidden somewhere else :p Ant"Carlos Santander B." <carlos8294 msn.com> wrote in message news:b5vi3m$25un$1 digitaldaemon.com...Walter, what has happened with this? Still doesn't work... ------------------- Carlos Santander B.Hi, can someone please explain to me the reasoning behind not allowingwith() for structs?Oversight? :-)
Mar 11 2004
I don't think i can follow. I come from Delphi where i came to like it. It is mostly a notational shortcut. -eye Ant schrieb:If you ask me 'with' is up there with 'goto' and 'break' and 'continue'. 'with' is an invitation to coders to expose details that should be hidden somewhere else :p Ant
Mar 11 2004
On Fri, 12 Mar 2004 00:33:49 +0100, Ilya Minkov wrote:I don't think i can follow. I come from Delphi where i came to like it [with]. It is mostly a notational shortcut. -eyenobody is perfect ;) Ant
Mar 11 2004
Ant wrote:On Thu, 11 Mar 2004 16:54:50 +0000, Carlos Santander B. wrote:I like "with". I go out of my way to use it. I'd use it for structs, too, if the compiler allowed it. I don't like "goto" (I prefer my spaghetti on a dinner plate), either. I have to use "break" on all of my switch constructs because I rarely fall-through. I don't think I've ever used "continue". What's it for? :) -- Justin http://jcc_7.tripod.com/d/In article <b5vmge$2a17$3 digitaldaemon.com>, Walter says...If you ask me 'with' is up there with 'goto' and 'break' and 'continue'. 'with' is an invitation to coders to expose details that should be hidden somewhere else :p Ant"Carlos Santander B." <carlos8294 msn.com> wrote in message news:b5vi3m$25un$1 digitaldaemon.com...Walter, what has happened with this? Still doesn't work... ------------------- Carlos Santander B.Hi, can someone please explain to me the reasoning behind not allowingwith() for structs?Oversight? :-)
Mar 11 2004
On Thu, 11 Mar 2004 17:47:48 -0600, J C Calvarese wrote:Ant wrote:That 'break' is different.If you ask me 'with' is up there with 'goto' and 'break' and 'continue'. 'with' is an invitation to coders to expose details that should be hidden somewhere else :p AntI like "with". I go out of my way to use it. I'd use it for structs, too, if the compiler allowed it. I don't like "goto" (I prefer my spaghetti on a dinner plate), either. I have to use "break" on all of my switch constructs because I rarely fall-through.I don't think I've ever used "continue". What's it for? :)As I remember on looks skips the rest of the current iteraction. Ant
Mar 11 2004
I like "with". I go out of my way to use it. I'd use it for structs, too, if the compiler allowed it.Never used with. What's it for?I don't like "goto" (I prefer my spaghetti on a dinner plate), either.Goto gives me nightmares.I have to use "break" on all of my switch constructs because I rarely fall-through.Me too.I don't think I've ever used "continue". What's it for? :)Breaking a loop iteration execution, instead of breaking the loop execution. Very handy. Cheers, Sigbjørn Lund Olsen
Mar 12 2004
Sigbjørn Lund Olsen wrote:It facilitates referring to the same object repeatedly. I'll quote another's work to make my point: [Without "with"] fileSelector = new Button (this) fileSelector.caption ("&File Selector"); fileSelector.onClick.add (&fileSelectorClick); fileSelector.alignLeft (true); fileSelector.gridAddRow (0, r); fileSelector.sticky ("<>^"); [With "with"] with (fileSelector = new Button (this)) { caption ("&File Selector"); onClick.add (&fileSelectorClick); alignLeft (true); gridAddRow (0, r); sticky ("<>^"); } That explains it for me... [...]I like "with". I go out of my way to use it. I'd use it for structs, too, if the compiler allowed it.Never used with. What's it for?Cheers, Sigbjørn Lund Olsen-- Justin http://jcc_7.tripod.com/d/
Mar 12 2004
Ant wrote:If you ask me 'with' is up there with 'goto' and 'break' and 'continue'. 'with' is an invitation to coders to expose details that should be hidden somewhere else :pThere's a case to be made that the with() construct reduces errors as well, as the program isn't typing the same identifier over and over again. It also makes code easier to read. with() can certainly be misused, but so can switch: switch (x) { while (x) { printf("%i\n", x); x++; continue; case 0: x = 1337; continue; case 1: x = -1; continue; } } -- andy
Mar 11 2004
On Thu, 11 Mar 2004 17:29:54 -0800, Andy Friesen wrote:Ant wrote:but that's my point, if your are typing the same identifier over and over you should review something. (you have to forgive me all these rants come from years of working with code of inferior quality and I can assure you: no 'break', 'goto', 'continue' or 'with' are necessary to produce bad code:( )If you ask me 'with' is up there with 'goto' and 'break' and 'continue'. 'with' is an invitation to coders to expose details that should be hidden somewhere else :pThere's a case to be made that the with() construct reduces errors as well, as the program isn't typing the same identifier over and over again.It also makes code easier to read. with() can certainly be misused, but so can switch: switch (x) { while (x) { printf("%i\n", x); x++; continue; case 0: x = 1337; continue; case 1: x = -1; continue; } } -- andySomeone showed before that you could have a statment inside a switch but outside a case! (did you compile that?) is that common to other languages? I don't remember seeing it and certanly I don't intend to use it. Ant
Mar 11 2004
I've never used with. Most of the time I kinda wanted to use with I was copying items from one structure to another, but with only works with one structure at a time. So I'd still have to type out one of them while using with on the other, and that seems like poor (inconsistent) style. If anyone can come up with a with that can be used on several structures at a time then I might use it, but probably not, so don't bother. As to continue and break... I try not to use them, except for break in switches. Most of the times I've used continue it's after a text file read; if the line is empty, just continue.
Mar 11 2004
Ant wrote:Sounds like a bit of an overgeneralization. :) (from Burton Raydons's Dig library example, halhello.d) with (fileSelector = new Button (this)) { caption ("&File Selector"); onClick.add (&fileSelectorClick); alignLeft (true); gridAddRow (0, r); sticky ("<>^"); } Is this really so horrible?There's a case to be made that the with() construct reduces errors as well, as the program isn't typing the same identifier over and over again.but that's my point, if your are typing the same identifier over and over you should review something.It's valid D, C, and C++. (according to gcc 3.3.1, anyhow)with() can certainly be misused, but so can switch: switch (x) { while (x) { printf("%i\n", x); x++; continue; case 0: x = 1337; continue; case 1: x = -1; continue; } }Someone showed before that you could have a statment inside a switch but outside a case! (did you compile that?)is that common to other languages? I don't remember seeing it and certanly I don't intend to use it.The point is that anything can be abused if you look hard enough. with() is no exception, but it's hardly as dangerous as goto. -- andy
Mar 11 2004
On Thu, 11 Mar 2004 20:08:18 -0800, Andy Friesen wrote:Ant wrote:Of course it is, I'm sorry.Sounds like a bit of an overgeneralization. :)There's a case to be made that the with() construct reduces errors as well, as the program isn't typing the same identifier over and over again.but that's my point, if your are typing the same identifier over and over you should review something.(from Burton Raydons's Dig library example, halhello.d) with (fileSelector = new Button (this)) { caption ("&File Selector"); onClick.add (&fileSelectorClick); alignLeft (true); gridAddRow (0, r); sticky ("<>^"); } Is this really so horrible?Yes! Nothing makes sence on those few lines... that's why I started DUI instead of looking into a linux version of dig. I just tool a look at the halhello.d I bet there where no nested functions whe he wrote that. (but it's a shame we lost Burton. He left about the time I came abord. On the DLab group Burton said he was preparing a post with a critique of D (or something like that)) Ant of course this is my opinion.
Mar 11 2004
Ant schrieb:Again, why? I think it's beautyful. And how would you like to do it (better) without with? Just removing with doesn't make it any better you know, instead it looses structure!(from Burton Raydons's Dig library example, halhello.d) with (fileSelector = new Button (this)) { caption ("&File Selector"); onClick.add (&fileSelectorClick); alignLeft (true); gridAddRow (0, r); sticky ("<>^"); } Is this really so horrible?Yes! Nothing makes sence on those few lines... that's why I started DUI instead of looking into a linux version of dig. I just tool a look at the halhello.d I bet there where no nested functions whe he wrote that.(but it's a shame we lost Burton. He left about the time I came abord. On the DLab group Burton said he was preparing a post with a critique of D (or something like that))He's been popping up a few times, esp. when new compiler versions come out, just to say that dig doesn't work. :> Probably he feels somewhat disappointed by something along these lines. Now that his own compiler is too much out-of-date. -eye
Mar 12 2004
On Fri, 12 Mar 2004 20:54:13 +0100, Ilya Minkov wrote:Ant schrieb:just create a nested function to do a similar job, then it can be used to all the 3 buttons on that halhello prog method. or just extend the Button class the create buttons that don't use the usual Button (this example doesn't justitfy that). but the entire thing is wrong should be on the lines of: fileSelector = new Button(this, "&File Selector", &fileSelectorClick); fileSelector.align(Align.EAST); fileSelector.sticky(0.0, 1.0, 0.0, 0.0); grid.add(fileSelector, 0, r); - the ctor should accept the very common parameters for convinience. - alingLeft(), alignRight(), alignTop(), alignBottom(), alignLeftTop()...? - sticky(char[]) is just a bad idea - seems unnatural that the button adds it self to some container. Ant Once I was wrong!!! I thought I had maid a mistake but I didn't. (my boss told me that one) So I could be wrong again.Again, why? I think it's beautyful. And how would you like to do it (better) without with? Just removing with doesn't make it any better you know, instead it looses structure!(from Burton Raydons's Dig library example, halhello.d) with (fileSelector = new Button (this)) { caption ("&File Selector"); onClick.add (&fileSelectorClick); alignLeft (true); gridAddRow (0, r); sticky ("<>^"); } Is this really so horrible?Yes! Nothing makes sence on those few lines... that's why I started DUI instead of looking into a linux version of dig. I just tool a look at the halhello.d I bet there where no nested functions whe he wrote that.(but it's a shame we lost Burton. He left about the time I came abord. On the DLab group Burton said he was preparing a post with a critique of D (or something like that))He's been popping up a few times, esp. when new compiler versions come out, just to say that dig doesn't work. :> Probably he feels somewhat disappointed by something along these lines. Now that his own compiler is too much out-of-date. -eye
Mar 12 2004
Well, the conclusion is, nothing good come out of this discussion. Nobody agrees with me and you guys now put me closer to the radial idiot mark :) I guess I sound much smarter if I keep my mounth close ;) it's also interesting that nobody complains on dig's API. It's so strange! probably it's a windows thing and I'm just not used to it. Ant
Mar 12 2004
Ilya Minkov wrote:Ant schrieb:[...](from Burton Raydons's Dig library example, halhello.d)It sounds like he want to use D to create another language. Part of his plans is some fancy template thing that either reveals a bug in the compiler or a feature that Walter hasn't implemented. Parts of dig (the header stripper, for example) may not work right now, but I think it's mostly been updated. Burton may have lost interest in D, but dig isn't necessarily down for the count. I hope he does post his issues with D, so that I can know what I need to work around. My issues with D are pretty insignificant, so I plan to stick around.(but it's a shame we lost Burton. He left about the time I came abord. On the DLab group Burton said he was preparing a post with a critique of D (or something like that))He's been popping up a few times, esp. when new compiler versions come out, just to say that dig doesn't work. :> Probably he feels somewhat disappointed by something along these lines. Now that his own compiler is too much out-of-date.-eye-- Justin http://jcc_7.tripod.com/d/
Mar 12 2004
Ant wrote:On Thu, 11 Mar 2004 17:29:54 -0800, Andy Friesen wrote:I like *with* because it makes changes to the code more easy. You only need to change the variable name in one place. For me at least it's also easier to read because there is less to read. -- -Anderson: http://badmama.com.au/~anderson/Ant wrote:but that's my point, if your are typing the same identifier over and over you should review something. (you have to forgive me all these rants come from years of working with code of inferior quality and I can assure you: no 'break', 'goto', 'continue' or 'with' are necessary to produce bad code:( )If you ask me 'with' is up there with 'goto' and 'break' and 'continue'. 'with' is an invitation to coders to expose details that should be hidden somewhere else :pThere's a case to be made that the with() construct reduces errors as well, as the program isn't typing the same identifier over and over again.
Mar 11 2004
Hmm... in a world without with... BOOL success; WNDCLASSEX wincls; wincls.cbSize = WNDCLASSEX.sizeof; wincls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; wincls.lpfnWndProc = &mainWinProc; wincls.cbClsExtra = 0; wincls.cbWndExtra = 0; wincls.hInstance = _instance; wincls.hIcon = LoadIcon(NULL, IDI_APPLICATION); wincls.hCursor = LoadCursor(NULL, IDC_ARROW); wincls.hbrBackground = cast(HBRUSH) GetStockObject(WHITE_BRUSH); wincls.lpszMenuName = NULL; wincls.lpszClassName = "MyAppMainWC"; wincls.hIconSm = NULL; success = RegisterClassEx(&wincls); Meanwhile in this world, where we do have with (if only it worked on structs)... WNDCLASSEX wincls; with (wincls) { cbSize = WNDCLASSEX.sizeof; style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; lpfnWndProc = &mainWinProc; cbClsExtra = 0; cbWndExtra = 0; hInstance = _instance; hIcon = LoadIcon(NULL, IDI_APPLICATION); hCursor = LoadCursor(NULL, IDC_ARROW); hbrBackground = cast(HBRUSH) GetStockObject(WHITE_BRUSH); lpszMenuName = NULL; lpszClassName = "MyAppMainWC"; hIconSm = NULL; success = RegisterClassEx(this); } I think I like it in this with-enabled world. Besides, if I remember right with() only exposes the public members of an object anyhow, yes? How does that lead to bugs? -C. Sauls -Invironz Ant wrote:On Thu, 11 Mar 2004 16:54:50 +0000, Carlos Santander B. wrote:In article <b5vmge$2a17$3 digitaldaemon.com>, Walter says...If you ask me 'with' is up there with 'goto' and 'break' and 'continue'. 'with' is an invitation to coders to expose details that should be hidden somewhere else :p Ant"Carlos Santander B." <carlos8294 msn.com> wrote in message news:b5vi3m$25un$1 digitaldaemon.com...Walter, what has happened with this? Still doesn't work... ------------------- Carlos Santander B.Hi, can someone please explain to me the reasoning behind not allowingwith() for structs?Oversight? :-)
Mar 12 2004
On Fri, 12 Mar 2004 05:10:27 -0600, C. Sauls wrote:I think I like it in this with-enabled world.Seems that every body likes 'with'. So it must be a good thing :) thank you all for the examples. Ant
Mar 12 2004