|
PIEBALDconsult wrote: the same as the Turbo Pascal with, which I never used
I used that a lot and liked it but that was in the early 1990s and I have not written a line of pascal in at least 15 years..
John
|
|
|
|
|
Don Kackman wrote: I find statements with with harder to read
$20 says it's mainly because you're not used to it. After using it for years I can say it's not that hard.
|
|
|
|
|
Jeremy Falcon wrote: $20 says it's mainly because you're not used to it. After using it for years I can say it's not that hard.
Sweet! You owe me $20!
I cut my teeth on VB3-6 and have seen (and used) my share of with statements. If common usage were limited to:
with myObject
.field1 = 0
.field2 = 1
end with
it's not so bad.
Unfortunately, over the lifetime of an app all too often you end up with
with myObject
.field1 = 0
if someBool then
.DoSomething
end if
[20 lines later]
.DoSomethingElse
[20 lines later still]
.field3 = .field1 + .field2
[at the bottom of a 500 line method with a bunch of other logic intertwingled]
end with
All of the above mixed in with loops, branches and other objects being used.
Having done plenty of both VB syntax and C style syntax development I think the with statement is really nothing more than a reaction to VB's excess verbosity, saving some keystrokes and sacrificing readability and maintainability.
|
|
|
|
|
Don Kackman wrote: Sweet! You owe me $20!
Um, we didn't shake on it.
Don Kackman wrote: All of the above mixed in with loops, branches and other objects being used.
I agree with that 100%, but I blame the programmer for it rather than the language construct is what I'm trying to get at.
Don Kackman wrote: I think the with statement is really nothing more than a reaction to VB's excess verbosity, saving some keystrokes and sacrificing readability and maintainability.
Most of the time I used it, it wasn't the fault of VB's verbosity but rather I wanted to clean my code up a bit with longer object naming, etc. I reckon to each his own, but methinks the abuse of it is the real issue more than having it available to use when needed.
|
|
|
|
|
Jeremy Falcon wrote: I reckon to each his own, but methinks the abuse of it is the real issue more than having it available to use when needed.
True.
But you still owe me $20!
|
|
|
|
|
Don Kackman wrote: But you still owe me $20!
Um, talk to my assistant about that. What? Who's my assistant? Oh, um, yeah, ask my assistant about that one too.
|
|
|
|
|
I'm actually a little surprised that C# 3 didn't see something like it already (aside from the new member initialization syntax.)
|
|
|
|