Re: @property method needs ()

2014-11-24 Thread ketmar via Digitalmars-d-learn
On Mon, 24 Nov 2014 06:56:08 + Andre via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi, in following example the @property method needs the () otherwise compiler error for row 24 is thrown. I cannot judge, whether the compiler behaves correct or not. Kind regards

Re: @property method needs ()

2014-11-24 Thread via Digitalmars-d-learn
On Monday, 24 November 2014 at 08:35:08 UTC, ketmar via Digitalmars-d-learn wrote: On Mon, 24 Nov 2014 06:56:08 + Andre via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi, in following example the @property method needs the () otherwise compiler error for row 24 is

Re: print yyyy-mm-dd

2014-11-24 Thread Suliman via Digitalmars-d-learn
Is there any way to set separator? For example I want use '/' or ':'?

Re: print yyyy-mm-dd

2014-11-24 Thread Suliman via Digitalmars-d-learn
And could anybody explain me how the cast is work. How to understand which types to which may be casted?

Re: print yyyy-mm-dd

2014-11-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, November 24, 2014 10:33:16 Suliman via Digitalmars-d-learn wrote: Is there any way to set separator? For example I want use '/' or ':'? No. toISOString and toISOExtString support the ISO and Extended ISO formats from the ISO standard, and std.datetime does not currently support

Re: print yyyy-mm-dd

2014-11-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, November 24, 2014 10:38:55 Suliman via Digitalmars-d-learn wrote: And could anybody explain me how the cast is work. How to understand which types to which may be casted? Look at the documentation for opCast. That's how the casting is done. But what it comes down to is SysTime -

Re: @property method needs ()

2014-11-24 Thread Andre via Digitalmars-d-learn
Thanks a lot for the info. Kind regards André On Monday, 24 November 2014 at 09:26:16 UTC, Marc Schütz wrote: On Monday, 24 November 2014 at 08:35:08 UTC, ketmar via Digitalmars-d-learn wrote: a known thing. not sure if this is a known *bug* (seems that almost nobody cares). compiler is

projections in D

2014-11-24 Thread Ramon via Digitalmars-d-learn
what range/algorithm allows me to make projections from one sequence to another? that is, in C#, this is the Select method (http://msdn.microsoft.com/en-us/library/vstudio/bb548891%28v=vs.100%29.aspx) example in C#: class ProjectionWanted { public int field1 { get; set; } public int

Re: projections in D

2014-11-24 Thread bearophile via Digitalmars-d-learn
Ramon: example in C#: class ProjectionWanted { public int field1 { get; set; } public int field2 { get; set; } public int field3 { get; set; } } void Foo(ListProjectionWanted list) { var list_projected = list.Select(l = new { l.field1, l.field2 }); // list_projected elements now

Re: projections in D

2014-11-24 Thread Ramon via Digitalmars-d-learn
What is the difference between lazy and eager ranges? (I guess, the lazy one has not yet queried the elements)

Re: projections in D

2014-11-24 Thread bearophile via Digitalmars-d-learn
On Monday, 24 November 2014 at 15:44:02 UTC, Ramon wrote: What is the difference between lazy and eager ranges? (I guess, the lazy one has not yet queried the elements) The lazy returns a range that once iterated gives the results one at a time (so the function allocates no heap memory).

Re: Sum informations in file....

2014-11-24 Thread Suliman via Digitalmars-d-learn
I can't understand why foreach loop produce every line by line, while it's fuctional analog print lines on one string: foreach(f; file.byLine()) { writeln(f); } auto file = File(foo.txt,r); file .byLine() .writeln; file content: - first sring second string -

Re: Sum informations in file....

2014-11-24 Thread ketmar via Digitalmars-d-learn
On Mon, 24 Nov 2014 19:04:34 + Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I can't understand why foreach loop produce every line by line, while it's fuctional analog print lines on one string: the two samples are not the same, they doing completely different

Re: Sum informations in file....

2014-11-24 Thread Ali Çehreli via Digitalmars-d-learn
On 11/24/2014 11:04 AM, Suliman wrote: I can't understand why foreach loop produce every line by line, while it's fuctional analog print lines on one string: foreach(f; file.byLine()) { writeln(f); f is a char[] and writeln prints all strings as their contents i.e. first string is

Re: Sum informations in file....

2014-11-24 Thread Ali Çehreli via Digitalmars-d-learn
On 11/24/2014 11:30 AM, ketmar via Digitalmars-d-learn wrote: File.byLine returns *output* *range*. Although the range is used for outputting, it is still an InputRange. :) Ali

