usage of too much GOTO can be bad pracitce or make influence in the code?

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

usage of too much GOTO can be bad pracitce or make influence in the code?

PICCORO McKAY Lenz
i have some GOTO to avoit large IF-ELSE code blocks and make readable the
code..

the usage of many GOTO instructions can be bad pracitce or make influence
in the code?

i remenber that in BASIC always tell me "dont use too much"

of course GAMBAS IS NOT BASIC (umm that sound familiarr... ;-)


Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: usage of too much GOTO can be bad pracitce or make influence in the code?

gambas-user mailing list
Le 22/06/2017 à 15:21, PICCORO McKAY Lenz a écrit :

> i have some GOTO to avoit large IF-ELSE code blocks and make readable the
> code..
>
> the usage of many GOTO instructions can be bad pracitce or make influence
> in the code?
>
> i remenber that in BASIC always tell me "dont use too much"
>
> of course GAMBAS IS NOT BASIC (umm that sound familiarr... ;-)
>
>
> Lenz McKAY Gerardo (PICCORO)
> http://qgqlochekone.blogspot.com

If your code is more readable with GOTO than without GOTO, then use GOTO.

Note than you have GOSUB too.

Regards,

--
Benoît Minisini

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: usage of too much GOTO can be bad pracitce or make influence in the code?

Jussi Lahtinen
In reply to this post by PICCORO McKAY Lenz
Depends on situation. Usually goto is not needed, but it can be useful.
Impossible to say more without seeing the code.
Usually the problem with goto is that it can render the code hard to debug
or read.


Jussi

On Thu, Jun 22, 2017 at 4:21 PM, PICCORO McKAY Lenz <[hidden email]>
wrote:

> i have some GOTO to avoit large IF-ELSE code blocks and make readable the
> code..
>
> the usage of many GOTO instructions can be bad pracitce or make influence
> in the code?
>
> i remenber that in BASIC always tell me "dont use too much"
>
> of course GAMBAS IS NOT BASIC (umm that sound familiarr... ;-)
>
>
> Lenz McKAY Gerardo (PICCORO)
> http://qgqlochekone.blogspot.com
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: usage of too much GOTO can be bad pracitce or make influence in the code?

PICCORO McKAY Lenz
2017-06-22 10:00 GMT-04:00 Jussi Lahtinen <[hidden email]>:

> Usually the problem with goto is that it can render the code hard to debug
> or read.
>
AH OK, so in large complex dependences must be avoid..

i only use to avoid a similar to this:

if isnull(value ) then
   ' amount of 4000 lines of code

else
   ' amount of other lot of lines
endif

so i put

if not isnull()
  goto codepiecelabel1
endif
  ' amount of lines

codepiecelabel1:
' here the 4000 lines


i cannot use a sub procedures due manage some variables


>
>
> Jussi
>
> On Thu, Jun 22, 2017 at 4:21 PM, PICCORO McKAY Lenz <
> [hidden email]>
> wrote:
>
> > i have some GOTO to avoit large IF-ELSE code blocks and make readable the
> > code..
> >
> > the usage of many GOTO instructions can be bad pracitce or make influence
> > in the code?
> >
> > i remenber that in BASIC always tell me "dont use too much"
> >
> > of course GAMBAS IS NOT BASIC (umm that sound familiarr... ;-)
> >
> >
> > Lenz McKAY Gerardo (PICCORO)
> > http://qgqlochekone.blogspot.com
> > ------------------------------------------------------------
> > ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Gambas-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: usage of too much GOTO can be bad pracitce or make influence in the code?

Tobias Boege-2
On Thu, 22 Jun 2017, PICCORO McKAY Lenz wrote:

> 2017-06-22 10:00 GMT-04:00 Jussi Lahtinen <[hidden email]>:
>
> > Usually the problem with goto is that it can render the code hard to debug
> > or read.
> >
> AH OK, so in large complex dependences must be avoid..
>
> i only use to avoid a similar to this:
>
> if isnull(value ) then
>    ' amount of 4000 lines of code
>
> else
>    ' amount of other lot of lines
> endif
>
> so i put
>
> if not isnull()
>   goto codepiecelabel1
> endif
>   ' amount of lines
>
> codepiecelabel1:
> ' here the 4000 lines
>
>
> i cannot use a sub procedures due manage some variables
>

