A little of coordination for Rosettacode
Ali Çehreli
acehreli at yahoo.com
Wed Feb 26 06:54:04 PST 2014
On 02/26/2014 03:24 AM, bearophile wrote:
> Ali Çehreli:
>
>> Improve at will! :p
>
> I will mostly just uniform its formatting to all the other Rosettacode
> entries, shorten the lines to 72 chars, etc.
>
>
>> synchronized {
>> // Switch to the next printer
>> printers = printers[1..$];
>> }
>
> This doesn't work:
>
> printers.popFront();
I've noticed that too. ;) And I am not sure why the slicing syntax works
because the 'printers' member is still shared then.
>> void print(string line)
>> {
>> enforce(ink != 0, new OutOfInk);
>> writefln("%s: %s", id, line);
>> --ink;
>> }
>> }
>>
>> struct PrinterRendezvous
>> ...
>> try {
>> synchronized {
>> (cast(Printer)printers.front).print(lines.front);
>> }
>
> It it a good idea to define Printer.print like this to remove that cast?
>
> void print(string line) shared
I had that at one point but then I could not convince myself that
Printer.print should be a shared member function. How do we know at
design time that every Printer would be shared? I thought that Printer
should be as simple as possible and that shared should be handled by a
higher-level code. Then the code became ugly like that. :)
I need more experience. :-/
> Bye,
> bearophile
Ali
More information about the Digitalmars-d-learn
mailing list