Re: [swift-users] make swift compiler to use the precompiled module files

2016-04-29 Thread Daniel Dunbar via swift-users
If the hash value of the module is different then most likely something else is 
going on -- are you passing any special flags or defines as part of the 
compiler command? If you run the same command from swiftc on the command line 
do you see the same behavior?

 - Daniel

> On Apr 29, 2016, at 2:08 PM, Ramakrishna Mallireddy 
>  wrote:
> 
> Every-time I run swift frontend the clang creates a new cachedir with 
> modulecache path hash(on every run the hash value is different for the same 
> input string) as the name of the dir and generates default cocoa framework 
> pcm files inside it.
> 
> I am using the swift front-end c++ api's to compile a simple swift file.
> If I set the -fdisable-module-hash, then pcm files are generated without the 
> hash as required under the ModuleCache Dir.
> so problem is solved as clang now see the existing pcm files, but now I hit 
> the next hurdle.
> 
> Now the pcm files are there in the cache, when I run the frontend again, I 
> assume clang will load the AST from the pcm files but clang ReadAST returns 
> with ASTReader::OutOfDate and as usual it calls compileAndLoadModule which I 
> want to avoid in the first place.
> 
> Call to CLang::CompilerInstance::ModuleManager->ReadAST(ModuleFileName,
>serialization::MK_ImplicitModule,
> 
>ImportLoc, ARRFlags) return with 
> ASTReader::OutOfDate
> 
> as ReadASTCore(FileName, Type, ImportLoc,  /*ImportedBy=*/nullptr, Loaded, 0, 
> 0, 0, ClientLoadCapabilities) returns with OutOfDate.
> 
> These files are generated just few minutes ago, how can it be OutOfDate I 
> don't have any idea.
> 
> File modules.timestamp under the ModuleCache Dir is 0 bytes.
> 
> Thanks
> 
> Ramakrishna
> 
> 
> On Fri, Apr 29, 2016 at 9:15 PM, Daniel Dunbar  > wrote:
> Clang will cache these automatically, can you give more details on exactly 
> what you are seeing?
> 
>  - Daniel
> 
> > On Apr 28, 2016, at 10:50 PM, Ramakrishna Mallireddy via swift-users 
> > mailto:swift-users@swift.org>> wrote:
> >
> > I have these precompiled module files generated every-time I run the swift 
> > compiler.
> >
> > _Builtin_stddef_max_align_t-1LMTETLX3WNFT.pcm
> > CFNetwork-1UTIO6DPB9R5P.pcm
> > CoreFoundation-CF8BGN41VJ11.pcm
> > CoreGraphics-3SDFP08OX46EF.pcm
> > CoreImage-3SDFP08OX46EF.pcm
> > Darwin-4F8STAM1KXDF.pcm
> > Foundation-2LQ7EQYFLQOP.pcm
> > ...etc
> >
> > How can I make the swift compiler to use these cache rather than compiling 
> > the libraries again.
> >
> > Thanks
> > Ramakrishna
> > ___
> > swift-users mailing list
> > swift-users@swift.org 
> > https://lists.swift.org/mailman/listinfo/swift-users 
> > 
> 
> 

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Protocols, `mutating` and Value vs Reference Types.

2016-04-29 Thread Dave Abrahams via swift-users

on Fri Apr 29 2016, Hooman Mehr  wrote:

> Thank you very much for your response. I made the change in the gist. This 
> takes
> me back to the same error that forced my into duplication path:
>
> “Cannot assign through subscript: ‘self’ is immutable” for the object case.
>
> The gist is self contained if you want to compile it yourself.
>
> Is this some kind of bug or the expected behavior?

Looks like a bug to me!

>
>
> On Apr 29, 2016, at 5:28 PM, Dave Abrahams via swift-users
>  wrote:
>
> on Fri Apr 29 2016, Hooman Mehr  wrote:
>
> Hi,
>
> I am designing APIs that need to support both reference (class/object)
> and value
> types. I am running into restrictions of `mutating` keyword in my
> protocols and
> this is causing a lot of duplication of code. In order to understand
> what I mean
> please take a look at this gist. 
>
> As you see, I have pairs of almost identical declarations: 
> KeyValueStore
> vs
> KeyValueStoreObject, and AnyDictionaryStore vs 
> AnyDictionaryStoreObject.
> This
> keeps rapidly growing as I am designing my APIs. Is there any sane way
> around
> this?
>
> protocol KeyValueStoreObject : class, KeyValueStore {}
> protocol AnyDictionaryStoreObject : class, AnyDictionaryStore {}
>
> would probably work for you.
>
> HTH,
>
> -- 
> Dave
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>