This is excessive. Maybe you can think about if your variables can
be put into a meaningful class. An object of this class contains all
your relevant variables and you can pass a reference of that object
(as a container for the variables) to a function.

If there's no sensible grouping of variables into classes but you
don't have dozens of variables, then you could try ByRef [1].

Regards,
Tobi

[1] http://gambaswiki.org/wiki/doc/byref

--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: usage of too much GOTO can be bad pracitce or make influence in the code?

Cristiano Guadagnino
In reply to this post by PICCORO McKAY Lenz
Based on your example, I would not find the code using GOTO any more
readable. Quite to the contrary, instead.
And I don't understand why you cannot use a sub. What's the problem with
variables that cannot be solved by passing the needed variables or using
globals?

Anyway, coding style is a matter of taste, so go with what you prefer.
Unless the code needs to be read/perused by others, obviously.

Cris


On Thu, Jun 22, 2017 at 4:10 PM, PICCORO McKAY Lenz <[hidden email]>
wrote:

> 2017-06-22 10:00 GMT-04:00 Jussi Lahtinen <[hidden email]>:
>
> > Usually the problem with goto is that it can render the code hard to
> debug
> > or read.
> >
> AH OK, so in large complex dependences must be avoid..
>
> i only use to avoid a similar to this:
>
> if isnull(value ) then
>    ' amount of 4000 lines of code
>
> else
>    ' amount of other lot of lines
> endif
>
> so i put
>
> if not isnull()
>   goto codepiecelabel1
> endif
>   ' amount of lines
>
> codepiecelabel1:
> ' here the 4000 lines
>
>
> i cannot use a sub procedures due manage some variables
>
>
> >
> >
> > Jussi
> >
> > On Thu, Jun 22, 2017 at 4:21 PM, PICCORO McKAY Lenz <
> > [hidden email]>
> > wrote:
> >
> > > i have some GOTO to avoit large IF-ELSE code blocks and make readable
> the
> > > code..
> > >
> > > the usage of many GOTO instructions can be bad pracitce or make
> influence
> > > in the code?
> > >
> > > i remenber that in BASIC always tell me "dont use too much"
> > >
> > > of course GAMBAS IS NOT BASIC (umm that sound familiarr... ;-)
> > >
> > >
> > > Lenz McKAY Gerardo (PICCORO)
> > > http://qgqlochekone.blogspot.com
> > > ------------------------------------------------------------
> > > ------------------
> > > Check out the vibrant tech community on one of the world's most
> > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > > _______________________________________________
> > > Gambas-user mailing list
> > > [hidden email]
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > >
> > ------------------------------------------------------------
> > ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Gambas-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: usage of too much GOTO can be bad pracitce or make influence in the code?

nando_f
Sometimes GOTO is needed...especially if you want your code to run faster.

Used properly and judiciously, it can make code reading much easier.

