Re: Goto - finally



sheldonlg wrote:
phpCodeHead wrote:
On Jun 24, 9:26 am, Jerry Stuckle <jstuck...@xxxxxxxxxxxxx> wrote:
Mason Barge wrote:

I understand the term procedural code, I understand the term OO, and I
understand spaghetti. What do you mean by "structural"?
[...]
http://en.wikipedia.org/wiki/Structured_programming



Since I just code little pages on my own -- and some of them are quite
complex (again, I understand the term "spaghetti code" although I
prefer to think of mine as "angel hair pasta code") -- I don't have to
worry about other peeps reading it.
I hope you don't have to read it six months or a year from now. Or,
even worse, try to fix it. Such code is hard to understand and even
harder to maintain.



And I've asked this question a dozen times, but still . . . do you
think OOP has sufficient benefits for me, given the info above, to
spend the time to learn and employ it? I've about decided "no", but
then, what if I wanted to get some outside fee work someday?
I really don't much like it. I have a sneaking suspicion that its
primary reason for existence is all the Java programmers who feel
naked without it.
You have that backwards. Java was created as an OO language BECAUSE OO
was so popular, even then. There were many OO languages before Java -
C++ and Smalltalk being the most recognized. OO techniques had caught
on already and were proving their power.

And I agree with asdf - learn about it so you can make an intelligent
choice.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@xxxxxxxxxxxxx
==================

Seriously, are we still arguing this?

http://www.cs.utexas.edu/~EWD/transcriptions/EWD02xx/EWD215.html

IMHO, technically speaking, anytime a program "breaks" from operating
on sequential statements, say, when a method is called, are we not
"going to" some other "labeled" (the function/method) name on some
other line of code somewhere?

For crying out loud, code, with all of its complexities, will never
NOT be "spagetti-like". Get over it.


No, it is not the same. Calling a function is aaying "do this block of code, and stay where you are at the next instruction". In other workds, calling a function is in-line coding. You might want to look at it as a line of pseudo-code that is actually implemented. It is just that rather than repeat it in-line many times, we have it in a separate place. It still is inline code. This differs from spaghetti code with the uni-directional goto statement with its jump to some arbitrary label -- never to return to the calling spot.

Ah, exactly what a real time scheduler does thousands of times a second..

Are multi tasking OS'es spaghetti code: No. Does every single if then else statement result on an assembler level GOTO . Yes.

So since the structured methods use gotos all the time, the issue is to hide them from humans. Well Jerry, mostly, since he gets a pain in his...thing.. when he sees one. And his humanity is questionable.

The ELSE statement implicitly means a GOTO. Every time you write ELSE it really means 'the preceding IF statement must make an _unconditional_ jump to the end of this else statement'.

So there cant be an efficiency problem with the GOTO. Its a human problem.

WE simply moved from
CMP BRANCH NOT EQUAL LABEL1
...
...

JMP LABEL2
LABEL1:
...
...
...
LABEL2:
...
...

to if {} else {}

For example.

You can make huge gains in assembler using GOTOS.

Consider a typical C compatible subroutine exit which tends to [pop the registers its used and then rturn..

say it pops FOUR registers and does a RET.

A minimum of 5 bytes of code usually.

Whereas a JMP STANDARD RET is 3 bytes in a 16 bit computer.
SO you can save two bytes per subroutine..I had to actually do that years ago to cram more functionality into a ROM..

Of course the tradeoff is that it breaks pipelining in a modern processor, and today ROM RAM and the like is cheap..and trained monkeys are expensive, arrogant and stupid.

Hence 'structured programming' to make one monkeys shit look like every other monkeys shit, in the hope they will be able to recognise it and actually read it when one monkey is off sick from a surfeit of bananas.


Fundamentally different.


Not really.

Its just different brains..like 'go up 5 blocks, turn left three blocks, do 27 blocks up there and make a right by the oak tree, and then its the 17th house on the right. versus '1.76 km NNE on a bearing of 279 from here' or 'latitude 67.5, longitude 0.321'

All are accurate. One is longer to write, easier to follow if you dont have a map or GPS..

Spaghetti code is anyway not the worst thing there is. Uncommented blocks nested 27 deep are just as bad, as is a subroutine of indeterminate operation every line..
.



Relevant Pages

  • Re: Goto - finally
    ... Jerry Stuckle wrote: ... This differs from spaghetti code with the uni-directional goto statement with its jump to some arbitrary label -- never to return to the calling spot. ... We are are talking at the least a third generation language, ...
    (comp.lang.php)
  • Re: Goto - finally
    ... Jerry Stuckle ... This differs from spaghetti code with the uni-directional goto statement with its jump to some arbitrary label -- never to return to the calling spot. ... We are are talking at the least a third generation language, ...
    (comp.lang.php)
  • Re: Goto - finally
    ... This differs from spaghetti code with the uni-directional goto statement with its jump to some arbitrary label -- never to return to the calling spot. ... We are are talking at the least a third generation language, ... other monkeys shit, in the hope they will be able to recognise it and actually read it when one monkey is off sick from a surfeit of bananas. ...
    (comp.lang.php)
  • Re: Tcl/TK is indeed dying
    ... The scope of the label ... by definition of C is a goto to other procedure not ... solveCellFast is compared to ... spaghetti code "works". ...
    (comp.lang.tcl)
  • RE: GOTOs to the People - Discussion please!
    ... Do only downward jumps qualify as spaghetti code? ... This brings up the discussion of GOTO since On Error GOTO is a GOTO. ... Public Function MySub(sMyFile as String) as String ... Dim sArgs() as String ...
    (microsoft.public.vb.general.discussion)