-- 
Dave
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Protocols, `mutating` and Value vs Reference Types.

2016-04-29 Thread Hooman Mehr via swift-users
Thank you very much for your response. I made the change in the gist 
. This takes 
me back to the same error that forced my into duplication path:

“Cannot assign through subscript: ‘self’ is immutable” for the object case.

The gist  is 
self contained if you want to compile it yourself.

Is this some kind of bug or the expected behavior?

> On Apr 29, 2016, at 5:28 PM, Dave Abrahams via swift-users 
>  wrote:
> 
> 
> on Fri Apr 29 2016, Hooman Mehr  wrote:
> 
>> Hi,
>> 
>> I am designing APIs that need to support both reference (class/object) and 
>> value
>> types. I am running into restrictions of `mutating` keyword in my protocols 
>> and
>> this is causing a lot of duplication of code. In order to understand what I 
>> mean
>> please take a look at this gist. 
>> 
>> As you see, I have pairs of almost identical declarations: KeyValueStore vs
>> KeyValueStoreObject, and AnyDictionaryStore vs AnyDictionaryStoreObject. This
>> keeps rapidly growing as I am designing my APIs. Is there any sane way around
>> this?
> 
> protocol KeyValueStoreObject : class, KeyValueStore {}
> protocol AnyDictionaryStoreObject : class, AnyDictionaryStore {}
> 
> would probably work for you.
> 
> HTH,
> 
> -- 
> Dave
> 
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Protocols, `mutating` and Value vs Reference Types.

2016-04-29 Thread Dave Abrahams via swift-users

on Fri Apr 29 2016, Hooman Mehr  wrote:

> Hi,
>
> I am designing APIs that need to support both reference (class/object) and 
> value
> types. I am running into restrictions of `mutating` keyword in my protocols 
> and
> this is causing a lot of duplication of code. In order to understand what I 
> mean
> please take a look at this gist. 
>
> As you see, I have pairs of almost identical declarations: KeyValueStore vs
> KeyValueStoreObject, and AnyDictionaryStore vs AnyDictionaryStoreObject. This
> keeps rapidly growing as I am designing my APIs. Is there any sane way around
> this?

protocol KeyValueStoreObject : class, KeyValueStore {}
protocol AnyDictionaryStoreObject : class, AnyDictionaryStore {}

would probably work for you.

HTH,

-- 
Dave

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] make swift compiler to use the precompiled module files

2016-04-29 Thread Ramakrishna Mallireddy via swift-users
Every-time I run swift frontend the clang creates a new cachedir with
modulecache path hash(on every run the hash value is different for the same
input string) as the name of the dir and generates default cocoa framework
pcm files inside it.

I am using the swift front-end c++ api's to compile a simple swift file.
If I set the -fdisable-module-hash, then pcm files are generated without
the hash as required under the ModuleCache Dir.
so problem is solved as clang now see the existing pcm files, but now I hit
the next hurdle.

Now the pcm files are there in the cache, when I run the frontend again, I
assume clang will load the AST from the pcm files but clang *ReadAST *returns
with *ASTReader::OutOfDate *and as usual it calls *compileAndLoadModule *which
I want to avoid in the first place*.*

Call to *CLang*::*CompilerInstance*::*ModuleManager*->*ReadAST*
(ModuleFileName,

   serialization::MK_ImplicitModule,

   ImportLoc, ARRFlags) return with
*ASTReader::OutOfDate*

as *ReadASTCore*(FileName, Type, ImportLoc,  /*ImportedBy=*/nullptr,
Loaded, 0, 0, 0, ClientLoadCapabilities) returns with *OutOfDate.*

These files are generated just few minutes ago, how can it be OutOfDate I
don't have any idea.

File* modules.timestamp* under the ModuleCache Dir is 0 bytes.

Thanks

Ramakrishna

On Fri, Apr 29, 2016 at 9:15 PM, Daniel Dunbar 
wrote:

> Clang will cache these automatically, can you give more details on exactly
> what you are seeing?
>
>  - Daniel
>
> > On Apr 28, 2016, at 10:50 PM, Ramakrishna Mallireddy via swift-users <
> swift-users@swift.org> wrote:
> >
> > I have these precompiled module files generated every-time I run the
> swift compiler.
> >
> > _Builtin_stddef_max_align_t-1LMTETLX3WNFT.pcm
> > CFNetwork-1UTIO6DPB9R5P.pcm
> > CoreFoundation-CF8BGN41VJ11.pcm
> > CoreGraphics-3SDFP08OX46EF.pcm
> > CoreImage-3SDFP08OX46EF.pcm
> > Darwin-4F8STAM1KXDF.pcm
> > Foundation-2LQ7EQYFLQOP.pcm
> > ...etc
> >
> > How can I make the swift compiler to use these cache rather than
> compiling the libraries again.
> >
> > Thanks
> > Ramakrishna
> > ___
> > swift-users mailing list
> > swift-users@swift.org
> > https://lists.swift.org/mailman/listinfo/swift-users
>
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Protocols, `mutating` and Value vs Reference Types.

2016-04-29 Thread Hooman Mehr via swift-users
Hi,

I am designing APIs that need to support both reference (class/object) and 
value types. I am running into restrictions of `mutating` keyword in my 
protocols and this is causing a lot of duplication of code. In order to 
understand what I mean please take a look at this gist 
. 

As you see, I have pairs of almost identical declarations: KeyValueStore vs 
KeyValueStoreObject, and AnyDictionaryStore vs AnyDictionaryStoreObject. This 
keeps rapidly growing as I am designing my APIs. Is there any sane way around 
this?

Thank you for your time,
Hooman___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Very slow compilation of `lazyvar` properties

2016-04-29 Thread Zachary Waldowski via swift-users
Tadeas Kriz via swift-users  swift.org> writes:

> 
> Hey everyone!
> I spent last few days trying to bring down compilation time of our iOS
> project, which has about 500 files and 50k lines (plus ~20 dependencies
> precompiled into frameworks by Carthage).
> 
> I stumbled upon this http://irace.me/swift-profiling and wrote myself a simple
> script that sums up all the times spent on various places in code. To my
> surprise, I found out that many of the lines that took the most of time to
> compile were simply `lazy var ` properties in classes. Is it unique to our
> project (I mean caused by misconfiguration) or do you guys see this as well?
> 
> Thanks!
> 
> Tadeas
> 
> 
> ___
> swift-users mailing list
> swift-users  swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
> 

I’ve identified this as well. It’s pretty severe in my current project, which is
of a similar size. Various sprinklings of “private”, “final”, and “@nonobjc”
all seem to have no positive effect. Using the self-calling closure version
seems to exacerbate the problem.

Zachary
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Stored Property, Externally Read-Only

2016-04-29 Thread Bob Davidson via swift-users
Great, thanks guys

On Fri, Apr 29, 2016 at 12:00 PM Nate Birkholz  wrote:

> That's correct.
>
> On Fri, Apr 29, 2016 at 8:52 AM, David Sweeris via swift-users <
> swift-users@swift.org> wrote:
>
>> Yep, declare it like this:
>> public private(set) var lastUpdated: NSDate?
>>
>> At least I’m pretty sure that’s the syntax. I don’t have Xcode in front
>> of me to double-check.
>>
>> HTH
>> - Dave Sweeris
>>
>> On Apr 29, 2016, at 9:52 AM, Bob Davidson via swift-users <
>> swift-users@swift.org> wrote:
>>
>> Hello,
>>
>> Does Swift have a syntax for allowing a stored property to be internally
>> changed by a class/structure, but external access is read-only?
>>
>> For example, my class/structure may have a date property such as
>> “lastUpdated”.  Outside code should have access to read the “lastUpdated”
>> property, but should not be allowed to change it.  Periodically, my class
>> may perform an “update” and would internally change the value of
>> “lastUpdated”.
>>
>> The only way I see to support this with a private property and a
>> computed, get-only property:
>>
>> private var internalLastUpdated: NSDate?
>> var lastUpdated: NSDate? { return internalLastUpdated }
>>
>> This there a better way?
>>
>> Thanks,
>> Bob Davidson
>>
>> ___
>> swift-users mailing list
>> swift-users@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
>>
>>
>>
>> ___
>> swift-users mailing list
>> swift-users@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-users
>>
>>
>
>
> --
> Nate Birkholz
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Stored Property, Externally Read-Only