--
Open WebMail Project (http://openwebmail.org)


---------- Original Message -----------
From: Cristiano Guadagnino <[hidden email]>
To: mailing list for gambas users <[hidden email]>
Sent: Thu, 22 Jun 2017 16:24:02 +0200
Subject: Re: [Gambas-user] usage of too much GOTO can be bad pracitce or make influence in
the code?

> Based on your example, I would not find the code using GOTO any more
> readable. Quite to the contrary, instead.
> And I don't understand why you cannot use a sub. What's the problem with
> variables that cannot be solved by passing the needed variables or using
> globals?
>
> Anyway, coding style is a matter of taste, so go with what you prefer.
> Unless the code needs to be read/perused by others, obviously.
>
> Cris
>
> On Thu, Jun 22, 2017 at 4:10 PM, PICCORO McKAY Lenz <[hidden email]>
> wrote:
>
> > 2017-06-22 10:00 GMT-04:00 Jussi Lahtinen <[hidden email]>:
> >
> > > Usually the problem with goto is that it can render the code hard to
> > debug
> > > or read.
> > >
> > AH OK, so in large complex dependences must be avoid..
> >
> > i only use to avoid a similar to this:
> >
> > if isnull(value ) then
> >    ' amount of 4000 lines of code
> >
> > else
> >    ' amount of other lot of lines
> > endif
> >
> > so i put
> >
> > if not isnull()
> >   goto codepiecelabel1
> > endif
> >   ' amount of lines
> >
> > codepiecelabel1:
> > ' here the 4000 lines
> >
> >
> > i cannot use a sub procedures due manage some variables
> >
> >
> > >
> > >
> > > Jussi
> > >
> > > On Thu, Jun 22, 2017 at 4:21 PM, PICCORO McKAY Lenz <
> > > [hidden email]>
> > > wrote:
> > >
> > > > i have some GOTO to avoit large IF-ELSE code blocks and make readable
> > the
> > > > code..
> > > >
> > > > the usage of many GOTO instructions can be bad pracitce or make
> > influence
> > > > in the code?
> > > >
> > > > i remenber that in BASIC always tell me "dont use too much"
> > > >
> > > > of course GAMBAS IS NOT BASIC (umm that sound familiarr... ;-)
> > > >
> > > >
> > > > Lenz McKAY Gerardo (PICCORO)
> > > > http://qgqlochekone.blogspot.com
> > > > ------------------------------------------------------------
> > > > ------------------
> > > > Check out the vibrant tech community on one of the world's most
> > > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > > > _______________________________________________
> > > > Gambas-user mailing list
> > > > [hidden email]
> > > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > >
> > > ------------------------------------------------------------
> > > ------------------
> > > Check out the vibrant tech community on one of the world's most
> > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > > _______________________________________________
> > > Gambas-user mailing list
> > > [hidden email]
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > >
> > ------------------------------------------------------------
> > ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Gambas-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
------- End of Original Message -------


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: usage of too much GOTO can be bad pracitce or make influence in the code?

PICCORO McKAY Lenz
In reply to this post by Cristiano Guadagnino
of course was a simple lines.. the code are around 3000 lines.. yes its
complicated..

i have vision . of course.. make the work as JAva works, in the future
maybe i make a framework based on my eforces

Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com

2017-06-22 10:24 GMT-04:00 Cristiano Guadagnino <[hidden email]>:

> Based on your example, I would not find the code using GOTO any more
> readable. Quite to the contrary, instead.
> And I don't understand why you cannot use a sub. What's the problem with
> variables that cannot be solved by passing the needed variables or using
> globals?
>
> Anyway, coding style is a matter of taste, so go with what you prefer.
> Unless the code needs to be read/perused by others, obviously.
>
> Cris
>
>
> On Thu, Jun 22, 2017 at 4:10 PM, PICCORO McKAY Lenz <
> [hidden email]>
> wrote:
>
> > 2017-06-22 10:00 GMT-04:00 Jussi Lahtinen <[hidden email]>:
> >
> > > Usually the problem with goto is that it can render the code hard to
> > debug
> > > or read.
> > >
> > AH OK, so in large complex dependences must be avoid..
> >
> > i only use to avoid a similar to this:
> >
> > if isnull(value ) then
> >    ' amount of 4000 lines of code
> >
> > else
> >    ' amount of other lot of lines
> > endif
> >
> > so i put
> >
> > if not isnull()
> >   goto codepiecelabel1
> > endif
> >   ' amount of lines
> >
> > codepiecelabel1:
> > ' here the 4000 lines
> >
> >
> > i cannot use a sub procedures due manage some variables
> >
> >
> > >
> > >
> > > Jussi
> > >
> > > On Thu, Jun 22, 2017 at 4:21 PM, PICCORO McKAY Lenz <
> > > [hidden email]>
> > > wrote:
> > >
> > > > i have some GOTO to avoit large IF-ELSE code blocks and make readable
> > the
> > > > code..
> > > >
> > > > the usage of many GOTO instructions can be bad pracitce or make
> > influence
> > > > in the code?
> > > >
> > > > i remenber that in BASIC always tell me "dont use too much"
> > > >
> > > > of course GAMBAS IS NOT BASIC (umm that sound familiarr... ;-)
> > > >
> > > >
> > > > Lenz McKAY Gerardo (PICCORO)
> > > > http://qgqlochekone.blogspot.com
> > > > ------------------------------------------------------------
> > > > ------------------
> > > > Check out the vibrant tech community on one of the world's most
> > > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > > > _______________________________________________
> > > > Gambas-user mailing list
> > > > [hidden email]
> > > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > > >
> > > ------------------------------------------------------------
> > > ------------------
> > > Check out the vibrant tech community on one of the world's most
> > > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > > _______________________________________________
> > > Gambas-user mailing list
> > > [hidden email]
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> > >
> > ------------------------------------------------------------
> > ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Gambas-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: usage of too much GOTO can be bad pracitce or make influence in the code?

Fernando Cabral
In reply to this post by Tobias Boege-2
On Thu, 22 Jun 2017, PICCORO McKAY Lenz wrote:

> > i only use to avoid a similar to this:
> >
> > if isnull(value ) then
> >    ' amount of 4000 lines of code
> > else
> >    ' amount of other lot of lines
> > endif
> > if not isnull()
> >   goto codepiecelabel1
> > endif
> >   ' amount of lines
>
> I don't want to be blunt, but I am forced to say that:

a) GOTO is always avoidable (even in COBOL)
b) The need for GOTO usally comes from poor coding (and perhaps poor
languages)
c)  For me, the above example is one of the worst situations to use GOTO.
It makes reading
    and understanding the code very, very hard.

