Re: [swift-users] module (de)-initialization

2016-12-21 Thread Joe Groff via swift-users
> On Dec 20, 2016, at 8:54 AM, Jens Alfke via swift-users > wrote: > > Also, AFAIK there is no mechanism in Swift (yet) to load or unload a module > at runtime, so a module load occurs when the program starts up, and an unload > occurs when the program exits. dlopen works fine, though the o

Re: [swift-users] module (de)-initialization

2016-12-20 Thread Jens Alfke via swift-users
Also, AFAIK there is no mechanism in Swift (yet) to load or unload a module at runtime, so a module load occurs when the program starts up, and an unload occurs when the program exits. So if your module really needs to do something to clean up, it could call the (C standard) function atexit()

Re: [swift-users] module (de)-initialization

2016-12-20 Thread Quinn "The Eskimo!" via swift-users
On 19 Dec 2016, at 08:37, Mr Bee via swift-users wrote: > 1. Is there any module initialization and deinitialization concept in Swift > (v.3)? No. For initialisation, the standard approach in Swift is to exploit the fact that globals are initialised lazily on first use. If you’re interested

Re: [swift-users] module (de)-initialization

2016-12-19 Thread Jens Alfke via swift-users
> On Dec 19, 2016, at 12:37 AM, Mr Bee via swift-users > wrote: > > Is there a way to print the 'i' of the let, and the 'i' of the loop, and the > 'i' of the var, from inside of the for loop? I know it's a bad practice, but > I'm just curious. No, there is no way of referring to them because

[swift-users] module (de)-initialization

2016-12-19 Thread Mr Bee via swift-users
Hi all, As I learn Swift, I got 2 questions here: 1. Is there any module initialization and deinitialization concept in Swift (v.3)? For example, upon loading a module, I want that module to do something before being utilized (initialization) or after being utilized (deinitialization). If there