Bug 20255 - Simple Loop Labeling

Ralph DiMola rdimola at evergreeninfo.net
Fri Aug 11 09:57:01 EDT 2017


I did not want to be the one to rehash this again but I would love to have
this as I do it manually all the time with comments. +1

Ralph DiMola
IT Director
Evergreen Information Services
rdimola at evergreeninfo.net


-----Original Message-----
From: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] On Behalf
Of Mark Waddingham via use-livecode
Sent: Friday, August 11, 2017 5:51 AM
To: How to use LiveCode
Cc: Mark Waddingham
Subject: Re: Bug 20255 - Simple Loop Labeling

On 2017-08-10 21:33, Dr. Hawkins via use-livecode wrote:
> In fact, what I would *like* is modern Fortran style labelling or 
> something like that, and the ability to the those labels to controls 
> like next and exit.  This, however, would accomplish so much with so 
> little.

Thinking out loud here and taking into account suggestions people have made
in the past...

Naming loops in a syntactic way certainly sounds like a useful thing to
do:

repeat for each line tLine in tContainer named LineLoop
   repeat for each item tItem in tLine named ItemLoop
     if some complicated condition then
       exit repeat ItemLoop
     else if some other complicated condition then
       exit repeat LineLoop
     end if

     -- do other stuff
     if some even more complicated condition then
       next repeat LineLoop
     end if
   end repeat ItemLoop
end repeat LineLoop

Certainly 'exit repeat ...' would not be harmful, 'next repeat ...' I'd have
to analyze more deeply.

The main problem with GOTO (apart from the ability to create very hard to
understand code) is that it allows creation of what is called 'unstructured
control-flow'. Basically that means that you have to work
*exceptionally* hard to untangle it in a compile to perform any sort of
reasonable optimization.

At present LiveCode only allows you to produce 'structured control flow'.
Adding 'next repeat ...', doesn't change that... However, 'next repeat ...'
is not so clear (I think it is probably fine, but need to check some
algorithmics).

The only other issue with the above (beyond implementing it) is the
syntax... It would reserve 'named' as a non-operator in this context. If we
did ever have reason to have 'X named Y' then in repeats you'd have to do:

   repeat for each line tLine in (tContainer named ...) named ...

Although - without knowing what 'named' might do as an operator, or being
able to think of anything it could do - that is probably a safe addition
from that point of view.

(Of course we could use 'labelled' instead of 'named' in the repeat context
- 'labelled' seems for some reason less likely to be leveragable as a binary
operator!)

Warmest Regards,

Mark.

--
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the Use-livecode mailing list