My experience is that when you get to a point where GOTO seems to be the
best solution (sometimes, only solution) then probabibly you have thought
not enough about what you are coding -- or coded well enough.

Finally, if you set the GOTO to break a loop, or to jump to a nearby place,
you might be able to survive.
But if you use it to to jump over 4000 lines of code, that should sound a
LOUD, VERY LOUD alarm. Something is probabily very wrong. I simply can not
think about a situation where you have a single block of 4.000 lines of
code. It should have been broken down into a few tens or pehaps hundreds
functions.

It means, even thou I don't know your code, I would guess it has not been
well thought out..

Regards

- fernando

be put into a meaningful class. An object of this class contains all

> your relevant variables and you can pass a reference of that object
> (as a container for the variables) to a function.
>
> If there's no sensible grouping of variables into classes but you
> don't have dozens of variables, then you could try ByRef [1].
>
> Regards,
> Tobi
>
> [1] http://gambaswiki.org/wiki/doc/byref
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



--
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: [hidden email]
Facebook: [hidden email]
Telegram: +55 (37) 99988-8868
Wickr ID: fernandocabral
WhatsApp: +55 (37) 99988-8868
Skype:  fernandojosecabral
Telefone fixo: +55 (37) 3521-2183
Telefone celular: +55 (37) 99988-8868

Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
nenhum político ou cientista poderá se gabar de nada.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: usage of too much GOTO can be bad pracitce or make influence in the code?

Christof Thalhofer
In reply to this post by PICCORO McKAY Lenz
Am 22.06.2017 um 16:10 schrieb PICCORO McKAY Lenz:

> so i put
>
> if not isnull()
>   goto codepiecelabel1
> endif
>   ' amount of lines
>
> codepiecelabel1:
> ' here the 4000 lines
>
>
> i cannot use a sub procedures due manage some variables
I never understood the religious cruzification of Goto.

Sometimes I do things like:

If anyvar = Null then
   Goto EndAndExit
Endif

'Some or a lot of code ...
'Inside another break:

If anothervar = Null Then
   Goto EndAndExit
Endif


EndAndExit:
End

For that situations I find Goto very useful.

If I use Goto, I only use it to jump downwards. I for me found out that
jumping upwards is a jump to hell.

And if it is really useful (jumping upwards, very very seldom) then it
has to be heavily documented.


Alles Gute

Christof Thalhofer

--
Dies ist keine Signatur


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: usage of too much GOTO can be bad pracitce or make influence in the code?

PICCORO McKAY Lenz
due to many inconsistence responses i must spend time (again) to
investigating..

the problem of goto comes from C to object conversion compilation..

many goto's produce many labels and "jump"'s in assembler code translation
when a C program are compling.. so the resulting program will be more
slower due too many "jumps"

this are poor ilustrated to most of users here in the list due i think
nobody here know (in experience) code in assemble like me..

i case of gambas analizing the code seems are not the same.. due gambas
fist make their own bycode that runtime inderstand and then that runtime
pass to object mahine.. so many things change and its not the same... in
easy words..

so i'm very frustrating due when i try to use gambas in professional way
(due are very promisess and usefully) many questions require spend of time
due situations like that... please users.. dont make conjetures of things
that not known, causes spend of time of otheers

Lenz McKAY Gerardo (PICCORO)
http://qgqlochekone.blogspot.com

2017-06-25 5:01 GMT-04:30 Christof Thalhofer <[hidden email]>:

