foreach

Nick Sabalausky via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 16 10:30:02 PDT 2014


On 6/16/2014 11:09 AM, Steven Schveighoffer wrote:
> On Mon, 16 Jun 2014 10:53:49 -0400, H. S. Teoh via Digitalmars-d
> <digitalmars-d at puremagic.com> wrote:
>
>> On Mon, Jun 16, 2014 at 09:24:56AM -0400, Steven Schveighoffer via
>> Digitalmars-d wrote:
>>> On Sun, 15 Jun 2014 20:38:53 -0400, H. S. Teoh via Digitalmars-d
>>> <digitalmars-d at puremagic.com> wrote:
>>>
>>> >On Sun, Jun 15, 2014 at 03:05:37AM -0400, Nick Sabalausky via
>>> >Digitalmars-d wrote:
>>> >[...]
>>> >>True story: I once had to put up with a production codebase (the
>>> >>company's *flagship* product) that wasn't asm (it was VB6) and yet was
>>> >>filled with garbage like this:
>>> >>
>>> >>if ...cond... then
>>> >>   ...statements...
>>> >>   goto somelabel
>>> >>end
>>> >>...statements...
>>> >>somelabel:
>>> >>
>>> >>Got posted on thedailywtf for that one.
>>> >
>>> >I see code like that *all the time*. It's about the only sane way you
>>> >can write error-handling code in C:
>>>
>>> No, you are missing something. Something *else*, that goes along with
>>> if.
>>>
>>> ;)
>> [...]
>>
>> Unfortunately, in C, that means a function with n statements will
>> require n levels of if-else nesting. That may be more textbook-correct,
>> but it would be far less readable than the already ugly if-error-goto
>> construct above.
>
> The code above is not what you are talking about. It's straightforward
> if-else.
>

Yes. I can understand the whole "goto error" thing in a VB codebase 
since, just like HS Teoh's C example, it's often the only clean-ish way 
to handle errors in VB (Talking pre-.NET here, of course). The examples 
I was referring to were just general logic. And the "...statements..." 
sections were HUGE! Several hundred lines, and not always indented 
correctly IIRC. So it wasn't anything obvious-looking like the example.



More information about the Digitalmars-d mailing list