March 12, 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.


March 12, 2004
Ant wrote:
>>
>>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.

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?

>>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?)

It's valid D, C, and C++. (according to gcc 3.3.1, anyhow)

> 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
March 12, 2004
On Thu, 11 Mar 2004 20:08:18 -0800, Andy Friesen wrote:

> Ant wrote:
>>>
>>>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.
> 
> Sounds like a bit of an overgeneralization. :)

Of course it is, I'm sorry.

> 
> (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.
March 12, 2004
Ant wrote:

>On Thu, 11 Mar 2004 17:29:54 -0800, Andy Friesen wrote:
>
>  
>
>>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 :p
>>>      
>>>
>>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.
>
>(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:( )
>  
>
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/
March 12, 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...
>>
>>>
>>>"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 allowing
>>>
>>>with
>>>
>>>>() for structs?
>>>
>>>Oversight? :-)
>>>
>>>
>>
>>Walter, what has happened with this? Still doesn't work...
>>
>>-------------------
>>Carlos Santander B.
> 
> 
> 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
> 
March 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

March 12, 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
March 12, 2004
Ant schrieb:

>>(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.

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!

> (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
March 12, 2004
On Fri, 12 Mar 2004 20:54:13 +0100, Ilya Minkov wrote:

> Ant schrieb:
> 
>>>(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.
> 
> 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!
> 
>> (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

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.

March 13, 2004
Ilya Minkov wrote:
> Ant schrieb:
>>> (from Burton Raydons's Dig library example, halhello.d)
[...]
>> (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.

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.

> 
> -eye


-- 
Justin
http://jcc_7.tripod.com/d/