> Am 22.06.2017 um 16:10 schrieb PICCORO McKAY Lenz:
>
> > so i put
> >
> > if not isnull()
> >   goto codepiecelabel1
> > endif
> >   ' amount of lines
> >
> > codepiecelabel1:
> > ' here the 4000 lines
> >
> >
> > i cannot use a sub procedures due manage some variables
>
> I never understood the religious cruzification of Goto.
>
> Sometimes I do things like:
>
> If anyvar = Null then
>    Goto EndAndExit
> Endif
>
> 'Some or a lot of code ...
> 'Inside another break:
>
> If anothervar = Null Then
>    Goto EndAndExit
> Endif
>
>
> EndAndExit:
> End
>
> For that situations I find Goto very useful.
>
> If I use Goto, I only use it to jump downwards. I for me found out that
> jumping upwards is a jump to hell.
>
> And if it is really useful (jumping upwards, very very seldom) then it
> has to be heavily documented.
>
>
> Alles Gute
>
> Christof Thalhofer
>
> --
> Dies ist keine Signatur
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: usage of too much GOTO can be bad pracitce or make influence in the code?

Fernando Cabral
In reply to this post by Christof Thalhofer
2017-06-25 6:31 GMT-03:00 Christof Thalhofer <[hidden email]>:

>
> > I never understood the religious cruzification of Goto.
>
> No doubt you can use a GOTO in a effective and understandable way.
Especially if you are just jumping a few lines downwards as you mentioned.
But my 40-year long experience with  more than a dozen programming
languages has always shown me this simple truth (for me!):  if I come to a
point where a GOTO is the best solution I can think of, then I'd better
rewrite the code because something has gone stray. To begin with, probabily
I don't know what I am doing. I have not thought enough about the problem
at hand.

Yes, even C has a GOTO. But if I remember correctly the original C Manual,
it briefly mentions it and then recommends against using it.

Now, this is not a religious crucification of GOTO. This is the result of
the 60+ collective experience with GOTOs. I have never met a good
programmer that relies on GOTOs to jump out of spaghetti-like code. That's
because good programmers to not have spaghetti code, to begin with.

But, again, I agree that jumping a few lines down the lane might not
obfuscate the code to the point of making it unreadable. But then again,
"breaks" and "loops" might work better even when you have nested loops.

My two cents.

Regards

- fernando


> Christof Thalhofer
>
> --
> Dies ist keine Signatur
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>


--
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: [hidden email]
Facebook: [hidden email]
Telegram: +55 (37) 99988-8868
Wickr ID: fernandocabral
WhatsApp: +55 (37) 99988-8868
Skype:  fernandojosecabral
Telefone fixo: +55 (37) 3521-2183
Telefone celular: +55 (37) 99988-8868

Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
nenhum político ou cientista poderá se gabar de nada.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: usage of too much GOTO can be bad pracitce or make influence in the code?

Tobias Boege-2
In reply to this post by PICCORO McKAY Lenz
PICCORO, read this mail at your own risk. I won't accept invoices for
wasting your professional time.

On Sun, 25 Jun 2017, PICCORO McKAY Lenz wrote:

> due to many inconsistence responses i must spend time (again) to
> investigating..
>
> the problem of goto comes from C to object conversion compilation..
>
> many goto's produce many labels and "jump"'s in assembler code translation
> when a C program are compling.. so the resulting program will be more
> slower due too many "jumps"
>
> this are poor ilustrated to most of users here in the list due i think
> nobody here know (in experience) code in assemble like me..
>

Oh wow, that's a high footstool you're sitting on.

> so i'm very frustrating due when i try to use gambas in professional way
> (due are very promisess and usefully) many questions require spend of time
> due situations like that... please users.. dont make conjetures of things
> that not known, causes spend of time of otheers
>

What most people talked about were the usual readability concerns which
are the first thing that's brought forward in every one of the countless
"GOTO considered harmful" essays out there. Supposing you asked a general
question about good practices regarding GOTO (which you were, just look
at your opening message!) they also said that it was up to personal
preference in the end. Therefore I don't see the too many inconsistencies
you speak of.

The only one who said anything about performance, which you bring up above,
was nando:

> Sometimes GOTO is needed...especially if you want your code to run faster.

