[swift-evolution] In-line scope designators

Ted F.A. van Gaalen tedvgiosdev at gmail.com
Tue Jun 20 12:24:57 CDT 2017


Before bringing this forward, I’ve tried brackets  { } as well 
for “my feature” but found this to be a bit awkward, 
confusing with real program { } blocks, 
also because it has nothing to do with blocks
(except for the class or struct body as limitation) 
rather its effect is sequential, line by line, 
within the class or struct body.
e.g:
      default scope here.
  private:
       source lines
       all declarations in lines following are private
       until another in-line scope designator is encountered.
  defalutscope:
      source lines
   public:
      source lines
    end of class/ struct/ 

Thus, it acts more or less like a compiler directive… 
therefore, perhaps this would better: 

@private:
   source lines
@public:
   source lines
@defaultscope:  // returns to default scope 
  source lines.
  
?

TedvG

> On 20. Jun 2017, at 18:32, Tino Heth <2th at gmx.de> wrote:
> 
> 
>> You can already effectively have these "regions" using extensions, with the exception of stored properties since they can't be placed there.
> I still think nested extensions would have been a good addition to the language: If we had those, 
> 
> struct MyType {
> 	private {
> 		var myPrivateVar: Int?
> 		var anotherOne: String?
> 	}
> }
> 
> would be a rather small piece of syntactic sugar...

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170620/f5d81c27/attachment.html>


More information about the swift-evolution mailing list