1. New keyword added: continue
- Posted by Jeremy Cowgar <jeremy at ?owgar.com> May 11, 2008
- 877 views
Continue has been added to Euphoria SVN. Continue is Exit's sibling.
for i = 1 to length(lines) do if length(lines[i]) = 0 or lines[i][1] = '#' then continue -- start loop at next iteration end if -- You know the line has data and is not a comment line -- process the line end for
-- Jeremy Cowgar http://jeremy.cowgar.com
2. Re: New keyword added: continue
- Posted by CChris <christian.cuvier at agriculture.?ou?.fr> May 11, 2008
- 787 views
Jeremy Cowgar wrote: > > Continue has been added to Euphoria SVN. Continue is Exit's sibling. > > }}} <eucode> > for i = 1 to length(lines) do > if length(lines[i]) = 0 or lines[i][1] = '#' then > continue -- start loop at next iteration > end if > > -- You know the line has data and is not a comment line > -- process the line > end for > </eucode> {{{ > > -- > Jeremy Cowgar > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> This one was sorely needed! Thanks! CChris
3. Re: New keyword added: continue
- Posted by Derek Parnell <ddparnell at bi?pond?com> May 11, 2008
- 807 views
Jeremy Cowgar wrote: > > Continue has been added to Euphoria SVN. Continue is Exit's sibling. But I seriously hope it is going to be renamed to something a lot more natural such as 'next'. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
4. Re: New keyword added: continue
- Posted by Salix <salix at freemai?.?u> May 11, 2008
- 786 views
> Jeremy Cowgar wrote: > > Continue has been added to Euphoria SVN. Continue is Exit's sibling. Oh, at last! Thanks! But I agree with Derek and I'd prefer a more natural such as 'next'. Regards, Salix
5. Re: New keyword added: continue
- Posted by CChris <christian.cuvier at agric?lt?re.gouv.fr> May 11, 2008
- 808 views
Salix wrote: > > > Jeremy Cowgar wrote: > > > Continue has been added to Euphoria SVN. Continue is Exit's sibling. > > Oh, at last! Thanks! > > But I agree with Derek and I'd prefer a more natural such as 'next'. > > Regards, > > Salix Me too, antd that's how it's named in Æ. But naming discussions are so ... , well, that I won't care how it gets eventually named, as long as it stays in the language. CChris
6. Re: New keyword added: continue
- Posted by Bernie Ryan <xotron at blu?f?og.com> May 11, 2008
- 814 views
I'd prefer a more natural such as 'next'. Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
7. Re: New keyword added: continue
- Posted by Arthur Crump <arthur.crump at ?tlw?rld.com> May 11, 2008
- 821 views
Just another vote for 'next' rather than 'continue' in a for statement. I am old enough to remember when 'next' was the end of a for statement instead of the much better 'end for' used now, but I think the proposal is a better use of .next' Arthur Crump, Cheshire, UK. ---------------------------- Derek Parnell wrote: > > Jeremy Cowgar wrote: > > > > Continue has been added to Euphoria SVN. Continue is Exit's sibling. > > > But I seriously hope it is going to be renamed to something a lot more natural > such as 'next'. > > > -- > Derek Parnell > Melbourne, Australia > Skype name: derek.j.parnell
8. Re: New keyword added: continue
- Posted by Mike Sywensky <michaelsy at yah?o.com> May 11, 2008
- 825 views
Arthur Crump wrote: > > Just another vote for 'next' rather than 'continue' in a for statement. > > I am old enough to remember when 'next' was the end of a for statement > instead of the much better 'end for' used now, but I think the proposal > is a better use of .next' > > Arthur Crump, Cheshire, UK. > > ---------------------------- > Derek Parnell wrote: > > > > Jeremy Cowgar wrote: > > > > > > Continue has been added to Euphoria SVN. Continue is Exit's sibling. > > > > > > But I seriously hope it is going to be renamed to something a lot more > > natural > > such as 'next'. > > > > > > -- > > Derek Parnell > > Melbourne, Australia > > Skype name: derek.j.parnell Although it may not make as much sense for someone learing euphoria as a first language, I imagine most people are not using it as a first language. My guess is most people are coming from other languages such as VB or C. 'continue' is what is used by both languages. That is my vote.
9. Re: New keyword added: continue
- Posted by Jeremy Cowgar <jeremy at cowgar.??m> May 11, 2008
- 815 views
Mike Sywensky wrote: > > Although it may not make as much sense for someone learing euphoria as a first > language, I imagine most people are not using it as a first language. > > My guess is most people are coming from other languages such as VB or C. > 'continue' > is what is used by both languages. That is my vote. I just went to the computer language shootout and looked at the more popular languages there. I suppose a more detailed study could be done via the TIBOE language index, but here are my findings: python = continue c = continue vb = continue d = continue basic = continue pascal = continue php = continue perl = next javascript = continue tcl = continue I agree after conversations here, looking in dictionary and comparing to other devices, that next makes sense, but most people who program do not program in one language, thus, similarity to a degree is good. But the choice between continue, next, repeat, again or whatever else may come up is not a huge deal to me personally. I am forced to use a few different languages and have to adapt to minor nuances like this all the time, so... before making any changes to the naming, I would like to hear more feedback from others who have not spoken yet about the topic. For me to change continue to next or whatever is about a 10-15 minute job for me, not a big deal and can be done at any time, so I am going to no act quickly, but let there be some more discussion. -- Jeremy Cowgar http://jeremy.cowgar.com
10. Re: New keyword added: continue
- Posted by Bernie Ryan <xotron at bluefr?g?com> May 11, 2008
- 800 views
NEXT takes the least amount of typing. Bernie My files in archive: WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API Can be downloaded here: http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan
11. Re: New keyword added: continue
- Posted by c.k.lester <euphoric at ckl??ter.com> May 11, 2008
- 818 views
Jeremy Cowgar wrote: > > I agree after conversations here, looking in dictionary and comparing to other > devices, that next makes sense, but most people who program do not program in > one language, thus, similarity to a degree is good. I vote for 'next.' I think VBA uses next and I use VBA at work.
12. Re: New keyword added: continue
- Posted by Jeremy Cowgar <jeremy at c?wgar.co?> May 11, 2008
- 798 views
c.k.lester wrote: > I vote for 'next.' I think VBA uses next and I use VBA at work. VBA does not use next as a continue. It uses next as a end for... for int i = 1 to 10 ' do some code here next To implement continue in VBA you use goto... for int i = 1 to 10 if i = 5 goto continue ' do some code continue: ' Label right next to the end of the for loop next So, next in Euphoria would conflict totally w/your next in VBA. -- Jeremy Cowgar http://jeremy.cowgar.com
13. Re: New keyword added: continue
- Posted by c.k.lester <euphoric at ckleste??com> May 11, 2008
- 820 views
Jeremy Cowgar wrote: > c.k.lester wrote: > > I vote for 'next.' I think VBA uses next and I use VBA at work. > VBA does not use next as a continue. It uses next as a end for... Well, you can see I never use a continue construct. :D I still like 'next' better because it's more appropriate and I only have to type 4 letters instead of 8. That's a 50% increase in efficiency.
14. Re: New keyword added: continue
- Posted by yuku <yuku at ikitek.co?> May 11, 2008
- 822 views
'next' is more likely to be used as a variable name - linked list node's next - next entry - next coming input so i vote for 'continue'.
15. Re: New keyword added: continue
- Posted by Matt Lewis <matthewwalkerlewis at gmai?.?om> May 11, 2008
- 757 views
Mike Sywensky wrote: > > Although it may not make as much sense for someone learing euphoria as a first > language, I imagine most people are not using it as a first language. > > My guess is most people are coming from other languages such as VB or C. > 'continue' > is what is used by both languages. That is my vote. I've used both 'continue' and 'next'. Either one is fine by me. Matt
16. Re: New keyword added: continue
- Posted by Matt Lewis <matthewwalkerlewis at gmail.??m> May 11, 2008
- 796 views
c.k.lester wrote: > > Jeremy Cowgar wrote: > > c.k.lester wrote: > > > I vote for 'next.' I think VBA uses next and I use VBA at work. > > VBA does not use next as a continue. It uses next as a end for... > > Well, you can see I never use a continue construct. :D > > I still like 'next' better because it's more appropriate and I only have to > type 4 letters instead of 8. That's a 50% increase in efficiency. And let's be honest here, folks, CK needs all the help he can get... Matt
17. Re: New keyword added: continue
- Posted by Jason Gade <jaygade at y?hoo.c?m> May 11, 2008
- 816 views
Matt Lewis wrote: > > Mike Sywensky wrote: > > > > Although it may not make as much sense for someone learing euphoria as a > > first > > language, I imagine most people are not using it as a first language. > > > > My guess is most people are coming from other languages such as VB or C. > > 'continue' > > is what is used by both languages. That is my vote. > > I've used both 'continue' and 'next'. Either one is fine by me. > > Matt I prefer continue, I think, for reasons that others have mentioned -- existing use of "next" as an identifier. -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.
18. Re: New keyword added: continue
- Posted by c.k.lester <euphoric at ck?ester.?om> May 11, 2008
- 767 views
Matt Lewis wrote: > c.k.lester wrote: > > I still like 'next' better because it's more appropriate and I only have to > > type 4 letters instead of 8. That's a 50% increase in efficiency. > And let's be honest here, folks, CK needs all the help he can get... Amen to that!
19. Re: New keyword added: continue
- Posted by Derek Parnell <ddparnell at bigpo?d.com> May 11, 2008
- 826 views
- Last edited May 12, 2008
Mike Sywensky wrote: > Although it may not make as much sense for someone > learing euphoria as a first language, ... or still make sense after years of usage. > I imagine most people are not using it as a first language. ... and yet there are a lot of people who are actually using Eu as a first-ish language. > My guess is most people are coming from other languages such as VB or C. What is this 'C' thing you speak of and what has Victoria Bitter got to do with programming? -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
20. Re: New keyword added: continue
- Posted by Jeremy Cowgar <jeremy at c?w?ar.com> May 11, 2008
- 803 views
- Last edited May 12, 2008
Derek Parnell wrote: > > ... and yet there are a lot of people who are actually using Eu as a first-ish > language. And by teaching the continue, we are not doing them a dis-service. Most programmers today are going to be multi-lingual. Not all, but most. Please see the post: http://www.openeuphoria.org/EUforum/m20765.html Which lists a few languages that I researched. I found 1 that uses next, and it is perl, but it has a rather complex looping interface such as a continue block that contains next, last, redo and retry. -- Jeremy Cowgar http://jeremy.cowgar.com
21. Re: New keyword added: continue
- Posted by Derek Parnell <ddparnell at b?gp?nd.com> May 11, 2008
- 774 views
- Last edited May 12, 2008
Jeremy Cowgar wrote: I suppose a more detailed study could be done via the TIBOE > language index, but here are my findings: > > python = continue > c = continue > vb = continue > d = continue > basic = continue > pascal = continue > php = continue > perl = next > javascript = continue > tcl = continue But aren't we supposed to be learning from the mistakes of the past? -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
22. Re: New keyword added: continue
- Posted by Jeremy Cowgar <jeremy at cow?ar?com> May 11, 2008
- 784 views
- Last edited May 12, 2008
Derek Parnell wrote: > > But aren't we supposed to be learning from the mistakes of the past? > Hm. #1, I'm not entirely sure continue is a mistake. #2, there is nothing inherently evil about continue and tradition should carry quite a bit of weight in this area. If there was a major flaw, then we should learn but I'm not seeing a huge flaw. Again, please understand, I'm just playing the "devils advocate" trying to promote a healthy debate about it. That's how we will do a service to Euphoria, however, I *think* I am on the side of continue, but am waffling. However, the debate is far from over. I do think it's possible, that if we choose next, in the future we may look back on things and treat the decision of going to next as one of those things in the past we should learn a lesson from. Another thought that just came to my mind is there is great talk about being able to embed Euphoria into C and use Euphoria as a scripting language to extend existing C applications. If that happens, we will have more and more C programmers using Euphoria. Thus, that should bear a *little* (probably not a lot) weight in the decision of next/continue. Probably what we should do is collect pro's and con's, then create a summary of those on the wiki. Then reference the wiki and make a decision. So, any pro's and con's out there people want to have recorded that has not already been said? For continue, pros: 1. standard cons: 1. what does it mean? For next, pros: 1. meaning is clearer (next iteration) cons: 1. use is common in variable names or function names (i.e. any iterator, list, database connection, etc...) 2. not standard or traditional 3. conflicts with other common languages such as basic, VBA, ASP (yes, all Microsoft). -- Jeremy Cowgar http://jeremy.cowgar.com
23. Re: New keyword added: continue
- Posted by Kat <KAT12 at coosahs.n??> May 12, 2008
- 785 views
Derek Parnell wrote: > > Jeremy Cowgar wrote: > I suppose a more detailed study could be done via the TIBOE > > language index, but here are my findings: > > > > python = continue > > c = continue > > vb = continue > > d = continue > > basic = continue > > pascal = continue > > php = continue > > perl = next > > javascript = continue > > tcl = continue > > But aren't we supposed to be learning from the mistakes of the past? Yeas, all these extra words, meaning different things to different people, when "goto" is so clear and direct and simple. <sigh> Kat
24. Re: New keyword added: continue
- Posted by "Euler German" <eulerg at gmail.com> May 12, 2008
- 806 views
> On 11 May 2008 at 3:29, Derek Parnell wrote (maybe snipped): > Jeremy Cowgar wrote: > > > > Continue has been added to Euphoria SVN. Continue is Exit's sibling. > > > But I seriously hope it is going to be renamed to something a lot more > natural such as 'next'. > Why not "loop"? -- _ _| euler f german _| sete lagoas, mg, brazil _| efgerman{AT}gmail{DOT}com
25. Re: New keyword added: continue
- Posted by CChris <christian.cuvier at agricultur?.?ouv.fr> May 12, 2008
- 817 views
Add to the pros for next that it is shorter to type. Symmetrically, a con for continue is its being longer. CChris
26. Re: New keyword added: continue
- Posted by CChris <christian.cuvier at agricultur?.go?v.fr> May 12, 2008
- 797 views
Euler German wrote: > > > On 11 May 2008 at 3:29, Derek Parnell wrote (maybe snipped): > > > Jeremy Cowgar wrote: > > > > > > Continue has been added to Euphoria SVN. Continue is Exit's sibling. > > > > > > But I seriously hope it is going to be renamed to something a lot more > > natural such as 'next'. > > > > Why not "loop"? > > -- > _ > _| euler f german > _| sete lagoas, mg, brazil > _| efgerman{AT}gmail{DOT}com > Good catch. However, if we are to add a loop construct that tests at the end (a do ... while or repeat ... until loop), then, as we couldn't use repeat nor do, loop would be the natural choice. This is why I keep thinking "next" is a little better, but not by much. CChris
27. Re: New keyword added: continue
- Posted by Kat <KAT12 at coo?a?s.net> May 12, 2008
- 783 views
Why? Here's how you use one keyword instead of six:
--repeat until :repeat x -= 1 if x > 12 then goto repeat end if -- case atom fred, a, d fred = 45 a = 1 d = 44 goto x puts(1,x&" is not covered") goto caseend :1 puts(1,"it's 1!") goto caseend :34 puts(1,"wow, 34!") :"Sam" puts(1,"you got Sam!" goto caseend :a+d puts(1,"Yep, fred is 45!") goto caseend :caseend -- continue, retry, restart, and next :restart for loop = 1 to 12 do :retry -- code if test = failed then goto retry end if if thistest = failed then goto restart end if if bored = true then goto next end if if done then goto demoend end if -- code :next end for :demoend
You know exactly where each "goto" lands, each :target can be in your own native language, and OOEU prooves it can be done. It's ONE word. It's so SIMPLE. Kat
28. Re: New keyword added: continue
- Posted by ChrisBurch2 <crylex at freeu?.co.u?> May 12, 2008
- 786 views
Kat wrote: <snip> > You know exactly where each "goto" lands, each :target can be in your own > native > language, and OOEU prooves it can be done. It's ONE word. It's so SIMPLE. > > Kat Yes, but then I wouldn't have so much fun reading the reams of stuff generated over one word Chris
29. Re: New keyword added: continue
- Posted by Jeremy Cowgar <jeremy at cowgar.c?m> May 12, 2008
- 773 views
Kat wrote: > > Why? > Here's how you use one keyword instead of six: > > }}} <eucode> > > --repeat until > :repeat > x -= 1 > if x > 12 then goto repeat end if > > > -- case > atom fred, a, d > fred = 45 > a = 1 > d = 44 > > goto x > puts(1,x&" is not covered") goto caseend > :1 puts(1,"it's 1!") goto caseend > :34 puts(1,"wow, 34!") > :"Sam" puts(1,"you got Sam!" goto caseend > :a+d puts(1,"Yep, fred is 45!") goto caseend > :caseend > > -- continue, retry, restart, and next > :restart > for loop = 1 to 12 do > :retry > -- code > if test = failed then goto retry end if > if thistest = failed then goto restart end if > if bored = true then goto next end if > if done then goto demoend end if > -- code > :next > end for > :demoend > > </eucode> {{{ The above code is not entirely correct or as simple as it seems. Let's start with the case statement. I think a case statement would a much better choice. Why? What if you want two case statements, either nested or in the same function in different sections that answer both to the integer 1 ?
goto x :1 puts "One!\n" :2 puts "Two!\n" :caseend goto y :1 puts "One!\n" -- invalid already used :2 puts "Two!\n" -- invalid already used :caseend -- invalid already used
The for loop with next, retry, exit, restart, etc... First to program might be a bit of a chore because on the keywords "end for" the stack is cleaned up, temp variables cleared, etc... A direct goto out of the for loop w/o hitting an end for would leave the internals dirty. It should be able to detect that it went out of the loop and then clean up, but it's not as easy as pushing adding a label and going to a label in the backend as you would think. #2 with the for loop, it suffers the same fate as the case statement. Sure, on the first for loop you can use :retry, :end, :next, :restart, but then on subsequent for loops in the same context (in top level or inside a function), you would have to get creative in your naming... :end2, :next2, :restart2, etc... Then have 1 for loop that is nested in another, and then later in the function you add a new for loop. Then, as time goes on, you add a for loop at the beginning of the function. Now, your first for loop is named :end3, :restart3, and your second is just :end, :restart, etc... and an inner is :restart3, etc... It begins to get pretty confusing. So, while I personally think a goto statement is a good thing, I do not think it is a replacement for exit, continue and a case statement. -- Jeremy Cowgar http://jeremy.cowgar.com
30. Re: New keyword added: continue
- Posted by Jason Gade <jaygade at ya?oo.co?> May 12, 2008
- 805 views
For me, the word "continue" (or "next" or "exit" or whatever) makes the context far more clear when trying to understand the code. I've seen very few uses of goto that can't easily be expressed in a better way in a high-level language. -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.
31. Re: New keyword added: continue
- Posted by Kat <KAT12 at coosahs??et> May 12, 2008
- 808 views
Jeremy Cowgar wrote: > > Kat wrote: > > > > Why? > > Here's how you use one keyword instead of six: > > > > }}} <eucode> > > > > --repeat until > > :repeat > > x -= 1 > > if x > 12 then goto repeat end if > > > > > > -- case > > atom fred, a, d > > fred = 45 > > a = 1 > > d = 44 > > > > goto x > > puts(1,x&" is not covered") goto caseend > > :1 puts(1,"it's 1!") goto caseend > > :34 puts(1,"wow, 34!") > > :"Sam" puts(1,"you got Sam!" goto caseend > > :a+d puts(1,"Yep, fred is 45!") goto caseend > > :caseend > > > > -- continue, retry, restart, and next > > :restart > > for loop = 1 to 12 do > > :retry > > -- code > > if test = failed then goto retry end if > > if thistest = failed then goto restart end if > > if bored = true then goto next end if > > if done then goto demoend end if > > -- code > > :next > > end for > > :demoend > > > > </eucode> {{{ > > The above code is not entirely correct or as simple as it seems. Let's start > with the case statement. I think a case statement would a much better choice. > Why? What if you want two case statements, either nested or in the same > function > in different sections that answer both to the integer 1 ? > > }}} <eucode> > goto x > :1 puts "One!\n" > :2 puts "Two!\n" > :caseend > > goto y > :1 puts "One!\n" -- invalid already used > :2 puts "Two!\n" -- invalid already used > :caseend -- invalid already used > </eucode> {{{ I wasn't arguing against the case, i have been in favor of case before, and would use it if it existed. I mentioned that in #Euphoria even. Before i left the channel. If you do make a case for case in Eu, please look at how nicely Matt did the case/goto targets in OOEU. I suspect even those could be made more versatile. > The for loop with next, retry, exit, restart, etc... First to program might > be a bit of a chore because on the keywords "end for" the stack is cleaned up, > temp variables cleared, etc... A direct goto out of the for loop w/o hitting > an end for would leave the internals dirty. It should be able to detect that > it went out of the loop and then clean up, but it's not as easy as pushing > adding > a label and going to a label in the backend as you would think. Depends on how it's done. In some languages, the loop is nearly a second program, and leaving it's code space clears everything that's not in the proc/funct it's nested in. Such "nearly a 2nd program" also justified nesting functions and procedures inside other functions of procedures, making the internal proc/func local to the proc/func it was nested in. I don't know how Eu does it. > #2 with the for loop, it suffers the same fate as the case statement. Sure, > on the first for loop you can use :retry, :end, :next, :restart, but then on > subsequent for loops in the same context (in top level or inside a function), > you would have to get creative in your naming... :end2, :next2, :restart2, > etc... > Then have 1 for loop that is nested in another, and then later in the function > you add a new for loop. Then, as time goes on, you add a for loop at the > beginning > of the function. Now, your first for loop is named :end3, :restart3, and your > second is just :end, :restart, etc... and an inner is :restart3, etc... It > begins > to get pretty confusing. OMGess, do you really program like that? > So, while I personally think a goto statement is a good thing, I do not think > it is a replacement for exit, continue and a case statement. I nominate it again for exit, continue, restart, next, retry (not the error handling retry), or any other keyword where the purpose is to get around intervening code. In your example of nested loops, i have no clue where an exit would goto, and in most cases i bet it would not goto where i wanted. There's been numerous posts showing an exit not traveling far enough, leading to more flag tests to see if it's necessary to exit some more. One goto would have been enough, and quite clear, mentioning a descriptive target at both ends of the jump, and easy to find with text search in an editor. While i am at this example of nested loops, that's about the only reason i use goto, the others being to simulate case i don't have, hop some debug code, or get right to the end of a procedure (tis easy to exit a function, you can return from anywhere inside it)(altho i have often put cleanup code at the bottoms of proc/func and goto that code before leaving). Case is a clear goto, but without a scope limit at the bottom (</case> ?), your objection to using goto for case is almost correct. I think Matt considered a goto switch that prohibited reverse :target lookups, which would have partly solved your case objection. In any case, i believe it looked for the next :target down the code that was in scope, and on not finding one, then looked down from the beginning of the scope. I can still see gotchas, and am not against case to solve those. Kat
32. Re: New keyword added: continue
- Posted by Jeremy Cowgar <jeremy at ?owgar.c?m> May 12, 2008
- 785 views
Kat wrote: > > Depends on how it's done. In some languages, the loop is nearly a second > program, > and leaving it's code space clears everything that's not in the proc/funct > it's > nested in. Such "nearly a 2nd program" also justified nesting functions and > procedures inside other functions of procedures, making the internal proc/func > local to the proc/func it was nested in. I don't know how Eu does it. Yes, that's how it would be done, but in your example, there were things like endcase, endfor, etc... those are outside the loop. > > #2 with the for loop, it suffers the same fate as the case statement. Sure, > > on the first for loop you can use :retry, :end, :next, :restart, but then on > > subsequent for loops in the same context (in top level or inside a > > function), > > you would have to get creative in your naming... :end2, :next2, :restart2, > > etc... > > Then have 1 for loop that is nested in another, and then later in the > > function > > you add a new for loop. Then, as time goes on, you add a for loop at the > > beginning > > of the function. Now, your first for loop is named :end3, :restart3, and > > your > > second is just :end, :restart, etc... and an inner is :restart3, etc... It > > begins > > to get pretty confusing. > > OMGess, do you really program like that? > Do I have nested loops? I sure do. Do I sometimes go back and add a new loop to a function? I sure do. That's all the above was showing, but using your example of goto. Because it is such a mess, I was using it as a case against using a goto as you described. > > So, while I personally think a goto statement is a good thing, I do not > > think > > it is a replacement for exit, continue and a case statement. > > I nominate it again for exit, continue, restart, next, retry (not the error > handling retry), or any other keyword where the purpose is to get around > intervening > code. In your example of nested loops, i have no clue where an exit would > goto, > and in most cases i bet it would not goto where i wanted. There's been > numerous > posts showing an exit not traveling far enough, leading to more flag tests to > see if it's necessary to exit some more. One goto would have been enough, and > quite clear, mentioning a descriptive target at both ends of the jump, and > easy > to find with text search in an editor. An exit and continue could be modified pretty easy to do something like this:
for a = 1 to 5 do for b = 1 to 5 do for c = 1 to 5 do exit 2 -- exit 2 loops end for -- never reached puts(1, "Hello!\n") end for printf(1, "%d,", {a}) end for
Output of above is 1,2,3,4,5. The same could be done for continue. Before enabling goto to exit a loop, I would nominate the above construct. If a parameter was not given to exit or continue, it would simply exit 1 loop as normal. However, can we please move goto discussions to the new Goto? thread? Thanks. -- Jeremy Cowgar http://jeremy.cowgar.com
33. Re: New keyword added: continue
- Posted by CChris <christian.cuvier at agri?ulture.gouv.?r> May 12, 2008
- 807 views
- Last edited May 13, 2008
Kat wrote: > > > Why? > Here's how you use one keyword instead of six: > > }}} <eucode> > > --repeat until > :repeat > x -= 1 > if x > 12 then goto repeat end if > > > -- case > atom fred, a, d > fred = 45 > a = 1 > d = 44 > > goto x > puts(1,x&" is not covered") goto caseend > :1 puts(1,"it's 1!") goto caseend > :34 puts(1,"wow, 34!") > :"Sam" puts(1,"you got Sam!" goto caseend > :a+d puts(1,"Yep, fred is 45!") goto caseend > :caseend > > -- continue, retry, restart, and next > :restart > for loop = 1 to 12 do > :retry > -- code > if test = failed then goto retry end if > if thistest = failed then goto restart end if > if bored = true then goto next end if > if done then goto demoend end if > -- code > :next > end for > :demoend > > </eucode> {{{ > > You know exactly where each "goto" lands, each :target can be in your own > native > language, and OOEU prooves it can be done. It's ONE word. It's so SIMPLE. > > Kat You know where each goto lands, granted. But you don't know where you land from, as any label can be targeted from scarrered places. And that's why soem people are downright against it, and why I don't like using it. I had found out this: when you start writing code, and it is naive an simple, then goto are as easy to read as anything, and perhaps easier. Then, the code becomes more complex because there's a handful of special cases, and you now have to guarantee that it hardly matters, when you reach a label, what was the program state just before. It simply doesn't work. You can always set up flags, but then tell me that you never make mistakes updating them... I tried to implement goto in Æ. It works. But I added a twist: all goto statements must have a label, and there is another builtin, come_from(), which retrieves the last goto label you jumped from. Otherwise, I'd say: goto is nice, it's one keyword instead of 6, is not hard to type, but it makes maintaining code so much trickier. Pascal compilers didn't recognise goto, unless a specific option was turned on. Perhaps that would be the way to go: if you want goto, have it, but know that you are doing things the hard way. I still think some equivalent of come_from() is necessary to make goto usable in the Euphoria framework - you know, that world where raw pointers are considered unsafe -. CChris
34. Re: New keyword added: continue
- Posted by Jeremy Cowgar <jeremy at co?gar.?om> May 12, 2008
- 796 views
- Last edited May 13, 2008
CChris wrote: > > Pascal compilers didn't recognise goto, unless a specific option was turned > on. Perhaps that would be the way to go: if you want goto, have it, but know > that you are doing things the hard way. I still think some equivalent of > come_from() > is necessary to make goto usable in the Euphoria framework - you know, that > world where raw pointers are considered unsafe -. > I do not think this is a viable option as it would introduce code incompatabilities. Say, John likes goto's and writes a library but Joe does not like goto's. He downloads John's library and cannot use it because he will not enable gotos. Then, John will start declaring "goto must be enabled", etc... I think that one Euphoria programmer should be able to run another Euphoria application in the same version w/o incompatibilities. Along the lines of one of the requirements for the standard library... no external dependencies. This is so if Jane writes a program, she knows it will run on Jim's install of Euphoria. -- Jeremy Cowgar http://jeremy.cowgar.com
35. Re: New keyword added: continue
- Posted by Kat <KAT12 at coosahs.n?t> May 12, 2008
- 766 views
- Last edited May 13, 2008
Jeremy Cowgar wrote: > > CChris wrote: > > > > Pascal compilers didn't recognise goto, unless a specific option was turned > > on. Perhaps that would be the way to go: if you want goto, have it, but know > > that you are doing things the hard way. I still think some equivalent of > > come_from() > > is necessary to make goto usable in the Euphoria framework - you know, that > > world where raw pointers are considered unsafe -. > > > > I do not think this is a viable option as it would introduce code > incompatabilities. > Say, John likes goto's and writes a library but Joe does not like goto's. He > downloads John's library and cannot use it because he will not enable gotos. > Then, John will start declaring "goto must be enabled", etc... I think that > one Euphoria programmer should be able to run another Euphoria application in > the same version w/o incompatibilities. > > Along the lines of one of the requirements for the standard library... no > external > dependencies. This is so if Jane writes a program, she knows it will run on > Jim's install of Euphoria. Ok, don't turn off goto, and then Jane's code can run on Jim's computer. Kat
36. Re: New keyword added: continue
- Posted by marky1124 <mark_young at hotmai??com> May 13, 2008
- 786 views
My vote is for continue, not that it matters hugely. My reasons are that of the 10 languages listed about 9 of them use continue and I think consistency is important. Especially given the earlier argument that next in VBA means "end for" and hence leans towards more confusion. I speak as a developer who currently is primarily using Euphoria and perl, and perl was the only one of the 10 that uses next. However there are so many significant syntax differences between perl and Euphoria that consistency of the use of next pales in comparison. Perl requires a semi-colon at the end of every line. Perl uses braces for code blocks. etc. Anyway - hoorah for this new addition to Euphoria, whatever it ends up being called. Thank you. Cheers, Mark
37. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at ?aho?.com> May 27, 2008
- 815 views
Derek Parnell wrote: > > Jeremy Cowgar wrote: > I suppose a more detailed study could be done via the TIBOE > > language index, but here are my findings: > > > > python = continue > > c = continue > > vb = continue > > d = continue > > basic = continue > > pascal = continue > > php = continue > > perl = next > > javascript = continue > > tcl = continue > > But aren't we supposed to be learning from the mistakes of the past? > > -- > Derek Parnell > Melbourne, Australia > Skype name: derek.j.parnell Next def: Immediately following in time, ORDER, importance, etc. Cont def: To go on after suspension or interruption. Cont def: To go on with or persist in. I think you can make a case for either word, but because next implies an iteration I would prefer it. The truth is, I don't have a dog in this hunt, because it doesn't really provide new capability. loop if true next code skipped here. end loop or loop if false code skipped here. end if end loop The results are the same. I also prefer type 4 letters to 8. NEXT is preferable to CONT for you wiseguys that say both can be 4.
38. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at ya?oo.c?m> May 27, 2008
- 819 views
skip def: To jump lightly over. ...for those leaning whimsically (also 4 letters.)
39. Re: New keyword added: continue
- Posted by Jason Gade <jaygade at yahoo?co?> May 27, 2008
- 798 views
I don't usually like to save typing at the expense of clarity. C is pretty good at that, though... -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.
40. Re: New keyword added: continue
- Posted by Kat <KAT12 at coosahs.?e?> May 27, 2008
- 795 views
ken mortenson wrote: > > skip def: To jump lightly over. > > ...for those leaning whimsically (also 4 letters.) goto def: to continue or next or resume or retry or restart or exit or entry at another location .. also 4 letters. Kat
41. Re: New keyword added: continue
- Posted by c.k.lester <euphoric at ?klester.?om> May 27, 2008
- 798 views
Kat wrote: > ken mortenson wrote: > > skip def: To jump lightly over. > > ...for those leaning whimsically (also 4 letters.) > goto def: to continue or next or resume or retry or restart or exit or entry > at another location How do you get next/continue or restart with goto (using only 4 letters?)? I don't see a way to iterate using just goto. You'd have to do all sorts of other stuff, methinks, to emulate these easier-to-use terms.
42. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at yahoo??om> May 27, 2008
- 818 views
- Last edited May 28, 2008
Kat, Regarding GOTO, do not be drawn to the dark side. Are you seduced by it's power?!!! [insert Vader's heavy breathing here. I almost said Darth, I'm such a nerd!] This is another one of those humble programmer issues for me. Is the concept of structured programming a good thing? Even though sometimes it means fitting things to a structure rather than what may seem to be a more direct way of coding? One of the tenants of structured programming is that a block of code should have exactly one entrance and one exit (there is some confusion on this point that I will illustrate in a moment.) Why? Because it reduces the stress on the programmer. One entrance means, no guessing about where to start in the code. Once exit means you know where the code continues. Some may say, "but we're only talking about once we're inside the block of code!" You can make a case for that, but it's not a strong case. This also goes for exit [how many levels?] which is a semi-structured kind of goto. GOTO is actually two words of course and it's the TO part that is unstructured and causes the problems. Would you argue for GO (only 2 letters!) The confusion about one exit is that some programmers interpret this to mean that a structured block of code must exit the block only at the very last instruction. This is incorrect. In my code I ofter test for exceptions right at the beginning of the block and return right there. Sprinkling returns throughout your code doesn't violate the one exit rule either. Why? Because no matter how many returns you have you always return to the line following the original call. That is the one and only exit point. GOTO could, and does by those italian pasta lovers, get used to violate the only one exit rule because you can use it so that the code following the call is not executed. So I ask again, is structured programming a good thing? It's not a question that can be given a snap answer. I thought about it for years before reaching the conclusion that whatever it's faults, the answer is yes in ALL cases. Again, it's about humility. Supermen do not make good programmers (I often find myself cleaning up after them... so I have a strong perspective on this.) GOTO is powerful. It's the biggest ship in the galaxy. If you find you can't live without it's power, machine language is the place to be. It's loaded with goto's. I hope I've loosened your grip on goto a little without causing offense. (Yes, Derek I see my tone... If you could only see my heart. Not to imply that you don't and I'm not picking on anyone and, and, ...) I am but a simple and humble servant to whatever is true.
43. Re: New keyword added: continue
- Posted by Kat <KAT12 at coos?hs.?et> May 27, 2008
- 799 views
- Last edited May 28, 2008
c.k.lester wrote: > > Kat wrote: > > ken mortenson wrote: > > > skip def: To jump lightly over. > > > ...for those leaning whimsically (also 4 letters.) > > goto def: to continue or next or resume or retry or restart or exit or entry > > at another location > > How do you get next/continue or restart with goto (using only 4 letters?)? I > don't see a way to iterate using just goto. You'd have to do all sorts of > other stuff, methinks, to emulate these easier-to-use terms. I have already given examples. Early mirc had no loop constructs, and for years had only if-then construct. All other loops, including case, were built with goto. I am NOT recommending this as good coding style in any language that has the appropriate loop devices..... set -u0 %loop 0 -- going to use "loop" :startofloop -- code -- note i can modify the loop var inc -u0 %loop if ( %loop != %y ) { goto startofloop } -- %loop is still valid here if i want to use it Bare-bones basic stuff. But getting good loops (if-then, while-do, repeat-until<cough>) in modern languages, and then adding 4 or more keywords to jump around *inside* a loop smells like nuts to me.
:restart for loop = 1 to 12 do :retry -- code if blah then goto restart end if if blorg then goto retry end if if not x then goto exit end if if CK then goto next end if if worstcase then goto cleanup&return end if -- code :next end for :exit
Not only is it crystal clear (flat panel, no cuts, colors, or occlusions) that it's going to change program flow, but the places it is going to are plainly and unambiguously labeled in the language of your choice, and it's pretty darned well self explainitory. I don't want to be programming along, then stop and wonder if the language will allow me to do something, and if so, which keyword do i want, and just where will it land? And then will it keep landing there if i later add some code to debug something else? Or what if i remove some debug code? etc etc etc. Kat
44. Re: New keyword added: continue
- Posted by c.k.lester <euphoric at c?l?ster.com> May 27, 2008
- 774 views
- Last edited May 28, 2008
Kat wrote: > c.k.lester wrote: > > How do you get next/continue or restart with goto (using only 4 letters?)? I > > don't see a way to iterate using just goto. You'd have to do all sorts of > > other stuff, methinks, to emulate these easier-to-use terms. > > :restart > for loop = 1 to 12 do > :retry > -- code > if blah then goto restart end if > if blorg then goto retry end if > if not x then goto exit end if > if CK then goto next end if > if worstcase then goto cleanup&return end if > -- code > :next > end for > :exit Ah, I see how next/continue would work there, and retry. But restart- jumping OUT of a loop and then going back into it- looks like it might cause interpreter pains (memory leaks, etc.). And jumping out of the loop? Dunno. Maybe an interpreter modifier can speak to that.
45. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at yahoo.c??> May 27, 2008
- 786 views
- Last edited May 28, 2008
Kat wrote: > Bare-bones basic stuff. But getting good loops (if-then, while-do, > repeat-until<cough>) > in modern languages, and then adding 4 or more keywords to jump around > *inside* > a loop smells like nuts to me. A programmer after my own heart (soon you will achieve oneness...) I'm even weirder in my thinking (you guys already figured that one out didn't ya? But here's some confirmation...) All code written anywhere by anyone (quantum computing may make this statement untrue) have only three structures (sequence, branch, loop) I'd like to get rid of ALL the various flavors of loops (while, for, for each, etc.) and replace it with the pseudo code I've always used. Loop ... End Loop You do all your initialization before the loop. The loop creates Index which starts with a value of zero and increments once each iteration. The scope of Index is limited to the last declaration so for nested loops... Loop x = Index Loop y = Index array(x,y)=whatever. if (y>9) exit End Loop if (x>12) exit End Loop ...but I'm a dreamer. Am I not the only one? Note that all loops are infinite and require an explicit exit. Programmers with bad habits will be spanked enough to learn good habits in very short order.
46. Re: New keyword added: continue
- Posted by Matt Lewis <matthewwalkerlewis at gma?l.?om> May 27, 2008
- 767 views
- Last edited May 28, 2008
c.k.lester wrote: > > Ah, I see how next/continue would work there, and retry. But restart- > jumping OUT of a loop and then going back into it- looks like it might > cause interpreter pains (memory leaks, etc.). And jumping out of the loop? > Dunno. Maybe an interpreter modifier can speak to that. You're probably afraid of 'exit', too. :P Seriously, exit is just a goto to the end of the loop. It doesn't do any clean up or anything. There isn't any needed. Matt
47. Re: New keyword added: continue
- Posted by c.k.lester <euphoric at ckl?ster.?om> May 27, 2008
- 793 views
- Last edited May 28, 2008
ken mortenson wrote: > > Loop > x = Index > Loop > y = Index > array(x,y)=whatever. > if (y>9) exit > End Loop > if (x>12) exit > End Loop I'm... strangely... attracted to it. 8|
48. Re: New keyword added: continue
- Posted by Jeremy Cowgar <jeremy at cowga?.c?m> May 27, 2008
- 797 views
- Last edited May 28, 2008
c.k.lester wrote: > > ken mortenson wrote: > > > > Loop > > x = Index > > Loop > > y = Index > > array(x,y)=whatever. > > if (y>9) exit > > End Loop > > if (x>12) exit > > End Loop > > I'm... strangely... attracted to it. 8| I was thinking we have: loop do until ... Why not loop do ... again or repeat However, I'd use a while loop or until loop for examples such as if (x>12) exit. Also you are assigning y = Index, x = Index, therefore, those are probably being incremented somewhere that you are not showing making the above loop probably more suited to a for loop? -- Jeremy Cowgar http://jeremy.cowgar.com
49. Re: New keyword added: continue
- Posted by c.k.lester <euphoric at ckl??ter.com> May 27, 2008
- 803 views
- Last edited May 28, 2008
Matt Lewis wrote: > c.k.lester wrote: > > Ah, I see how next/continue would work there, and retry. But restart- > > jumping OUT of a loop and then going back into it- looks like it might > > cause interpreter pains (memory leaks, etc.). And jumping out of the loop? > > Dunno. Maybe an interpreter modifier can speak to that. > You're probably afraid of 'exit', too. :P > Seriously, exit is just a goto to the end of the loop. It doesn't do any > clean up or anything. There isn't any needed. You'd know. I'm curious that there's no clean up necessary. It looks like there'd be a dangling variable. Eeeewwwwwww!!! :D (I admit I've never used exit. I'm not a sloppy enough coder. HAHAHAHA. Just kidding. I might've used it once. Well, I just checked bbcmf-system. Out of about 8.6KLOC, exit appears 0 times. So, I probably never have used it.)
50. Re: New keyword added: continue
- Posted by Jeremy Cowgar <jeremy at c?wgar?com> May 27, 2008
- 800 views
- Last edited May 28, 2008
Jeremy Cowgar wrote: > > > Why not > > loop do > ... > again or repeat > I wanted to prefix but forgot... There are common things we do in loops and common ways of exiting a loop, thus we have for, while and until loops. If we get too many loops, we just overly complicate things. If we have too little loops, we overly complicate things as well. I do think the programming world has settled on the three main loops that satisfy the vast majority of looping needs and they are what we have, while, for and until. We probably do not need any more. For instance, I learned yesterday or today, that while 1 do ... end while is optimized as: begining: ... do something goto begining No exit checks or anything, so one could very well successfully argue we already have the loop proposed by ken: Loop End Loop -- Jeremy Cowgar http://jeremy.cowgar.com
51. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at y?hoo?com> May 27, 2008
- 775 views
- Last edited May 28, 2008
c.k.lester wrote: > > ken mortenson wrote: > > > > Loop > > x = Index > > Loop > > y = Index > > array(x,y)=whatever. > > if (y>9) exit > > End Loop > > if (x>12) exit > > End Loop > > I'm... strangely... attracted to it. 8| Medic! Medic! Get the tranquilizers, we've got another one!
52. Re: New keyword added: continue
- Posted by Matt Lewis <matthewwalkerlewis at gmail.??m> May 27, 2008
- 793 views
- Last edited May 28, 2008
c.k.lester wrote: > > Matt Lewis wrote: > > c.k.lester wrote: > > > Ah, I see how next/continue would work there, and retry. But restart- > > > jumping OUT of a loop and then going back into it- looks like it might > > > cause interpreter pains (memory leaks, etc.). And jumping out of the loop? > > > Dunno. Maybe an interpreter modifier can speak to that. > > You're probably afraid of 'exit', too. :P > > Seriously, exit is just a goto to the end of the loop. It doesn't do any > > clean up or anything. There isn't any needed. > > You'd know. > > I'm curious that there's no clean up necessary. It looks like there'd be a > dangling variable. Eeeewwwwwww!!! :D Basically, each loop variable gets a slot in the symbol table. If it's not top level code, then it 'goes away' just like all the other private variables. > (I admit I've never used exit. I'm not a sloppy enough coder. HAHAHAHA. Just > kidding. I might've used it once. Well, I just checked bbcmf-system. Out of > about 8.6KLOC, exit appears 0 times. So, I probably never have used i >grep -c exit eusql.e 21 Maybe it's not in bbcmf, but you depend upon it. :) Matt
53. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at yahoo??om> May 27, 2008
- 774 views
- Last edited May 28, 2008
Jeremy Cowgar wrote: > I was thinking we have: > > loop do > > until ... > > Why not > > loop do > ... > again or repeat > > However, I'd use a while loop or until loop for examples such as if (x>12) > exit. The only difference between a do while or do until is where the test is made. In my construct there is no difference, you just put it where you want (or at multiple points if that's your style or need. do, again and repeat are all extraneous. In my view all structures would consistantly end with end (followed by the name of the structure: if, loop, procedure, etc.) Also you are assigning y = Index, x = Index, therefore, those are probably > being incremented somewhere that you are not showing making the above loop > probably > more suited to a for loop? Exactly, they are incremented under the covers for each iteration of the loop starting at zero. This doesn't mean the programmer is limited in any way. A for loop simply has it's initialize as part of it's syntax. Initialize before the loop in all cases creates a simple habit. It may even teach those that initialize IN loops that, that is not a good idea. For loops also have an implicit increment by which I'm just suggesting is better being explicit. The real advantage is only one loop structure wich reduces stress on the humble programmer. Need a loop? Use Loop.
54. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at y?hoo.co?> May 27, 2008
- 781 views
- Last edited May 28, 2008
Jeremy Cowgar wrote: > while 1 do > ... > end while > > is optimized as: > > begining: > > ... do something > > goto begining > > No exit checks or anything, so one could very well successfully argue we > already > have the loop proposed by ken: Yes, we've always had the loop. I'm just proposing we go all the way and just use the syntax... > Loop > > End Loop I guaranty the soon nobody would miss, while, for, for each, repeat until, do while, do until, rinse, lather, soap... oops! Got ahead of myself on those last few.
55. Re: New keyword added: continue
- Posted by c.k.lester <euphoric at ckles?er.com> May 27, 2008
- 782 views
- Last edited May 28, 2008
Matt Lewis wrote: > c.k.lester wrote: > > (I admit I've never used exit. I'm not a sloppy enough coder. HAHAHAHA. Just > > kidding. I might've used it once. Well, I just checked bbcmf-system. Out of > > about 8.6KLOC, exit appears 0 times. So, I probably never have used i > >grep -c exit eusql.e > 21 > Maybe it's not in bbcmf, but you depend upon it. :) heheh... Yeah, I saw some in Tommy Carlier's kanarie, too, which is a significant part of BBCMF. So, I guess I've gotta cut off EuSQL and kanarie... LOL! RIGHT!!!11!!1!!111!
56. Re: New keyword added: continue
- Posted by Jeremy Cowgar <jeremy at cow?ar.?om> May 27, 2008
- 807 views
- Last edited May 28, 2008
ken mortenson wrote: > > I guaranty the soon nobody would miss, while, for, for each, repeat until, > do while, do until, rinse, lather, soap... oops! Got ahead of myself on > those last few. > Ken, do you have any major open source apps out there that I can see the source for? Or any open source applications you have contributed a major patches/code to that I can see? I know a substantial amount of programmers, many of who can create code of such an utmost quality that it's down right amazing. Applications that have been in existence for > 15 years, still *easily* maintained today, well structured. These are people I trust. I also lead on applications in the 500KLOC range and I would not dare say get rid of for, while and until loops. That's just crazy. In fact, no one I have ever met or read about would make such a claim. It doesn't make sense. -- Jeremy Cowgar http://jeremy.cowgar.com
57. Re: New keyword added: continue
- Posted by Derek Parnell <ddparnell at bigpon?.?om> May 27, 2008
- 800 views
- Last edited May 28, 2008
Kat wrote: > }}} <eucode> > :restart > for loop = 1 to 12 do > :retry > -- code > if blah then goto restart end if > if blorg then goto retry end if > if not x then goto exit end if > if CK then goto next end if > if worstcase then goto cleanup&return end if > -- code > :next > end for > :exit > </eucode> {{{ Hi Kat, just a few of quick questions ... ** How, as a maintainer of the code above, can I be sure that process flow only gets to the "restart:" label from either the statement immediately preceding it or the 'goto' inside the loop? In other words, how can I be sure that there is not another 'goto restart' elsewhere in the code? ** If I have to place another looping construct within the same scope as the one above, what should I call the labels? ** Under what circumstanes might I have to rename the labels? -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
58. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at yahoo??om> May 27, 2008
- 796 views
- Last edited May 28, 2008
I wouldn't be adverse to an optional from/by Loop from 7 by -1.2 if (Index<-14.2) exit End Loop
59. Re: New keyword added: continue
- Posted by gshingles <gshingles at gmai?.c?m> May 27, 2008
- 796 views
- Last edited May 28, 2008
ken mortenson wrote: > > I guaranty the soon nobody would miss, while, for, for each, repeat until, > do while, do until, rinse, lather, soap... oops! Got ahead of myself on > those last few. Maybe I'm just lazy, but I really miss foreach in Euphoria, especially since it has native sequences. I suspect sequence operations make it fairly redundant though. If all the work is being done by the interpreter then I would rather write something that looks like English, so I like having while and for. It's more natural to think (in my view) "count to 10 and for each number do something with it" (for..end for) than to think "LOOP,ADD,DO,TEST,END" (loop..loop end) or "while I haven't found it get the next one and have a look". (while) I'm actually really starting to admire Python. You say what you mean and don't have to dress everything up again to carry on with your code. I often sit there thinking "Is that it?" when I've iterated over an array in three lines of code and don't have to type '}' or 'end for' or count brackets etc Anyway, whatever language Euphoria uses I'm sure we'll all get used to it. It's all the same as far as the CPU is concerned :) Gary
60. Re: New keyword added: continue
- Posted by c.k.lester <euphoric at ckl?ster.com> May 27, 2008
- 765 views
- Last edited May 28, 2008
Derek Parnell wrote: > > just a few of quick questions ... Thus, goto is destroyed in one fell swoop.
61. Re: New keyword added: continue
- Posted by Kat <KAT12 at coos?hs?net> May 27, 2008
- 772 views
- Last edited May 28, 2008
Derek Parnell wrote: > > Kat wrote: > > }}} <eucode> > > :restart > > for loop = 1 to 12 do > > :retry > > -- code > > if blah then goto restart end if > > if blorg then goto retry end if > > if not x then goto exit end if > > if CK then goto next end if > > if worstcase then goto cleanup&return end if > > -- code > > :next > > end for > > :exit > > </eucode> {{{ > > Hi Kat, > just a few of quick questions ... > > ** How, as a maintainer of the code above, can I be sure that process flow > only > gets to the "restart:" label from either the statement immediately preceding > it or the 'goto' inside the loop? In other words, how can I be sure that there > is not another 'goto restart' elsewhere in the code? You can't. You read the code to see if there is another "goto" that label. The same with "exit", "return", etc.. I have a fair amount of code that has "return" sprinkled around, and no one has ever complained about more than one place leaving the function. One way to restrict the "where from" is to localise all "goto" to procedure/function blocks, and not allow it in top level code. Exactly like in OOEU. > ** If I have to place another looping construct within the same scope as the > one above, what should I call the labels? Umm, how about "loop2" ? Or you mean the targets for more "goto" of the same umm, form? Pick a name. You have the freedom to restart the inner loop, the outer loop, the nested while loop in there which you added later, etc.. I tend to give my nested loop names some description, even if it's just "index1", so i could have a "goto restart_index1", which sorta reads easily, and i know just where it's going, and i can get there with the one "goto" keyword from any depth of nested loops. The target being present alerts me, as i am reading down the code, that i may be going back to that point from somewhere. > ** Under what circumstanes might I have to rename the labels? Never, i believe. If you add loops, or other code, you do not need to change anything, assuming your intent to goto the :target is the same. If you wish to add a target, choose another name. Like i said, i tend to use the loop name as part of the target, and/or/as well as the purpose, if i need any clairification, rather insuring unique target names. This way i can wrap or unwrap nested loops, and not have a problem, as well as skip blocks during debug. With goto scope restricted to proc/funct blocks, it makes some code even easier, such as "goto cleanup&return", which i know has the local scope of variables, is at the bottom of the block where code will fall thru to anyhow, and execute the "cleanup&return". With Eu the way it is now, i have hunks of code copy/pasted thruout which does the cleanup with local vars and returns, and those hunks are a nightmare to keep identical. Just as an aside, one other cure for that would be nested procedures, which could be called inside the nesting procedure, and the nested one have the scope of the nesting one's vars, i did this in Turbo Pascal a *lot*. I believe Matt scored 100 with the way he did goto in OOEU, and i reiterate my suggestion all of OOEU be merged into Eu v4. Kat
62. Re: New keyword added: continue
- Posted by Kat <KAT12 at coos?hs.n?t> May 27, 2008
- 793 views
- Last edited May 28, 2008
c.k.lester wrote: > > Derek Parnell wrote: > > > > just a few of quick questions ... > > Thus, goto is destroyed in one fell swoop. I don't see why. Kat
63. Re: New keyword added: continue
- Posted by c.k.lester <euphoric at cklester?co?> May 27, 2008
- 786 views
- Last edited May 28, 2008
Kat wrote: > c.k.lester wrote: > > Derek Parnell wrote: > > > just a few of quick questions ... > > Thus, goto is destroyed in one fell swoop. > I don't see why. Maintainability of code is of utmost importance. Using goto is dangerous! :)
64. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at yahoo.??m> May 27, 2008
- 774 views
- Last edited May 28, 2008
Jeremy Cowgar wrote: > I know a substantial amount of programmers, many of who can create code of > such > an utmost quality that it's down right amazing. Applications that have been > in existence for > 15 years, still *easily* maintained today, well structured. > These are people I trust. I worked for a guy like that in NYC.
65. Re: New keyword added: continue
- Posted by Kat <KAT12 at c?osahs?net> May 27, 2008
- 758 views
- Last edited May 28, 2008
c.k.lester wrote: > > Kat wrote: > > c.k.lester wrote: > > > Derek Parnell wrote: > > > > just a few of quick questions ... > > > Thus, goto is destroyed in one fell swoop. > > I don't see why. > > Maintainability of code is of utmost importance. Using goto is dangerous! :) Why are these two blocks so different that you call the 2nd one "dangerous" ?
for loop = 1 to x do -- code if x = blah then goto next end if -- code :next end for for loop = 1 to x do -- code if x = blah then next end if -- code end for
And ye who didn't know you were using code containing "exit", how were you "maintaining" that code? And how would you know how many places called "exit" to make the code flow change? Kat
66. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at y?hoo?com> May 27, 2008
- 785 views
- Last edited May 28, 2008
Jeremy Cowgar wrote: > Ken, do you have any major open source apps out there that I can see the > source > for? Or any open source applications you have contributed a major patches/code > to that I can see? While I believe in open source I've worked for proprietory outfits. Most of my experimentation (not drugs! languages!) was prior to the last ten years (in which I worked for just two companies... I left the first company, worked a year for the second, then went back to the first.) My contract with a little mom and pop outfit in Seattle (well, Silverdale) called Squarerigger (they write fleet maintainance software and I hired with them at the beginning of a DOS to windows period.) even required me to shred any code I wrote for them after leaving the company. The second companies I worked at was for a young man and I made mistakes in handling the project. We had outlined a six month project which I was totally on track in the 1st four month to finish. He called his company NextPOS although it's something else now that he merged with a partner. You should be able to find both on the web. Then he decided he wanted the project broken up into a front end and a back end. I should have told him, no and stuck with no. I should have told him we need to get what I was working on done in the next few month so we could be making money to justify my salary, then work on a second version. But I didn't do that. He was the boss, young as he was, so I pulled out every 'back end' feature from the code that was almost completed and it was the last time I worked on it (it's now sitting on one of his backup servers somewhere) During the next 8 months he had me change the backend design twice. He'd told his vendors about the product from the first and they were calling everyday to find out it's status. Finally one weekend his chief tech. asked me for my machines password to do some network maintenance and when I came in monday I was locked out of my machine and the tech. didn't come in that day. So I told the Sales VP (the only senior guy besides me in the office that day) that I was taking the rest of the day off. I was still steaming the next day, so I called in and said I was taking another personal day (this was after a year of 60+ hour weeks.) When I came in the next day, my friend and owner wasn't in, but had his secretary/office manager let me know the bad news. Three days later I left California and was back to work for Squarerigger in Seattle. That first weekend there I worked overnights all weekend to fix their code for a very important demo on monday with some city that I don't recall. It wasn't enough time to fix everything (I could only insure that it didn't actually blow up.) They made the sale. I do have bits and pieces here and there in one language or another, but nothing I'd be proud to show off. I was hoping to do that with my next Euphoria project. What I've learned has been by listening, reading, thinking and experiences. I'm a self taught computer bum. Wrote my first HP2000F timeshared basic program in 30 minutes after buying the language manual from the local community college. Went to a trade school, but my buddy and I had to teach the instructors about PMA on the Prime 750. Spent hundreds of dollars on manuals I never used after leaving the school. Doesn't seem right. Bought a commodore 64 (with disk drive and tape!) for $1300. It was serial number 000000006xx in the year they sold 8 million (and the price dropped to under $200.) Gave it away, but would kind of like to have it now. I once thought FORTH could be the 'one true language' but that hallucination ended (but I still look at things like REBOL.) Wrote my first big project in NYC. dBase II multiuser (we had 13 286 machines on 2 servers... in 1982? very cutting edge.) 10,000 lines of code and I could visualize every line and every character... I actually edited the code remotely and blind for a customer in Ohio. No way I could do that today. I can hardly remember my name these days. Even flew to Ohio and did some custom reports for them. Nursemaided a report all night. When I got back to NYC my boss was mad about me giving things away for free. I was young. Rewrote that report in BASCOM and it went from 16 hours to 30 minutes! Bought my first copy of MASM back then, since I've bought Delphi, PowerBasic, DarkBasic. I was going to say I never had to buy C, then I remembered I bought a copy of Lattice C, which had a great upgrade policy right until the moment they went out of business. My favorite CPU was the 6502 with it's 13 addressing modes. I wrote an assembler for it in basic. Although my first CPU was an RCA 1802 that ran at a few hundred kilohertz. I've found I like features in many languages (ever ask yourself how would I do this in assember when writing dBase code?) I was also an air traffic controller and that's a story for another day. Boy, did you open a can of worms! All you really need to know is that I'm 49 but round that up to 50. I'm cranky. A rare INTJ. But code? I don't got no stink'n code. You guys better get Euphoria up to speed so I can ditch all these other language and just have fun. Later I'll tell you my vision for the 'ONE TRUE LANGUAGE' which Euphoria is a very significant part of. Then I'll show you code... Did you see my PowerBASIC example... Please don't make me code in PB. I'll be good. I promise. Please... BTW, while I was away for a year they bloated a work order module from about 10,000 lines to over 20,000 (adding accounting features that I had argued years earlier during the design phase should have been foundational to the product.) Worked that over to less than 10,000 lines of cleaner, more functional and easier to maintain code. Yes, I know that less is more. It's probably got all it's bloat back now that I'm not watching over it anymore. I
67. Re: New keyword added: continue
- Posted by Derek Parnell <ddparnell at big?ond.?om> May 27, 2008
- 775 views
- Last edited May 28, 2008
Kat wrote: Thanks Kat. > Derek Parnell wrote: >> ... how can I be sure that there is not another 'goto restart' >> elsewhere in the code? > > You can't. You read the code to see if there is another "goto" that label. How likely would this requirement increase the cost of maintenance? > The same with "exit", "return", etc.. I have a fair amount > of code that has "return" sprinkled around, and no one has > ever complained about more than one place leaving > the function. I see this as a different issue. With 'goto' the question I raise deals with how ones arrives at the label and has nothing to do with the 'goto' statement itself, but with 'exit' and 'return', the process flow to arrive at that statement is clear and local. > One way to restrict the "where from" is to localise all "goto" > to procedure/function blocks, and not allow it in top level code. > Exactly like in OOEU. Does the number of statements in a routine affect this position? >> ** If I have to place another looping construct within the same >> scope as the one above, what should I call the labels? > > Umm, how about "loop2" ? Does the requirement that a 'goto' needs a (unique within the scope) label, reduce the amount of code that has to be read by maintainers? To me it seems that using the combination of 'label xyz' and 'goto xyz' contains a lot more redundant content than 'next' does. If such a loop containing labels, needs to be later nested inside another loop, what is the suggested naming convention, if any? e.g. We start with ... restart1: loop -- some code -- goto restart1 -- some more code --- restart2: loop -- some code --- goto restart2: -- some code -- goto restart1 -- some code end loop end loop But later this needs to be nested, such as ... restart3: loop -- some code --- restart1: loop -- some code -- goto restart1 -- some more code --- restart2: loop -- some code --- goto restart2: -- some code -- goto restart1 -- some code -- end loop end loop -- some code -- goto restart3 -- some code -- end loop Would it be better to keep the existing label names as above, or is it better to rename them to keep the implied nesting level obvious? >> ** Under what circumstanes might I have to rename the labels? > Never, i believe. See above. > Just as an aside, one other cure for that > would be nested procedures, which could be > called inside the nesting procedure, and the > nested one have the scope of the nesting one's > vars Yes, nested routines would be very very nice. I suspect that we will have this ability soon, but not for v4.0 -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
68. Re: New keyword added: continue
- Posted by Derek Parnell <ddparnell at bi?po?d.com> May 28, 2008
- 778 views
Kat wrote: > > c.k.lester wrote: > > Maintainability of code is of utmost importance. Using goto is dangerous! :) > > Why are these two blocks so different that you call the 2nd one "dangerous" > ? Because in the first one we could get this ...
procedure foo() --- many lines of code --- goto next --- many lines of code --- goto next --- many lines of code --- for loop = 1 to x do -- code if x = blah then goto next end if -- code :next end for --- many lines of code --- goto next --- many lines of code --- end procedure
But I can't do that in the second example, and thus the cost of maintenance is lower in the second example. The cost is affected by the probability of bugs, the amount of code to read, and the amount of coding to repair/enhance existing code. > And how would you know how many places called "exit" to make the > code flow change? The problem is not the 'goto' statement (ie. change of control flow), the problem is with the label and how to arrive there. The extra maintenance cost that 'goto' introduces into a program must be offset by the performance benefit derived from using it, IMHO. Demonstrate that in a specific piece of Euphoria code and I'll support the use of 'goto' in that piece of code. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
69. Re: New keyword added: continue
- Posted by c.k.lester <euphoric at c??ester.com> May 28, 2008
- 794 views
Kat wrote: > c.k.lester wrote: > > Maintainability of code is of utmost importance. Using goto is dangerous! :) > Why are these two blocks so different that you call the 2nd one "dangerous" > ? > for loop = 1 to x do > -- code > if x = blah then goto next end if > -- code > :next > end for > > for loop = 1 to x do > -- code > if x = blah then next end if > -- code > end for Because adding loops therein could be problematic. > And ye who didn't know you were using code containing "exit", > how were you "maintaining" that code? I'm not maintaining that code (they are in libraries I am including), so I don't care. :)
70. Re: New keyword added: continue
- Posted by Kat <KAT12 at co?sahs.?et> May 28, 2008
- 787 views
ken mortenson wrote: > <snip- a bunch of stuff, mentioned 6502 and flying> Several people here are avid 6502 people, and a few fly or have flown their own planes. And some of us are 50 yrs old or older. I still want to build a 6502 in ttl, i went so far as to do the pcb layouts over 10 years ago. Then the Dog Era began. Nevertheless, my ex-business ex-advisor who moved out of this state after considering what happened to me here (etc), is donating a gently used HP 1631D to the effort, which i pick up next month. I have a HP 1600A, but he says the 1631D, with external storage, is worth having. Still no ETA for a 6502 that executes internal instructions at any speed i can feed code into it, up to sub-ns speeds. Oh yea, and i did touch-n-go in a single engine (trike landing gear, high wing, 2 seater up front, i don't remember more about it), but didn't go for the pricey license. I did buy property with 1200ft of property line, but can't use it,, the neighbor's dogs got it in court, and they don't share. And without rounding, i am over 50. Kat
71. Re: New keyword added: continue
- Posted by Matt Lewis <matthewwalkerlewis at gm?il.co?> May 28, 2008
- 783 views
ken mortenson wrote: > > I wouldn't be adverse to an optional from/by > > Loop from 7 by -1.2 > if (Index<-14.2) exit > End Loop That's good to know. I think. Matt
72. Re: New keyword added: continue
- Posted by Kat <KAT12 at coo?ahs.?et> May 28, 2008
- 816 views
c.k.lester wrote: > > Kat wrote: > > c.k.lester wrote: > > > Maintainability of code is of utmost importance. Using goto is dangerous! > > > :) > > Why are these two blocks so different that you call the 2nd one "dangerous" > > ? > > for loop = 1 to x do > > -- code > > if x = blah then goto next end if > > -- code > > :next > > end for > > > > for loop = 1 to x do > > -- code > > if x = blah then next end if > > -- code > > end for > > Because adding loops therein could be problematic. I do not see how. And frankly, the contrivance i post next i don't understand either....
for loop1 = 1 to 12 do -- code goto next1 -- code for loop2 = 1 to 12 do -- code goto next2 -- code for loop3 = 1 to 12 do -- code goto next3 -- code for loop4 = 1 to 12 do -- code goto next4 -- code for loop5 = 1 to 12 do -- code goto next5 -- code for loop6 = 1 to 12 do -- code goto next6 -- code :next6 end for :next5 end for :next4 end for :next3 end for :next2 end for :next1 end for
No, i don't write like that, but i feel you wanted an extremely good example of stuff taken to bad extremes. But it does proove that you can word search in a text editor to find the target easily, and won't skip a "next" target, because the "goto" targets are plainly labeled above. > > And ye who didn't know you were using code containing "exit", > > how were you "maintaining" that code? > > I'm not maintaining that code (they are in libraries I am including), so > I don't care. :) Good, then you won't care if i use goto. ) Kat
73. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at yahoo??om> May 28, 2008
- 762 views
Kat wrote: > And without rounding, i am over 50. Now I understand your loyalty to spaghetti. somewhere you've got a program running... :49 GOTO 49 ps: half italian and a quarter swede, so I like spaghetti too, just not in my code. I once had a boss in NYC that used to say he was 80% finished and hand me a plate of spaghetti it fix. He's also the guy that wrote self modifying code in BAL. That was quite the experience.
74. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at y?ho?.com> May 28, 2008
- 793 views
Matt Lewis wrote: > > ken mortenson wrote: > > > > I wouldn't be adverse to an optional from/by > > > > Loop from 7 by -1.2 > > if (Index<-14.2) exit > > End Loop > > That's good to know. I think. So, what are you trying to tell me? I can take it. I'm a big boy.
75. Re: New keyword added: continue
- Posted by Kat <KAT12 at ?oos?hs.net> May 28, 2008
- 768 views
Derek Parnell wrote: > > Kat wrote: > > Thanks Kat. > > > Derek Parnell wrote: > >> ... how can I be sure that there is not another 'goto restart' > >> elsewhere in the code? > > > > You can't. You read the code to see if there is another "goto" that label. > > How likely would this requirement increase the cost of maintenance? In Textpad, drag the cursor over the label, and keypress for search. You could, i suppose, add a "came_from" var you interrogate in some way. > > The same with "exit", "return", etc.. I have a fair amount > > of code that has "return" sprinkled around, and no one has > > ever complained about more than one place leaving > > the function. > > I see this as a different issue. With 'goto' the question I raise deals with > how ones arrives at the label and has nothing to do with the 'goto' statement > itself, but with 'exit' and 'return', the process flow to arrive at that > statement > is clear and local. It is as clear as goto, i think. If i have a function, and i can return from it in several points, how do you know which return got you back out of the function? > > One way to restrict the "where from" is to localise all "goto" > > to procedure/function blocks, and not allow it in top level code. > > Exactly like in OOEU. > > Does the number of statements in a routine affect this position? What? I don't see the connection between statement count and use of any keyword. > >> ** If I have to place another looping construct within the same > >> scope as the one above, what should I call the labels? > > > > Umm, how about "loop2" ? > > Does the requirement that a 'goto' needs a (unique within the scope) label, > reduce the amount of code that has to be read by maintainers? To me it seems > that using the combination of 'label xyz' and 'goto xyz' contains a lot more > redundant content than 'next' does. But you *know* where goto will goto, and across languages, you haveto remember where each language differs, as well as how each human language interprets each of those other keywords, such as "next", "continue", etc. > If such a loop containing labels, needs to be later nested inside another > loop, > what is the suggested naming convention, if any? > > e.g. We start with ... > restart1: > loop > -- some code -- > goto restart1 > -- some more code --- > restart2: > loop > -- some code --- > goto restart2: > -- some code -- > goto restart1 > -- some code > end loop > end loop > > But later this needs to be nested, such as ... > > restart3: > loop > -- some code --- > restart1: > loop > -- some code -- > goto restart1 > -- some more code --- > restart2: > loop > -- some code --- > goto restart2: > -- some code -- > goto restart1 > -- some code -- > end loop > end loop > -- some code -- > goto restart3 > -- some code -- > end loop > > Would it be better to keep the existing label names as above, or is it better > to rename them to keep the implied nesting level obvious? Better to find a better way to code that. I would keep the labels more descriptive of what they do, and then not change them if you are wrapping or inserting new code that describes another function. > >> ** Under what circumstanes might I have to rename the labels? > > > Never, i believe. > > See above. Did. > > Just as an aside, one other cure for that > > would be nested procedures, which could be > > called inside the nesting procedure, and the > > nested one have the scope of the nesting one's > > vars > > Yes, nested routines would be very very nice. I suspect that we will have this > ability soon, but not for v4.0 Cool. Kat
76. Re: New keyword added: continue
- Posted by Kat <KAT12 at co?s?hs.net> May 28, 2008
- 793 views
Derek Parnell wrote: > > Kat wrote: > > > > c.k.lester wrote: > > > Maintainability of code is of utmost importance. Using goto is dangerous! > > > :) > > > > Why are these two blocks so different that you call the 2nd one "dangerous" > > ? > > Because in the first one we could get this ... > > > }}} <eucode> > procedure foo() > --- many lines of code --- > goto next > --- many lines of code --- > goto next > --- many lines of code --- > for loop = 1 to x do > -- code > if x = blah then goto next end if > -- code > :next > end for > --- many lines of code --- > goto next > --- many lines of code --- > end procedure > </eucode> {{{ > > But I can't do that in the second example, and thus the cost of maintenance > is lower in the second example. The cost is affected by the probability of > bugs, > the amount of code to read, and the amount of coding to repair/enhance > existing > code. I do not know why you'd do that code anyhow. You are jumping into a loop, you realise? You have unqualified statements to do a jump, so you have not shown me the entire code you wish me to approve or justify. Likewise, i could code up 100 procedures or functions, calling every one of them thru oddball routine_id() names, and cause everyone fits trying to trace them. And strangely, isn't that :next target where someone(?) wants to put an "entry" keyword? OUCH!! Do you want me to say you shouldn't code like that? Granted. Do you want me to say someone could code like that? Granted. Are you asking me if i think that is good code? No. Would i code like that? No. > > And how would you know how many places called "exit" to make the > > code flow change? > > The problem is not the 'goto' statement (ie. change of control flow), the > problem > is with the label and how to arrive there. > > The extra maintenance cost that 'goto' introduces into a program must be > offset > by the performance benefit derived from using it, IMHO. Demonstrate that in > a specific piece of Euphoria code and I'll support the use of 'goto' in that > piece of code. I cannot write up every possible piece of code that could possibly contain a "goto" for your support. I have no example of "goto" in Eu, because "goto" is not supported in Eu. I also code in mirc, but usually i use goto there for making up loops that mirc lacks, but Eu has. I tried using ooeu several times for more advanced projects, but there is a *HUGE* speed hit with ooeu which i cannot absorb. Perhaps this thread should be called "lets keep kat too busy answering the same questions over and over to spam any more". The discussion of goto has been going on for years on this list, and i am still in favor of goto being added to Eu. Kat
77. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at yah?o?com> May 28, 2008
- 774 views
Kat wrote: > for loop1 = 1 to 12 do > -- code > goto next1 > -- code > for loop2 = 1 to 12 do > -- code > goto next2 > -- code > for loop3 = 1 to 12 do > -- code > goto next3 > -- code > for loop4 = 1 to 12 do > -- code > goto next4 > -- code > for loop5 = 1 to 12 do > -- code > goto next5 > -- code > for loop6 = 1 to 12 do > -- code > goto next6 > -- code > :next6 > end for > :next5 > end for > :next4 > end for > :next3 > end for > :next2 > end for > :next1 > end for Is equivalent to... > for loop1 = 1 to 12 do > -- code > goto next1 > :next1 > end for Is this what you meant the code to do?
78. Re: New keyword added: continue
- Posted by Kat <KAT12 at c?osahs.net> May 28, 2008
- 787 views
ken mortenson wrote: > > Kat wrote: > > > And without rounding, i am over 50. > > Now I understand your loyalty to spaghetti. I am not in favor of spagetti code. This is getting irritating to the point of dropping Eu entirely. > somewhere you've got a program running... > > :49 > GOTO 49 No, i don't. > ps: half italian and a quarter swede, so I like spaghetti too, just not > in my code. I once had a boss in NYC that used to say he was 80% finished > and hand me a plate of spaghetti it fix. He's also the guy that wrote > self modifying code in BAL. That was quite the experience. I do have some self-modifying 6502 assy code, written without aid of an assembler. I did it once, i ran out of memory on a C64, and rather than find more somewhere, i modify one byte of memory on pass one, and set it back on pass two. It's never broken. Kat
79. Re: New keyword added: continue
- Posted by c.k.lester <euphoric at ?klester?com> May 28, 2008
- 767 views
Kat wrote: > > This is getting irritating to the point of dropping Eu entirely. Bye, kat!
80. Re: New keyword added: continue
- Posted by Jason Gade <jaygade at y?hoo?com> May 28, 2008
- 784 views
c.k.lester wrote: > > Kat wrote: > > > > This is getting irritating to the point of dropping Eu entirely. > > Bye, kat! That's kinda messed up, man. -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.
81. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at yahoo.??m> May 28, 2008
- 784 views
Kat wrote: > > ken mortenson wrote: > > Now I understand your loyalty to spaghetti. > > I am not in favor of spagetti code. This is getting irritating to the point > of dropping Eu entirely. Please forgive me Kat. I thought I was being cute. Obviously I'm not quite as charming as I must imagine myself to be.
82. Re: New keyword added: continue
- Posted by Derek Parnell <ddparnell at bigpond?com> May 28, 2008
- 769 views
Kat wrote: >>> Why are these two blocks so different that >>> you call the 2nd one "dangerous" > I do not know why you'd do that code anyhow. That is not the point, Kat. I know that you and all the other responsible coders would not write such code. But if 'goto' exists then it it possible for SOMEONE to write such code. And because of that possibility, the code maintainer has to check EVERY BLOODY time what the actual control flow is just in case some dunderhead wrote something this bad. > Likewise, i could code up 100 procedures or functions, calling > every one of them thru oddball routine_id() names, and cause > everyone fits trying to trace them. That is true. That is why the usage of each routine_id() needs to be justified too. However, because of the forward referencing restriction in Euphoria, routine_id() must be used in some cases because there is no alternative (apart from code duplication). > And strangely, isn't that > :next target where someone(?) wants to put an "entry" keyword? OUCH!! Also true. I've gone off the 'entry' keyword now for that reason and others. > Do you want me to say you shouldn't code like that? > Granted. Do you want me to say someone could code like that? Granted. > Are you asking me if i think that is good code? No. > Would i code like that? No. However, that is not the point, Kat. This is not about you. It is about that "someone" who could code like this. > I cannot write up every possible piece of code that > could possibly contain a "goto" for your support. Then don't. No one is forcing you too. However, if anyone wants me, specifically, to support their code that happens to use a 'goto', then they need to convince me that there is no better way but to use 'goto'. > i am still in favor of goto being added to Eu. I have no issue with goto being added to Euphoria. I have issues with me having to support code (Euphoria or otherwise) that uses goto. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
83. Re: New keyword added: continue
- Posted by Matt Lewis <matthewwalkerlewis at gmail?c?m> May 28, 2008
- 757 views
ken mortenson wrote: > > Matt Lewis wrote: > > > > ken mortenson wrote: > > > > > > I wouldn't be adverse to an optional from/by > > > > > > Loop from 7 by -1.2 > > > if (Index<-14.2) exit > > > End Loop > > > > That's good to know. I think. > > So, what are you trying to tell me? I can take it. I'm a big boy. Exactly. Matt
84. Re: New keyword added: continue
- Posted by Kat <KAT12 at coo?ahs.?et> May 28, 2008
- 759 views
ken mortenson wrote: > > Kat wrote: > > > for loop1 = 1 to 12 do > > -- code > > goto next1 > > -- code > > for loop2 = 1 to 12 do > > -- code > > goto next2 > > -- code > > for loop3 = 1 to 12 do > > -- code > > goto next3 > > -- code > > for loop4 = 1 to 12 do > > -- code > > goto next4 > > -- code > > for loop5 = 1 to 12 do > > -- code > > goto next5 > > -- code > > for loop6 = 1 to 12 do > > -- code > > goto next6 > > -- code > > :next6 > > end for > > :next5 > > end for > > :next4 > > end for > > :next3 > > end for > > :next2 > > end for > > :next1 > > end for > > Is equivalent to... > > > for loop1 = 1 to 12 do > > -- code > > goto next1 > > :next1 > > end for > > Is this what you meant the code to do? It has no meaning, it's a waste of bytes. It shows "goto next1" goes to ":next1" etc.. Forget it. Kat
85. Re: New keyword added: continue
- Posted by CChris <christian.cuvier at agriculture.?ouv.?r> May 28, 2008
- 761 views
c.k.lester wrote: > > Matt Lewis wrote: > > c.k.lester wrote: > > > Ah, I see how next/continue would work there, and retry. But restart- > > > jumping OUT of a loop and then going back into it- looks like it might > > > cause interpreter pains (memory leaks, etc.). And jumping out of the loop? > > > Dunno. Maybe an interpreter modifier can speak to that. > > You're probably afraid of 'exit', too. :P > > Seriously, exit is just a goto to the end of the loop. It doesn't do any > > clean up or anything. There isn't any needed. > > You'd know. > > I'm curious that there's no clean up necessary. It looks like there'd be a > dangling variable. Eeeewwwwwww!!! :D > > (I admit I've never used exit. I'm not a sloppy enough coder. HAHAHAHA. Just > kidding. I might've used it once. Well, I just checked bbcmf-system. Out of > about 8.6KLOC, exit appears 0 times. So, I probably never have used it.) No cleanup is needed. When you say
for i=1 to n do -- ... end for
a variable named i, but with a unique index, is created for the duration of the routine it is in (top level code is in a procedure which returns in a special way). Since only the index of a variable is being used in actual execution, the only concern is that this particular i be used out of context. This is ensured by hiding it when the parser sees "end for". The parser doesn't goto or loop through code, it linearly ploughs through it. The i variable is a variable like any other, but with a special scope, so that the only references to it will appear inside the for loop it indexes. What may be an issue is jumping into a for loop from outside. The first code in a for loop initialises i, so strange things may happen if that code is skipped. And the logic needed for goto to understand that it must reinitialise the for loop index(es) involved before jumping in is probably costly. This can work in an interpreter with multple passes over the source, but not with the current parser, which is one pass only for speed. CChris
86. Re: New keyword added: continue
- Posted by CChris <christian.cuvier at agric?ltur?.gouv.fr> May 28, 2008
- 783 views
Kat wrote: > > Derek Parnell wrote: > > > > Kat wrote: > > > }}} <eucode> > > > :restart > > > for loop = 1 to 12 do > > > :retry > > > -- code > > > if blah then goto restart end if > > > if blorg then goto retry end if > > > if not x then goto exit end if > > > if CK then goto next end if > > > if worstcase then goto cleanup&return end if > > > -- code > > > :next > > > end for > > > :exit > > > </eucode> {{{ > > > > Hi Kat, > > just a few of quick questions ... > > > > ** How, as a maintainer of the code above, can I be sure that process flow > > only > > gets to the "restart:" label from either the statement immediately preceding > > it or the 'goto' inside the loop? In other words, how can I be sure that > > there > > is not another 'goto restart' elsewhere in the code? > > You can't. You read the code to see if there is another "goto" that label. The > same with "exit", "return", etc.. I have a fair amount of code that has > "return" > sprinkled around, and no one has ever complained about more than one place > leaving > the function. One way to restrict the "where from" is to localise all "goto" > to procedure/function blocks, and not allow it in top level code. Exactly like > in OOEU. > > > ** If I have to place another looping construct within the same scope as the > > one above, what should I call the labels? > > Umm, how about "loop2" ? Or you mean the targets for more "goto" of the same > umm, form? Pick a name. You have the freedom to restart the inner loop, the > outer loop, the nested while loop in there which you added later, etc.. I tend > to give my nested loop names some description, even if it's just "index1", so > i could have a "goto restart_index1", which sorta reads easily, and i know > just > where it's going, and i can get there with the one "goto" keyword from any > depth > of nested loops. The target being present alerts me, as i am reading down the > code, that i may be going back to that point from somewhere. > > > ** Under what circumstanes might I have to rename the labels? > > Never, i believe. If you add loops, or other code, you do not need to change > anything, assuming your intent to goto the :target is the same. If you wish > to add a target, choose another name. Like i said, i tend to use the loop name > as part of the target, and/or/as well as the purpose, if i need any > clairification, > rather insuring unique target names. This way i can wrap or unwrap nested > loops, > and not have a problem, as well as skip blocks during debug. > > With goto scope restricted to proc/funct blocks, it makes some code even > easier, > such as "goto cleanup&return", which i know has the local scope of variables, > is at the bottom of the block where code will fall thru to anyhow, and execute > the "cleanup&return". With Eu the way it is now, i have hunks of code > copy/pasted > thruout which does the cleanup with local vars and returns, and those hunks > are a nightmare to keep identical. Just as an aside, one other cure for that > would be nested procedures, which could be called inside the nesting > procedure, > and the nested one have the scope of the nesting one's vars, i did this in > Turbo > Pascal a *lot*. > > I believe Matt scored 100 with the way he did goto in OOEU, and i reiterate > my suggestion all of OOEU be merged into Eu v4. > > Kat Which I'd support, with probably reservations about namespace handling. CChris
87. Re: New keyword added: continue
- Posted by CChris <christian.cuvier at agriculture.g??v.fr> May 28, 2008
- 778 views
Kat wrote: > > Derek Parnell wrote: > > > > Kat wrote: > > > > Thanks Kat. > > > > > Derek Parnell wrote: > > >> ... how can I be sure that there is not another 'goto restart' > > >> elsewhere in the code? > > > > > > You can't. You read the code to see if there is another "goto" that label. > > > > > > > How likely would this requirement increase the cost of maintenance? > > In Textpad, drag the cursor over the label, and keypress for search. You > could, > i suppose, add a "came_from" var you interrogate in some way. > > > > The same with "exit", "return", etc.. I have a fair amount > > > of code that has "return" sprinkled around, and no one has > > > ever complained about more than one place leaving > > > the function. > > > > I see this as a different issue. With 'goto' the question I raise deals with > > how ones arrives at the label and has nothing to do with the 'goto' > > statement > > itself, but with 'exit' and 'return', the process flow to arrive at that > > statement > > is clear and local. > > It is as clear as goto, i think. If i have a function, and i can return from > it in several points, how do you know which return got you back out of the > function? > > > > One way to restrict the "where from" is to localise all "goto" > > > to procedure/function blocks, and not allow it in top level code. > > > Exactly like in OOEU. > > > > Does the number of statements in a routine affect this position? > > What? I don't see the connection between statement count and use of any > keyword. > > > >> ** If I have to place another looping construct within the same > > >> scope as the one above, what should I call the labels? > > > > > > Umm, how about "loop2" ? > > > > Does the requirement that a 'goto' needs a (unique within the scope) label, > > reduce the amount of code that has to be read by maintainers? To me it seems > > that using the combination of 'label xyz' and 'goto xyz' contains a lot more > > redundant content than 'next' does. > > But you *know* where goto will goto, and across languages, you haveto remember > where each language differs, as well as how each human language interprets > each > of those other keywords, such as "next", "continue", etc. > > > If such a loop containing labels, needs to be later nested inside another > > loop, > > what is the suggested naming convention, if any? > > > > e.g. We start with ... > > restart1: > > loop > > -- some code -- > > goto restart1 > > -- some more code --- > > restart2: > > loop > > -- some code --- > > goto restart2: > > -- some code -- > > goto restart1 > > -- some code > > end loop > > end loop > > > > But later this needs to be nested, such as ... > > > > restart3: > > loop > > -- some code --- > > restart1: > > loop > > -- some code -- > > goto restart1 > > -- some more code --- > > restart2: > > loop > > -- some code --- > > goto restart2: > > -- some code -- > > goto restart1 > > -- some code -- > > end loop > > end loop > > -- some code -- > > goto restart3 > > -- some code -- > > end loop > > > > Would it be better to keep the existing label names as above, or is it > > better > > to rename them to keep the implied nesting level obvious? > > Better to find a better way to code that. I would keep the labels more > descriptive > of what they do, and then not change them if you are wrapping or inserting new > code that describes another function. > > > >> ** Under what circumstanes might I have to rename the labels? > > > > > Never, i believe. > > > > See above. > > Did. > > > > Just as an aside, one other cure for that > > > would be nested procedures, which could be > > > called inside the nesting procedure, and the > > > nested one have the scope of the nesting one's > > > vars > > > > Yes, nested routines would be very very nice. I suspect that we will have > > this > > ability soon, but not for v4.0 > > Cool. > > Kat It can be in 4.0 in a matter of days. The code works in interpreted mode in Æ. There may be issues with translated code, as I recently discovered, but the bulk of it could take like 3 days to port in, and a couple more for any residual bugs (I have always stated tat that code was experimental and not thoroughly tested). CChris
88. Re: New keyword added: continue
- Posted by CChris <christian.cuvier at agric?ltur?.gouv.fr> May 28, 2008
- 782 views
Derek Parnell wrote: > > Kat wrote: > >>> Why are these two blocks so different that > >>> you call the 2nd one "dangerous" > > > > I do not know why you'd do that code anyhow. > > That is not the point, Kat. I know that you and all the other responsible > coders > would not write such code. But if 'goto' exists then it it possible for > SOMEONE > to write such code. And because of that possibility, the code maintainer has > to check EVERY BLOODY time what the actual control flow is just in case some > dunderhead wrote something this bad. > Yeah, some coder did it wrong on the internet... Code which is hard to maintain won't be maintained and will quietly die, like many goto-less contribs in the Archive. Why should we care? > > Likewise, i could code up 100 procedures or functions, calling > > every one of them thru oddball routine_id() names, and cause > > everyone fits trying to trace them. > > That is true. That is why the usage of each routine_id() needs to be justified > too. However, because of the forward referencing restriction in Euphoria, > routine_id() > must be used in some cases because there is no alternative (apart from code > duplication). > > > And strangely, isn't that > > :next target where someone(?) wants to put an "entry" keyword? OUCH!! > > Also true. I've gone off the 'entry' keyword now for that reason and others. > > > Do you want me to say you shouldn't code like that? > > Granted. Do you want me to say someone could code like that? Granted. > > Are you asking me if i think that is good code? No. > > Would i code like that? No. > > However, that is not the point, Kat. This is not about you. It is about that > "someone" who could code like this. > > > I cannot write up every possible piece of code that > > could possibly contain a "goto" for your support. > > Then don't. No one is forcing you too. However, if anyone wants me, > specifically, > to support their code that happens to use a 'goto', then they need to convince > me that there is no better way but to use 'goto'. > > > i am still in favor of goto being added to Eu. > > I have no issue with goto being added to Euphoria. I have issues with me > having > to support code (Euphoria or otherwise) that uses goto. > We may agree that the standard library, nor the interpreter, shoud not have goto (the C code in backend and translated code has them galore). If you supervise coders, you may ask them not to use it, since you are the boss. Any remaining concern? CChris > -- > Derek Parnell > Melbourne, Australia > Skype name: derek.j.parnell
89. Re: New keyword added: continue
- Posted by Derek Parnell <ddparnell at bi?pond.co?> May 28, 2008
- 793 views
CChris wrote: > Which I'd support, with probably reservations about namespace handling. What is it that you would support? Your response is not clear about what section of that very long post you're referring to. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
90. Re: New keyword added: continue
- Posted by Derek Parnell <ddparnell at bi?pon?.com> May 28, 2008
- 778 views
CChris wrote: > It can be in 4.0 in a matter of days. What is the 'it' you talk about here? Whatever it is, don't add it to Eu until we all know what 'it' is that you are proposing to do. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
91. Re: New keyword added: continue
- Posted by Derek Parnell <ddparnell at ?igpond.c?m> May 28, 2008
- 782 views
CChris wrote: > If you supervise coders, you may ask them not to use it, > since you are the boss. Any remaining concern? Are you talking to me, Chris? If so, what are you talking about? I really haven't got a clue what trying to say to me. -- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
92. Re: New keyword added: continue
- Posted by CChris <christian.cuvier at agriculture.go?v?fr> May 28, 2008
- 762 views
Derek Parnell wrote: > > CChris wrote: > > > Which I'd support, with probably reservations about namespace handling. > > What is it that you would support? Your response is not clear about what > section > of that very long post you're referring to. > The section preceding my comment, ie getting 80+% of OOEu into official Eu. CChris > -- > Derek Parnell > Melbourne, Australia > Skype name: derek.j.parnell
93. Re: New keyword added: continue
- Posted by Jeremy Cowgar <jeremy at ?owgar.com> May 28, 2008
- 775 views
CChris wrote: > > > The section preceding my comment, ie getting 80+% of OOEu into official Eu. > What specific functionality of OOeu? -- Jeremy Cowgar http://jeremy.cowgar.com
94. Re: New keyword added: continue
- Posted by CChris <christian.cuvier at a?ric?lture.gouv.fr> May 28, 2008
- 770 views
Derek Parnell wrote: > > CChris wrote: > > > It can be in 4.0 in a matter of days. > > What is the 'it' you talk about here? > Support for nested routines. Like in
function umbrella() integer n1 sequence s2 procedure foo() --... end procedure -- umbrella code end function
A nested routine can be called only by * itself * the routine it is nested in (recursively) * any routine recursively nested in it * a sibling, ie another routine singly nested into the same parent * any routine recursively nested in a sibling Top level code is not considered to have any nested routine. The rules are needed in case of multiple nesting, so that no variable name clash occurs. Calling an indirect descendent (grandchild or more) is not forbidden, but probably to be frowned upon. Only vars defined by a routine or any of its ancestors are available to it. > Whatever it is, don't add it to Eu until we all know what 'it' is that you are > proposing to do. Of course CChris > > > -- > Derek Parnell > Melbourne, Australia > Skype name: derek.j.parnell
95. Re: New keyword added: continue
- Posted by CChris <christian.cuvier at ag?iculture.gouv.f?> May 28, 2008
- 780 views
Derek Parnell wrote: > > CChris wrote: > > > If you supervise coders, you may ask them not to use it, > > since you are the boss. Any remaining concern? > > Are you talking to me, Chris? If so, what are you talking about? I really > haven't > got a clue what trying to say to me. > > -- > Derek Parnell > Melbourne, Australia > Skype name: derek.j.parnell You said: I'm concerned about having someday to maintain code that someone wrote badly using goto. Let's assume the oncern is not overplayed. Now how would that situation be happening? 1/ Because the Eu interpreter or the standard lib uses goto. We mat reasonably agree not to let this happen. After all, they are in the greater common denominator of Eu, which dosn't include goto. 2/ Because someone you supervise is giving you such code. Then you are free to set your coding rules, including not using goto. 3/ Because a supervisor hands you that job, and he accepted goto in code. But then you were aware that it ould happen, right? 4/ Otherwise, you have hardly any obligation to maintain any code you didn't write, so you can decide to not maintain if there's a goto. Is that clearer? So, you can always avoid maintaining the dreaded code, and your concerns will remain theory, even with goto in the language, not actual. CChris Notes: 1/ I'm not actively pushing for goto, as it may be of scarce usefulness with the new flow control statements in, and has serious pitfalls. However, I see that most of the reasons put forward against it are quite wrong. 2/ Can someone point me to actual publicly released spaghetti code? It's everyone's talk, but I have never seen any. Preferrably something less than 5 year old.
96. Re: New keyword added: continue
- Posted by Jeremy Cowgar <jeremy at cow?ar.?om> May 28, 2008
- 782 views
> > You said: I'm concerned about having someday to maintain code that someone > wrote > badly using goto. > <snip> > Let's assume the concern is not overplayed. Now how would that situation be > happening? > > 1/ Because the Eu interpreter or the standard lib uses goto. We mat > reasonably agree not to let this happen. After all, they are in the greater > common denominator of Eu, which dosn't include goto. I've heard a few people say this and it does not make sense to me. I am not arguing for or against goto but here is my simple observation on the above statement. If goto is not good for the standard libraries than it's not good for the language. If it is good for the language than it's good for the standard library. I see no exceptions to this rule. Why would we add language functionality and then ban it from use? If we have the idea it should be banned, then it shouldn't be added! If we think it should be added then we cannot/should not ban it's use! -- Jeremy Cowgar http://jeremy.cowgar.com
97. Re: New keyword added: continue
- Posted by CChris <christian.cuvier at agriculture.gouv??r> May 28, 2008
- 773 views
Jeremy Cowgar wrote: > > CChris wrote: > > > > > > The section preceding my comment, ie getting 80+% of OOEu into official Eu. > > > > What specific functionality of OOeu? > > -- > Jeremy Cowgar > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> - prototype based classes - dynamic variables (var_id(), read_variable(), ...) - dynamic code execution (eval() and friends) - supportfor optional : return_type in funvtion headers - and, why not?, goto CChris
98. Re: New keyword added: continue
- Posted by Jason Gade <jaygade at yahoo?c?m> May 28, 2008
- 759 views
CChris wrote: > > Jeremy Cowgar wrote: > > > > CChris wrote: > > > > > > > > > The section preceding my comment, ie getting 80+% of OOEu into official > > > Eu. > > > > > > > What specific functionality of OOeu? > > > > -- > > Jeremy Cowgar > > <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a> > > - prototype based classes Wait -- OOEU has classes. I don't remember it having "prototype-based classes". From my readings, prototype-based OO is very different from class-based OO because in class-based OO classes and objects are different kinds of things and in prototype-based they aren't. > - dynamic variables (var_id(), read_variable(), ...) > - dynamic code execution (eval() and friends) > - supportfor optional : return_type in funvtion headers What is "optional : return_type in function headers"? That sounds like a move away from genericity to me. > - and, why not?, goto > > CChris -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.
99. Re: New keyword added: continue
- Posted by Matt Lewis <matthewwalkerlewis at gmail.co?> May 28, 2008
- 799 views
Jason Gade wrote: > > CChris wrote: > > > > - supportfor optional : return_type in funvtion headers > > What is "optional : return_type in function headers"? That sounds like a move > away from genericity to me. You could overload class methods as long as they had different signatures. ooeu mangled names similar to C++. So you could have two different methods with the same name and same number of parameters. The return type helped the parser figure out which method to use based upon the return parameters from functions. It wasn't enforced in ooeu.
euclass complex( sequence c ) atom real, imaginary function add( atom a ) : complex ... end function function add( complex c ) ... end function function complex( atom r ) : complex return {r, 0} end function function complex( atom r, atom i ) : complex return {r, i} end function function complex( complex c ) : complex return c end function end euclass complex x, y x = complex( 0 ) y = complex( 5, 2 ) x = x.add( 3 ) x = x.add( y ) x = x.add( y.add( 2 ) )
100. Re: New keyword added: continue
- Posted by Jason Gade <jaygade at ?ah?o.com> May 28, 2008
- 776 views
Matt Lewis wrote: > > Jason Gade wrote: > > > > CChris wrote: > > > > > > - supportfor optional : return_type in funvtion headers > > > > What is "optional : return_type in function headers"? That sounds like a > > move > > away from genericity to me. > > You could overload class methods as long as they had different signatures. > > ooeu mangled names similar to C++. So you could have two different methods > with the same name and same number of parameters. The return type helped > the parser figure out which method to use based upon the return parameters > from functions. It wasn't enforced in ooeu. > }}} <eucode> > euclass complex( sequence c ) > atom real, imaginary > > function add( atom a ) : complex > ... > end function > > function add( complex c ) > ... > end function > > function complex( atom r ) : complex > return {r, 0} > end function > > function complex( atom r, atom i ) : complex > return {r, i} > end function > > function complex( complex c ) : complex > return c > end function > end euclass > > complex x, y > x = complex( 0 ) > y = complex( 5, 2 ) > > x = x.add( 3 ) > x = x.add( y ) > x = x.add( y.add( 2 ) ) > </eucode> {{{ Yeah, I had to recheck the docs after CChris mentioned it. How does that affect non-method routines? -- A complex system that works is invariably found to have evolved from a simple system that works. --John Gall's 15th law of Systemantics. "Premature optimization is the root of all evil in programming." --C.A.R. Hoare j.
101. Re: New keyword added: continue
- Posted by Matt Lewis <matthewwalkerlewis at gm?il.?om> May 28, 2008
- 766 views
Jason Gade wrote: > > Matt Lewis wrote: > > > > Jason Gade wrote: > > > > > > What is "optional : return_type in function headers"? That sounds like a > > > move > > > away from genericity to me. > > > > You could overload class methods as long as they had different signatures. > > > > ooeu mangled names similar to C++. So you could have two different methods > > with the same name and same number of parameters. The return type helped > > the parser figure out which method to use based upon the return parameters > > from functions. It wasn't enforced in ooeu. > > > Yeah, I had to recheck the docs after CChris mentioned it. > > How does that affect non-method routines? It doesn't, except when they're used as parameters for method calls. Basically, the return type was stored in a slot in the symbol table for each function (defaulted to object, IIRC). It was therefore an additional couple of tokens to parse, and a little bit of additional information in the symbol table that the OO symbol resolution code used. Matt
102. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at yahoo?c?m> May 28, 2008
- 769 views
CChris wrote: > So, you can always avoid maintaining the dreaded code, and your concerns will > remain theory, even with goto in the language, not actual. With all due respect, this is incorrect. In the real world, supervisors are not baby sitters. They usually (almost always) do not have time for a full (or even partial) code review. Even if a supervisor assigns a senior programmer to review a junior programmers code, in a real shop where everybodies working on there own stuff, it just doesn't get done. Only when code review is part of an institutional and formal process does it get done, which is hardly ever the case. So if you agree (and you certainly have the right not to) that some feature makes maintainance a greater issue; if that feature is in the language you can be assured that some will abuse it. OTOH, whatever doesn't exist can not be abused.
103. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at y?hoo.co?> May 28, 2008
- 800 views
Jeremy Cowgar wrote: > > > > You said: I'm concerned about having someday to maintain code that someone > > wrote > > badly using goto. > > > > <snip> > > > Let's assume the concern is not overplayed. Now how would that situation be > > happening? > > > > 1/ Because the Eu interpreter or the standard lib uses goto. We mat > > reasonably agree not to let this happen. After all, they are in the greater > > common denominator of Eu, which dosn't include goto. > > I've heard a few people say this and it does not make sense to me. I am not > arguing for or against goto but here is my simple observation on the above > statement. > > If goto is not good for the standard libraries than it's not good for the > language. > If it is good for the language than it's good for the standard library. I see > no exceptions to this rule. Why would we add language functionality and then > ban it from use? If we have the idea it should be banned, then it shouldn't > be added! If we think it should be added then we cannot/should not ban it's > use! That's just too logical Jeremy. What are you, some kind of fanatic?
104. Re: New keyword added: continue
- Posted by CChris <christian.cuvier at agricult?re.gouv.?r> May 28, 2008
- 765 views
Jason Gade wrote: > > Matt Lewis wrote: > > > > Jason Gade wrote: > > > > > > CChris wrote: > > > > > > > > - supportfor optional : return_type in funvtion headers > > > > > > What is "optional : return_type in function headers"? That sounds like a > > > move > > > away from genericity to me. > > > > You could overload class methods as long as they had different signatures. > > > > ooeu mangled names similar to C++. So you could have two different methods > > with the same name and same number of parameters. The return type helped > > the parser figure out which method to use based upon the return parameters > > from functions. It wasn't enforced in ooeu. > > }}} <eucode> > > euclass complex( sequence c ) > > atom real, imaginary > > > > function add( atom a ) : complex > > ... > > end function > > > > function add( complex c ) > > ... > > end function > > > > function complex( atom r ) : complex > > return {r, 0} > > end function > > > > function complex( atom r, atom i ) : complex > > return {r, i} > > end function > > > > function complex( complex c ) : complex > > return c > > end function > > end euclass > > > > complex x, y > > x = complex( 0 ) > > y = complex( 5, 2 ) > > > > x = x.add( 3 ) > > x = x.add( y ) > > x = x.add( y.add( 2 ) ) > > </eucode> {{{ > > Yeah, I had to recheck the docs after CChris mentioned it. > > How does that affect non-method routines? > > -- > A complex system that works is invariably found to have evolved from a simple > system that works. > --John Gall's 15th law of Systemantics. > > "Premature optimization is the root of all evil in programming." > --C.A.R. Hoare > > j. In self documentation, optimisation in returning vlues and again clearer code. That's why it would be optional for non OO routines. CChris
105. Re: New keyword added: continue
- Posted by Matt Lewis <matthewwalkerlewis at gmail.c?m> May 28, 2008
- 782 views
Jeremy Cowgar wrote: > > If goto is not good for the standard libraries than it's not good for the > language. If it is good for the language than it's good for the standard > library. I see no exceptions to this rule. Why would we add language > functionality and then ban it from use? If we have the idea it should be > banned, then it shouldn't be added! If we think it should be added then we > cannot/should not ban it's use! That's a good general principle, but not necessarily true for every case. One place where goto can be a lifesaver is in porting code from other languages that either have goto, or have other flow control structures that we don't. Goto emulation in these cases can lead to really messy code that's technically structured code, but the mess of nested ifs and flags can make a giant knot that could be cut with a well placed goto here and there. They can also be used in certain cases to great effect in optimizing (take a look at the back end of the interpreter :). I accept that some view this as insufficient reason for adding goto. I happen to disagree with them. Matt
106. Re: New keyword added: continue
- Posted by CChris <christian.cuvier at agriculture.?ouv?fr> May 28, 2008
- 778 views
ken mortenson wrote: > > Jeremy Cowgar wrote: > > > > > > > You said: I'm concerned about having someday to maintain code that someone > > > wrote > > > badly using goto. > > > > > > > <snip> > > > > > Let's assume the concern is not overplayed. Now how would that situation > > > be > > > happening? > > > > > > 1/ Because the Eu interpreter or the standard lib uses goto. We mat > > > reasonably agree not to let this happen. After all, they are in the > > > greater > > > common denominator of Eu, which dosn't include goto. > > > > I've heard a few people say this and it does not make sense to me. I am not > > arguing for or against goto but here is my simple observation on the above > > statement. > > > > If goto is not good for the standard libraries than it's not good for the > > language. > > If it is good for the language than it's good for the standard library. I > > see > > no exceptions to this rule. Why would we add language functionality and then > > ban it from use? If we have the idea it should be banned, then it shouldn't > > be added! If we think it should be added then we cannot/should not ban it's > > use! > > That's just too logical Jeremy. What are you, some kind of fanatic? 1/ The standard library is made of very short routines, with perhaps the exception of sort.e. There would be hardly any point in using goto there anyway. 2/The interpreter is made of a few source files maintained by a few programmers. That selected group may decide anything that helps keep it cohesive. In both cases, there is no reason to apply the same strategy to general code. CChris
107. Re: New keyword added: continue
- Posted by Jeremy Cowgar <jeremy at cow?ar.co?> May 28, 2008
- 768 views
Matt Lewis wrote: > > I accept that some view this as insufficient reason for adding goto. I > happen to disagree with them. > I think goto should be added, however, if goto exists and it makes sense to use it in a given situation, then it should be allowed in the standard library. Everyone is afraid of spaghetti code. We can create spaghetti code with or without goto. What stops us from doing so? Hopefully those contributing to Euphoria know how to program w/o spaghetti. Hopefully those peer reviewing commits will recognize spaghetti when it's committed. To say that goto could *possibly* create spaghetti *if* used improperly by a *novice* programmer therefore it should not be allowed in the standard library sounds a bit odd to me. -- Jeremy Cowgar http://jeremy.cowgar.com
108. Re: New keyword added: continue
- Posted by ken mortenson <kenneth_john at ya?oo.c?m> May 28, 2008
- 777 views
Matt Lewis wrote: > > Goto emulation in these cases can lead to really messy code that's technically > structured code, but the mess of nested ifs and flags can make a giant knot > that could be cut with a well placed goto here and there. Matt, here's something to think about for a moment. If GOTO is so essential, how is it that MILLIONS of programmer, writing BILLIONS of lines of code over DECADES have been able to forgo using it? This is a serious thing to ponder. I admit the adustment to writing structured code is not an easy one, but the rewards (this is just one of many voices of experience) are more than you know.
109. Re: New keyword added: continue
- Posted by Matt Lewis <matthewwalkerlewis at gmail??om> May 28, 2008
- 814 views
ken mortenson wrote: > > Matt Lewis wrote: > > > > Goto emulation in these cases can lead to really messy code that's > > technically > > structured code, but the mess of nested ifs and flags can make a giant knot > > that could be cut with a well placed goto here and there. > > Matt, here's something to think about for a moment. If GOTO is so essential, > how is it that MILLIONS of programmer, writing BILLIONS of lines of code > over DECADES have been able to forgo using it? This is a serious thing to > ponder. Yes, lot's of code has been written without using $language_feature. It does not follow that $language_feature is superfluous. > I admit the adjustment to writing structured code is not an easy one, but the > rewards (this is just one of many voices of experience) are more than you > know. This statement makes even less sense than the one before. Are you sure that you meant to respond to me? Matt