and here I agree with you. The last part is certainly debatable and depends
on the platform (using goto in C is wildly different from using GOTO in
Gambas, see below). *The* standard example, and *perhaps* what he thought
of, is jumping out of 4 nested loops without GOTO. You can do it but at
least the obvious two solutions introduce new functions (i.e. calls and
returns) or some more IFs, both of which are forms of jumps.

> i case of gambas analizing the code seems are not the same.. due gambas
> fist make their own bycode that runtime inderstand and then that runtime
> pass to object mahine.. so many things change and its not the same... in
> easy words..
>

Exactly, so why do you think your concerns about pipelining and branch
prediction at the C -> machine level are relevant at all in Gambas?
The program execution loop in the interpreter is a gigantic jump table.
The execution of every instruction in a Gambas program involves at
least two goto's in C, while the actual Gambas GOTO instruction is
implemented as an arithmetic operation on the program counter!

And no, I'm not conjecturing this; it's right there in the source code.
It should be natural that you read it if you require a deeper understanding
for your professional tasks than what others can provide. Your time is
not more precious than anyone else's on this list.

On a tangent I'm surprised nobody took the opportunity to scold Benoit
in this thread yet :-) Have you never tried modifying one of his parsers,
e.g. gb.markdown:

  $ cd ~/src/gambas3/comp/src/gb.markdown/.src
  // Count non-empty, non-comment lines
  $ egrep -cv "^[ ]*'|^[ ]*$" Markup.module
  798
  // Count labels, GOTO and GOSUB lines which are not commented out
  $ egrep -i ":[ ]*$|GOTO|GOSUB" Markup.module | grep -cv "^[ ]*'"
  75
  // Percentage of directly GOTO-related lines in the markdown parser
  $ pcalc 100*75/798
        9.398496240601503       0x9                     0y1001

Regards,
Tobi

--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: usage of too much GOTO can be bad pracitce or make influence in the code?

Fernando Cabral
>
> On Sun, 25 Jun 2017, PICCORO McKAY Lenz wrote:
> > this are poor ilustrated to most of users here in the list due i think
> > nobody here know (in experience) code in assemble like me..
>
> Lenz, I think you should pay attention to what Tobi has said. Very
instructive and comprehensive (although succinct).
In Assembly, yes, GOTOs are used abundantly. That has to do with the lower
level progamming required by the machine language. But, avoiding machine
language was, perhaps, the main reason why high-level language were
invented in the fifities (BASIC was created in 1964). The newer and the
higher-level the language, the less your programming should require GOTOs.

When you say you have 4.000+ lines of code inside a IF THEN, and 4.000+
more after the ELSE, I would guess your code is very hard to read and
understand. Perhaps you could benefit from some reorganization. For
instance, breaking it down into smaller functions (or subroutines) you can
call as needed.

The more you break it down (up to a point), the easier it is to know what
your are doing at each stage.

On the other hand, functionality and efficacy come first. Performance comes
next. That's because - no matter how fast your program is - if it is not
doing what it is supposed to do, it is useless.

Even in higher-level language, GOTO could be theoretically faster. But we
would be talking about gains of very tyne fractions of milliseconds. Will
it make any difference:  I doubt it. It is hard to think and code
bottleneck could be solved with GOTOs. If it is inefficient, it will
continue to be so even if you spread GOTOs all over.

Many of us consider GOTOs to be an unecessary and confusing command. But If
you feel that using GOTO is your way to go, by all means, use it.

Regards

-fernando