2016-04-29 Thread Nate Birkholz via swift-users
That's correct.

On Fri, Apr 29, 2016 at 8:52 AM, David Sweeris via swift-users <
swift-users@swift.org> wrote:

> Yep, declare it like this:
> public private(set) var lastUpdated: NSDate?
>
> At least I’m pretty sure that’s the syntax. I don’t have Xcode in front of
> me to double-check.
>
> HTH
> - Dave Sweeris
>
> On Apr 29, 2016, at 9:52 AM, Bob Davidson via swift-users <
> swift-users@swift.org> wrote:
>
> Hello,
>
> Does Swift have a syntax for allowing a stored property to be internally
> changed by a class/structure, but external access is read-only?
>
> For example, my class/structure may have a date property such as
> “lastUpdated”.  Outside code should have access to read the “lastUpdated”
> property, but should not be allowed to change it.  Periodically, my class
> may perform an “update” and would internally change the value of
> “lastUpdated”.
>
> The only way I see to support this with a private property and a computed,
> get-only property:
>
> private var internalLastUpdated: NSDate?
> var lastUpdated: NSDate? { return internalLastUpdated }
>
> This there a better way?
>
> Thanks,
> Bob Davidson
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>


-- 
Nate Birkholz
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Stored Property, Externally Read-Only

2016-04-29 Thread David Sweeris via swift-users
Yep, declare it like this:
public private(set) var lastUpdated: NSDate?

At least I’m pretty sure that’s the syntax. I don’t have Xcode in front of me 
to double-check.

HTH
- Dave Sweeris

> On Apr 29, 2016, at 9:52 AM, Bob Davidson via swift-users 
>  wrote:
> 
> Hello,
> 
> Does Swift have a syntax for allowing a stored property to be internally 
> changed by a class/structure, but external access is read-only?
> 
> For example, my class/structure may have a date property such as 
> “lastUpdated”.  Outside code should have access to read the “lastUpdated” 
> property, but should not be allowed to change it.  Periodically, my class may 
> perform an “update” and would internally change the value of “lastUpdated”.
> 
> The only way I see to support this with a private property and a computed, 
> get-only property:
> 
>   private var internalLastUpdated: NSDate?
>   var lastUpdated: NSDate? { return internalLastUpdated }
> 
> This there a better way?
> 
> Thanks,
> Bob Davidson
> 
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Stored Property, Externally Read-Only

2016-04-29 Thread Bob Davidson via swift-users
Hello,

Does Swift have a syntax for allowing a stored property to be internally
changed by a class/structure, but external access is read-only?

For example, my class/structure may have a date property such as
“lastUpdated”.  Outside code should have access to read the “lastUpdated”
property, but should not be allowed to change it.  Periodically, my class
may perform an “update” and would internally change the value of
“lastUpdated”.

The only way I see to support this with a private property and a computed,
get-only property:

private var internalLastUpdated: NSDate?
var lastUpdated: NSDate? { return internalLastUpdated }

This there a better way?

Thanks,
Bob Davidson
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] make swift compiler to use the precompiled module files

2016-04-29 Thread Daniel Dunbar via swift-users
Clang will cache these automatically, can you give more details on exactly what 
you are seeing?

 - Daniel

> On Apr 28, 2016, at 10:50 PM, Ramakrishna Mallireddy via swift-users 
>  wrote:
> 
> I have these precompiled module files generated every-time I run the swift 
> compiler.
> 
> _Builtin_stddef_max_align_t-1LMTETLX3WNFT.pcm
> CFNetwork-1UTIO6DPB9R5P.pcm
> CoreFoundation-CF8BGN41VJ11.pcm
> CoreGraphics-3SDFP08OX46EF.pcm
> CoreImage-3SDFP08OX46EF.pcm
> Darwin-4F8STAM1KXDF.pcm
> Foundation-2LQ7EQYFLQOP.pcm
> ...etc
> 
> How can I make the swift compiler to use these cache rather than compiling 
> the libraries again.
> 
> Thanks
> Ramakrishna
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users