Re: Sum informations in file....

2014-11-24 Thread ketmar via Digitalmars-d-learn
On Mon, 24 Nov 2014 11:41:43 -0800 Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On 11/24/2014 11:30 AM, ketmar via Digitalmars-d-learn wrote: File.byLine returns *output* *range*. Although the range is used for outputting, it is still an InputRange. :) ah,

Re: Sum informations in file....

2014-11-24 Thread Rene Zwanenburg via Digitalmars-d-learn
On Monday, 24 November 2014 at 20:23:57 UTC, Suliman wrote: thanks! But how I can skip first line? My varian: auto lines = foo.txt.File .byLine .filter!(f=f[0] != f[0]); With 'drop' from std.range: auto lines = foo.txt.File .byLine

Re: Sum informations in file....

2014-11-24 Thread Suliman via Digitalmars-d-learn
Thanks! But is there any way to do it with std.algorithm? Can be skipOver used for it?

DerelictOrg and SDL_Mixer

2014-11-24 Thread torea via Digitalmars-d-learn
Hi all, I'm playing a bit with D and SDL using DerelictOrg on debian 6. I've installed SDL2, SDL_mixer2 and the latest packages DerelictUtil and DerelictSDL2. I can display some stuffs and interact with the keys. Now I'm trying to add music and sounds but each time I try to access a function

opEquals unsafe? Please tell me this isnt true...

2014-11-24 Thread Eric via Digitalmars-d-learn
@safe class Y { } @safe class X { } @safe class Z { int x; this() { if (typeid(X) == typeid(Y)) x = 1; // Compile Error else x = 2; } } void main() { new Z; } // test.d(19): Error: safe function 'test.Z.this' // cannot call system function 'object.opEquals'

Something between a scalar and an enum

2014-11-24 Thread bearophile via Digitalmars-d-learn
An enumeration contains a small number of distinct elements: enum Colors { red, green, yellow, brown } While an integral numeric value encodes a scalar: uint x; x = 120; x++; A sufficiently common pattern in my code is to have something intermediate: that has a small group of special

A nice D coding pattern

2014-11-24 Thread bearophile via Digitalmars-d-learn
In some D programs I'm using this coding pattern: struct Foo { // Instance fields here. @disable this(); this(in string[] data) pure @safe in { // Many pre-conditions here. } out(result) { // Some post-conditions here. } body { // ... }

Re: DerelictOrg and SDL_Mixer

2014-11-24 Thread Jack via Digitalmars-d-learn
On Monday, 24 November 2014 at 21:19:40 UTC, torea wrote: Hi all, I'm playing a bit with D and SDL using DerelictOrg on debian 6. I've installed SDL2, SDL_mixer2 and the latest packages DerelictUtil and DerelictSDL2. I can display some stuffs and interact with the keys. Now I'm trying to add

Re: DerelictOrg and SDL_Mixer

2014-11-24 Thread torea via Digitalmars-d-learn
On Monday, 24 November 2014 at 23:27:58 UTC, Jack wrote: It's a common error but did you load the Mixer and SDL libraries? DerelictSDL2Mixer.load(); DerelictSDL2.load(); And some code or output from gdb would be most helpful. Oh.. I didn't know about the DerelictSDL2Mixer.load()! I thought

Re: opEquals unsafe? Please tell me this isnt true...

2014-11-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, November 24, 2014 22:12:08 Eric via Digitalmars-d-learn wrote: @safe class Y { } @safe class X { } @safe class Z { int x; this() { if (typeid(X) == typeid(Y)) x = 1; // Compile Error else x = 2; } } void main() { new Z; } //

Re: opEquals unsafe? Please tell me this isnt true...

2014-11-24 Thread Eric via Digitalmars-d-learn
On Tuesday, 25 November 2014 at 02:48:43 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: On Monday, November 24, 2014 22:12:08 Eric via Digitalmars-d-learn wrote: @safe class Y { } @safe class X { } @safe class Z { int x; this() { if (typeid(X) == typeid(Y)) x =

Re: opEquals unsafe? Please tell me this isnt true...

2014-11-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 25 November 2014 at 03:42:50 UTC, Eric wrote: I'm finding it really hard to write robust classes in D due to all the problems with Object. I wish Object didn't have any methods. One thing I do is kinda act as if it didn't and make my own interfaces instead.