[swift-evolution] Optional "endfor", "endif", etc after closing "}"

Marc Knaup marc at knaup.koeln
Sat Dec 12 07:31:11 CST 2015


I'm also against any kind of markers to annotate the end of a block.

If the code inside a if/guard/loop/do/func/var/… block is so long that the
developer thinks about annotating the closing curly brace then they should
instead break it down into smaller pieces. Move parts into separate
functions and replace it with calls to these functions.
This makes the block shorter, much easier to understand and the function
names will aid as additional documentation.

On Sat, Dec 12, 2015 at 2:19 PM, Amir Michail via swift-evolution <
swift-evolution at swift.org> wrote:

>
> > On Dec 12, 2015, at 7:54 AM, Andrew Brown <a.br at me.com> wrote:
> >
> > +1
> >
> > Anything that supports developers is worth it.
> > Can't say I like the syntax but I'll take whatever is agreed.
>
> What about this syntax?
>
> for … {
>   if … {
>>   } /if
> } /for
>
>
> >
> > ABR.
> >
> >> On 8 Dec 2015, at 14:43, Amir Michail via swift-evolution <
> swift-evolution at swift.org> wrote:
> >>
> >>
> >>> On Dec 8, 2015, at 8:42 AM, Amir Michail via swift-evolution <
> swift-evolution at swift.org> wrote:
> >>>
> >>> Unlike something like “} // if”, the compiler would actually check "}
> endif” and report an error if “}” doesn’t close the expected construct.
> >>
> >> Or perhaps more elegantly (again, it’s optional):
> >>
> >> if ... {
> >>  …
> >> if }
> >>
> >> for ... {
> >>  …
> >> for }
> >> etc.
> >>
> >>
> >>> _______________________________________________
> >>> swift-evolution mailing list
> >>> swift-evolution at swift.org
> >>> https://lists.swift.org/mailman/listinfo/swift-evolution
> >>
> >> _______________________________________________
> >> swift-evolution mailing list
> >> swift-evolution at swift.org
> >> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151212/6c90162b/attachment.html>


More information about the swift-evolution mailing list