Re: Removing an object from a range

2010-12-12 Thread bearophile
Jonathan M Davis: > They're both based on C++ (though C# is also heavily based on Java which is > based on C++). D probably does take some features from C# (such as > delegates), > but D has taken features from a number of different languages. I doubt that > anything in C# is based on anything

Re: Removing an object from a range

2010-12-12 Thread Andrej Mitrovic
On 12/13/10, Matthias Walter wrote: > On 12/12/2010 08:43 PM, Andrej M. wrote: >> I can't seem to find an easy remove method in std.algorithm that takes an >> object and a range (an array in this case) and removes any matches from >> the range. I'm using this snippet for now: >> >> private Drawing

Re: Removing an object from a range

2010-12-12 Thread Matthias Walter
On 12/12/2010 08:43 PM, Andrej M. wrote: > I can't seem to find an easy remove method in std.algorithm that takes an > object and a range (an array in this case) and removes any matches from the > range. I'm using this snippet for now: > > private DrawingElement[] elements; > > public override vo

Re: Removing an object from a range

2010-12-12 Thread Jonathan M Davis
On Sunday 12 December 2010 18:35:38 Andrej Mitrovic wrote: > On a side note I have to admit I've never programmed in C# before, but > I don't seem to have much trouble understanding it. From the looks of > it, the two languages borrow a lot from each other, and have very > similar syntax. They're

Re: Removing an object from a range

2010-12-12 Thread Andrej Mitrovic
On a side note I have to admit I've never programmed in C# before, but I don't seem to have much trouble understanding it. From the looks of it, the two languages borrow a lot from each other, and have very similar syntax. On 12/13/10, Andrej Mitrovic wrote: > On 12/13/10, Jonathan M Davis wrote

Re: Removing an object from a range

2010-12-12 Thread Andrej Mitrovic
On 12/13/10, Jonathan M Davis wrote: > I created an enhancement request for it: http://is.gd/iDSqj > > - Jonathan M Davis > Thanks!

Re: Removing an object from a range

2010-12-12 Thread Jonathan M Davis
On Sunday 12 December 2010 17:43:12 Andrej M. wrote: > I can't seem to find an easy remove method in std.algorithm that takes an > object and a range (an array in this case) and removes any matches from > the range. I'm using this snippet for now: > > private DrawingElement[] elements; > > public

Removing an object from a range