>
> Oh wow, that's a high footstool you're sitting on.
>
> > so i'm very frustrating due when i try to use gambas in professional way
> > (due are very promisess and usefully) many questions require spend of
> time
> > due situations like that... please users.. dont make conjetures of things
> > that not known, causes spend of time of otheers
> >
>
> What most people talked about were the usual readability concerns which
> are the first thing that's brought forward in every one of the countless
> "GOTO considered harmful" essays out there. Supposing you asked a general
> question about good practices regarding GOTO (which you were, just look
> at your opening message!) they also said that it was up to personal
> preference in the end. Therefore I don't see the too many inconsistencies
> you speak of.
>
> The only one who said anything about performance, which you bring up above,
> was nando:
>
> > Sometimes GOTO is needed...especially if you want your code to run
> faster.
>
> and here I agree with you. The last part is certainly debatable and depends
> on the platform (using goto in C is wildly different from using GOTO in
> Gambas, see below). *The* standard example, and *perhaps* what he thought
> of, is jumping out of 4 nested loops without GOTO. You can do it but at
> least the obvious two solutions introduce new functions (i.e. calls and
> returns) or some more IFs, both of which are forms of jumps.
>
> > i case of gambas analizing the code seems are not the same.. due gambas
> > fist make their own bycode that runtime inderstand and then that runtime
> > pass to object mahine.. so many things change and its not the same... in
> > easy words..
> >
>
> Exactly, so why do you think your concerns about pipelining and branch
> prediction at the C -> machine level are relevant at all in Gambas?
> The program execution loop in the interpreter is a gigantic jump table.
> The execution of every instruction in a Gambas program involves at
> least two goto's in C, while the actual Gambas GOTO instruction is
> implemented as an arithmetic operation on the program counter!
>
> And no, I'm not conjecturing this; it's right there in the source code.
> It should be natural that you read it if you require a deeper understanding
> for your professional tasks than what others can provide. Your time is
> not more precious than anyone else's on this list.
>
> On a tangent I'm surprised nobody took the opportunity to scold Benoit
> in this thread yet :-) Have you never tried modifying one of his parsers,
> e.g. gb.markdown:
>
>   $ cd ~/src/gambas3/comp/src/gb.markdown/.src
>   // Count non-empty, non-comment lines
>   $ egrep -cv "^[ ]*'|^[ ]*$" Markup.module
>   798
>   // Count labels, GOTO and GOSUB lines which are not commented out
>   $ egrep -i ":[ ]*$|GOTO|GOSUB" Markup.module | grep -cv "^[ ]*'"
>   75
>   // Percentage of directly GOTO-related lines in the markdown parser
>   $ pcalc 100*75/798
>         9.398496240601503       0x9                     0y1001
>
> Regards,
> Tobi
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



--
Fernando Cabral
Blogue: http://fernandocabral.org
Twitter: http://twitter.com/fjcabral
e-mail: [hidden email]
Facebook: [hidden email]
Telegram: +55 (37) 99988-8868
Wickr ID: fernandocabral
WhatsApp: +55 (37) 99988-8868
Skype:  fernandojosecabral
Telefone fixo: +55 (37) 3521-2183
Telefone celular: +55 (37) 99988-8868

Enquanto houver no mundo uma só pessoa sem casa ou sem alimentos,
nenhum político ou cientista poderá se gabar de nada.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: usage of too much GOTO can be bad pracitce or make influence in the code?

Jussi Lahtinen
In reply to this post by PICCORO McKAY Lenz
People gave you good correct answers. Gambas is not C, and you cannot fix
bad code structure by using goto.
Remember that people here are spending quite a lot of time to decrypt your
messages to be able to help you. And you don't even bother to use spell
checker.
Little bit respect towards others.


Jussi


On Sun, Jun 25, 2017 at 3:18 PM, PICCORO McKAY Lenz <[hidden email]>
wrote:

> due to many inconsistence responses i must spend time (again) to
> investigating..
>
> the problem of goto comes from C to object conversion compilation..
>
> many goto's produce many labels and "jump"'s in assembler code translation
> when a C program are compling.. so the resulting program will be more
> slower due too many "jumps"
>
> this are poor ilustrated to most of users here in the list due i think
> nobody here know (in experience) code in assemble like me..
>
> i case of gambas analizing the code seems are not the same.. due gambas
> fist make their own bycode that runtime inderstand and then that runtime
> pass to object mahine.. so many things change and its not the same... in
> easy words..
>
> so i'm very frustrating due when i try to use gambas in professional way
> (due are very promisess and usefully) many questions require spend of time
> due situations like that... please users.. dont make conjetures of things
> that not known, causes spend of time of otheers
>
> Lenz McKAY Gerardo (PICCORO)
> http://qgqlochekone.blogspot.com
>
> 2017-06-25 5:01 GMT-04:30 Christof Thalhofer <[hidden email]>:
>
> > Am 22.06.2017 um 16:10 schrieb PICCORO McKAY Lenz:
> >
> > > so i put
> > >
> > > if not isnull()
> > >   goto codepiecelabel1
> > > endif
> > >   ' amount of lines
> > >
> > > codepiecelabel1:
> > > ' here the 4000 lines
> > >
> > >
> > > i cannot use a sub procedures due manage some variables
> >
> > I never understood the religious cruzification of Goto.
> >
> > Sometimes I do things like:
> >
> > If anyvar = Null then
> >    Goto EndAndExit
> > Endif
> >
> > 'Some or a lot of code ...
> > 'Inside another break:
> >
> > If anothervar = Null Then
> >    Goto EndAndExit
> > Endif
> >
> >
> > EndAndExit:
> > End
> >
> > For that situations I find Goto very useful.
> >
> > If I use Goto, I only use it to jump downwards. I for me found out that
> > jumping upwards is a jump to hell.
> >
> > And if it is really useful (jumping upwards, very very seldom) then it
> > has to be heavily documented.
> >
> >
> > Alles Gute
> >
> > Christof Thalhofer
> >
> > --
> > Dies ist keine Signatur
> >
> >
> > ------------------------------------------------------------
> > ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Gambas-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> >
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: usage of too much GOTO can be bad pracitce or make influence in the code?

