[Tutor] With

Sean 'Shaleh' Perry shalehperry@attbi.com
Mon Jun 9 20:22:04 2003


> >and so on...
> >
> >What exactly would a 'with' do that an 'it' doesn't?
>
> To me it'd be easier to follow and less noisy. YMMV.
>

To those of us who learned it early in our programmer career 'with' just seems 
so much more elegant than assigning to a short named variable.

In C++ I can do:

blah* i = this_long_thing;
i->foo = 2;
i->bar = 'bat';

in Python I can do (as mentioned earlier):

i = this_long_thing
i.foo = 2
i.bar = 'bat'

but it just feels like a hack when I learned the admittedly syntactic sacrine 
of:

with this_long_thing
do
    foo = 2;
    bar = 'bat';
done

I personally used this in Borland's Delphi for GUI code all of the time.  It 
is quite readable when people are used to the idiom.