Pure functions in D

Bruce Adams tortoise_74 at yeah.who.co.uk
Thu Sep 25 01:15:00 PDT 2008


On Wed, 24 Sep 2008 13:15:12 +0100, Leandro Lucarella <llucax at gmail.com>  
wrote:

> downs, el 24 de septiembre a las 08:52 me escribiste:
>> Denis Koroskin wrote:
>> > On Tue, 23 Sep 2008 02:24:10 +0400, Walter Bright
>> > <newshound1 at digitalmars.com> wrote:
>> >
>> >> bearophile wrote:
>> >>>> They can be hot swapped (meaning replaced at runtime), because they
>> >>>> do not rely on any global initialization or termination state.<
>> >>>  This sounds true and interesting, but what can it be used/useful  
>> for?
>> >>
>> >> I've heard mention many times that languages like Erlang allow hot
>> >> swapping meaning the software can be upgraded without bringing the
>> >> system to a halt first.
>> >
>> > Yes, Java has some support of hot-swapping, too.
>> >
>> > Imagine you have a MMORPG server. Applying a patch or adding some
>> > additional content is a daily event. Doing so without disconnecting  
>> the
>> > people (especially if there are thousands of player online) is  
>> desirable
>> > but hardly available in C/C++.
>>
>> I did that with an IRC bot a while back.
>>
>> Just build a new executable, halt all your running tasks, dump the  
>> system state to a file (*including socket handles*), use the exec  
>> system call to replace the process with the new executable, and read  
>> the system state back, replacing handles as you go.
>>
>> No dropped connections.
>
> Using dynamic libraries with dlopen can be useful for hot-swapping too.
>

Also take a look at the purple book "Advanced C++ Programming" by Coplien.



More information about the Digitalmars-d mailing list