PICCORO McKAY Lenz
In reply to this post by Tobias Boege-2
2017-06-25 12:13 GMT-04:30 Tobias Boege <[hidden email]>:

> PICCORO, read this mail at your own risk. I won't accept invoices for
> wasting your professional time.
>
you forgive it the EULA M$ license  ;-)

Oh wow, that's a high footstool you're sitting on.
>
well its due there's only one source of A&Q for gambas, a mail list.. and
if you dont have property configured the mail.. you never see the response..

"GOTO considered harmful" essays out there. Supposing you asked a general
> question about good practices regarding GOTO (which you were, just look
> at your opening message!) they also said that it was up to personal
> preference in the end. Therefore I don't see the too many inconsistencies
> you speak of.
>
yeah i'm very frustrating make programs and dont have a spanish good source
for..


> The only one who said anything about performance, which you bring up above,
> was nando:
>
> > Sometimes GOTO is needed...especially if you want your code to run
> faster.
>
> and here I agree with you. The last part is certainly debatable and depends
> on the platform (using goto in C is wildly different from using GOTO in
> Gambas, see below). *The* standard example, and *perhaps* what he thought
> of, is jumping out of 4 nested loops without GOTO. You can do it but at
> least the obvious two solutions introduce new functions (i.e. calls and
> returns) or some more IFs, both of which are forms of jumps.

as i spected i cannot show the resulting code now, due companies behavour..
but in my particular case i must ask firts.. and finally i doit by
myselft..

but i paste the result for others like me (know are very few,... but make
great things)

an the next part of your mail are great, thanks for clarify: i reading the
source code for analising but again i must spent more time.. i want made
some projects but the time its the firts enemy for those that have some
little vision...


> > i case of gambas analizing the code seems are not the same.. due gambas

> fist make their own bycode that runtime inderstand and then that runtime
> > pass to object mahine.. so many things change and its not the same... in
> > easy words..
> >
>
> Exactly, so why do you think your concerns about pipelining and branch
> prediction at the C -> machine level are relevant at all in Gambas?
> The program execution loop in the interpreter is a gigantic jump table.
> The execution of every instruction in a Gambas program involves at
> least two goto's in C, while the actual Gambas GOTO instruction is
> implemented as an arithmetic operation on the program counter!
>
> And no, I'm not conjecturing this; it's right there in the source code.
> It should be natural that you read it if you require a deeper understanding
> for your professional tasks than what others can provide. Your time is
> not more precious than anyone else's on this list.
>
eacho one in this list are always by own..  i can see that people here when
gambas releaseing only send bug reports of their used things.. does not try
other either by curiosity ...


> On a tangent I'm surprised nobody took the opportunity to scold Benoit
> in this thread yet :-) Have you never tried modifying one of his parsers,
> e.g. gb.markdown:
>
>   $ cd ~/src/gambas3/comp/src/gb.markdown/.src
>   // Count non-empty, non-comment lines
>   $ egrep -cv "^[ ]*'|^[ ]*$" Markup.module
>   798
>   // Count labels, GOTO and GOSUB lines which are not commented out
>   $ egrep -i ":[ ]*$|GOTO|GOSUB" Markup.module | grep -cv "^[ ]*'"
>   75
>   // Percentage of directly GOTO-related lines in the markdown parser
>   $ pcalc 100*75/798
>         9.398496240601503       0x9                     0y1001
>
interesting.. but as i tell you.. time its our enemy..


>
> Regards,
> Tobi
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gambas-user
Loading...