2010-12-12 Thread Andrej M.
I can't seem to find an easy remove method in std.algorithm that takes an object and a range (an array in this case) and removes any matches from the range. I'm using this snippet for now: private DrawingElement[] elements; public override void Remove(DrawingElement d) { foreach (i, child;

Re: _indexed_ iteration using opApply or range

2010-12-12 Thread Simen kjaeraas
spir wrote: (1) In my case, I do not want to modify the range (actually the private collection), because the type is not only about beeing a range (~ provide iteration). So that I defined the range methods, using a private 'rangeIndex slot', as (the type also maintains a 'length' slot):

Re: _indexed_ iteration using opApply or range

2010-12-12 Thread spir
On Sun, 12 Dec 2010 21:15:00 +0100 "Simen kjaeraas" wrote: > The trick to ranges is that they modify themselves. For a simple array > wrapper > range this may be a way: > > struct wrapper( T ) { > T[] data; > void popFront( ) { > data = data[1..$]; > } > ref T fron

Re: _indexed_ iteration using opApply or range

2010-12-12 Thread Jonathan M Davis
On Sunday 12 December 2010 12:15:00 Simen kjaeraas wrote: > spir wrote: > > Hello, > > > > Had a nice time figuring out how to let opApply allow index iteration > > > > like: > > foreach (i, x ; collection) {} > > > > Finally managed to do it adding 'i' everywhere: > > > > struct S1 { > >

Re: overzealous pointsTo()

2010-12-12 Thread Nick Voronin
On Sun, 12 Dec 2010 22:36:03 +0300, Nick Voronin wrote: pointsTo() tries to check every member of anonymous union inside struct. alias this makes a passable workaround though. (I hope) :) union U { int i; string s; } struct S3 { int type; U u; alias

Re: _indexed_ iteration using opApply or range

2010-12-12 Thread Simen kjaeraas
spir wrote: Hello, Had a nice time figuring out how to let opApply allow index iteration like: foreach (i, x ; collection) {} Finally managed to do it adding 'i' everywhere: struct S1 { private int[] elements = []; int opApply (int delegate (ref uint, ref int) block) {

Re: _indexed_ iteration using opApply or range -- PS

2010-12-12 Thread Simen kjaeraas
spir wrote: PS: Also tried to make iteration work by defining slice "with no argument" (coll[]) only, like indicated in TDPL p.381. But could not manage to do it. The point of coll[] is that a collection may not want to define the range primitives itself, but rather expose a special range

Re: _indexed_ iteration using opApply or range -- PS

2010-12-12 Thread spir
On Sun, 12 Dec 2010 20:47:04 +0100 spir wrote: > Hello, > > Had a nice time figuring out how to let opApply allow index iteration like: > foreach (i, x ; collection) {} > Finally managed to do it adding 'i' everywhere: > > struct S1 { > private int[] elements = []; > int opApply (in

_indexed_ iteration using opApply or range

2010-12-12 Thread spir
Hello, Had a nice time figuring out how to let opApply allow index iteration like: foreach (i, x ; collection) {} Finally managed to do it adding 'i' everywhere: struct S1 { private int[] elements = []; int opApply (int delegate (ref uint, ref int) block) { foreach (uint i, in

overzealous pointsTo()

2010-12-12 Thread Nick Voronin
pointsTo() tries to check every member of anonymous union inside struct. import std.exception; union U { int i; string s; } struct S1 { int type; U u; } struct S2 { int type; union { int i; string s; } } v

Re: Why immutable ?

2010-12-12 Thread Jonathan M Davis
On Sunday 12 December 2010 08:03:57 Simen kjaeraas wrote: > Eyyub wrote: > > I recently upgraded to the D 2, and i would like understand for which > > reason they are the immutable keyword ! > > immutable means 'this data cannot change'. It is different from const in > that the latter means 'I ca

Re: Problems with std.traits.isSafe & SafeD

2010-12-12 Thread Jonathan M Davis
On Sunday 12 December 2010 05:55:11 Johannes Pfau wrote: > Hmm, next problem with safe D. > > unittest > { > @safe int tf(int i){return i;} > bool a = isSafe!(tf); > assert(a == true); > static assert(isSafe!(tf)); > static assert(isSafe!(typeof(&tf))); > } > > All three

Re: cannot make opDollar work

2010-12-12 Thread Andrej Mitrovic
I think this might have been reported: http://d.puremagic.com/issues/show_bug.cgi?id=3474 On 12/12/10, spir wrote: > Hello, > > Test case: > > struct S { > int[] ints; > int opDollar () {return this.ints.length;} > int opIndex (int i) {return this.ints[i];} > int[] opSlice (int i

cannot make opDollar work

2010-12-12 Thread spir
Hello, Test case: struct S { int[] ints; int opDollar () {return this.ints.length;} int opIndex (int i) {return this.ints[i];} int[] opSlice (int i, int j) {return this.ints[i..j];} } unittest { S s = S([3,2,1]); // _link_ error on each line: // Error: undefined ident

Re: Interface inheritance

2010-12-12 Thread Mandeep Singh Brar
But that idea would not work in APIs like JDBC for example (something i was trying to immitate partly). PreparedStatement has method setInt(int, int) while CallableStatement has method setInt(string,int). It is not possible to compile CallableStatement.setInt(int,int) without casting or putting in

Re: XSDs?

2010-12-12 Thread Kagamin
Tom Wrote: > Does D2 have something to check XML against XSD schemas? No.

Re: Why immutable ?

2010-12-12 Thread Simen kjaeraas
Eyyub wrote: I recently upgraded to the D 2, and i would like understand for which reason they are the immutable keyword ! immutable means 'this data cannot change'. It is different from const in that the latter means 'I cannot change this data (but someone else may change it from under my f

Why immutable ?

2010-12-12 Thread Eyyub
I recently upgraded to the D 2, and i would like understand for which reason they are the immutable keyword ! Thx

Problems with std.traits.isSafe & SafeD

2010-12-12 Thread Johannes Pfau
Hmm, next problem with safe D. unittest { @safe int tf(int i){return i;} bool a = isSafe!(tf); assert(a == true); static assert(isSafe!(tf)); static assert(isSafe!(typeof(&tf))); } All three asserts fail! Even the example from std.traits doesn't work for me, isSafe always r

Re: Unqual for @safe @system and @trusted

2010-12-12 Thread Johannes Pfau
Am 11.12.2010, 19:33 Uhr, schrieb bearophile : Johannes Pfau: Is there something like Unqual that can remove the safety attributes from a type? In such cases we have to ask what's your use case/purpose. Isn't @trusted enough? Bye, bearophile Well, for my signal implementation (Latest

Re: Interface inheritance

2010-12-12 Thread Adam Burton
Mandeep Singh Brar wrote: > I just posted a bug on the bugs list about problems in compiling the > following code using dmd, but realized that there might be some > inheritance feature that i might now be aware of. Can you please let me > know if i am missing something in the below code. > > impo

Re: function pointers in D2

2010-12-12 Thread Daniel Murphy
"Christopher Nicholson-Sauls" wrote in message news:ie28aa$18b...@digitalmars.com... > This > surprises me, and certainly has to be a bug. > http://d.puremagic.com/issues/show_bug.cgi?id=3797

Interface inheritance

2010-12-12 Thread Mandeep Singh Brar
I just posted a bug on the bugs list about problems in compiling the following code using dmd, but realized that there might be some inheritance feature that i might now be aware of. Can you please let me know if i am missing something in the below code. import std.stdio; interface A { p

Re: function pointers in D2

2010-12-12 Thread Christopher Nicholson-Sauls
On 12/12/10 03:54, Nrgyzer wrote: > Hey guys, > > I've used D1 in the past and D1 seems to check for correct function > pointers. In D2 I can pass any function pointer to an function, for > example: > > ... > void example(void function(int, int) fp) { > ... > } > > ... > void callback1(int x, in

function pointers in D2

2010-12-12 Thread Nrgyzer
Hey guys, I've used D1 in the past and D1 seems to check for correct function pointers. In D2 I can pass any function pointer to an function, for example: ... void example(void function(int, int) fp) { ... } ... void callback1(int x, int y) { } void callback2() { } ... example(&callback1); // W