Re: Derelict2 openGL3 issues

2012-04-24 Thread Denis Shelomovskij
One day I'll finish my OpenGL wrapper for D. It will give you better abilities in creating OpenGL 3 contexts than most C++ frameworks (SDL, GLFW etc.) and, I hope, will get rid of passing pointers to functions. It will be done soon after I'll finish Scintilla wrapper for D. And it will be

Re: Stack overflow / recursive expansion with alias this

2012-04-24 Thread Namespace
Hm, doesn't anybody know anything about it?

Re: Stack overflow / recursive expansion with alias this

2012-04-24 Thread Timon Gehr
On 04/23/2012 11:29 PM, Namespace wrote: I have this code: ... T _get() { return this._value; } const(T) _get() const { return this._value; } You missed the 'immutable' and 'inout cases. Just use inout(T) _get() inout { return _value; } instead of the

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-24 Thread Regan Heath
On Mon, 23 Apr 2012 16:43:20 +0100, Steven Schveighoffer schvei...@yahoo.com wrote: While dealing with unicode in my std.stream rewrite, I've found that hand-decoding dchars is way faster than using library calls. After watching Andrei's talk on generic and generative programming I have

Re: Range of random numbers

2012-04-24 Thread Christophe
bearophile , dans le message (digitalmars.D.learn:35108), a écrit : What about (untested): auto uniformRange(T1 lower, T2 upper) { return count().map!(_ = uniform(lower, upper))(); } That looks like a workarround, not meaningful code. How about return repeat(_ =uniform(lower,

Why has base class protection been deprecated?

2012-04-24 Thread David Bryant
With the dmd 2.059 I have started getting the error 'use of base class protection is deprecated' when I try to implement an interface with private visibility, ie: interface Interface { } class Class : private Interface { } $ dmd test.d test.d(4): use of base class protection is

Re: Why has base class protection been deprecated?

2012-04-24 Thread Don Clugston
On 24/04/12 14:22, David Bryant wrote: With the dmd 2.059 I have started getting the error 'use of base class protection is deprecated' when I try to implement an interface with private visibility, ie: interface Interface { } class Class : private Interface { } $ dmd test.d test.d(4): use of

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-24 Thread Marco Leise
Am Sat, 14 Apr 2012 19:31:40 -0700 schrieb Jonathan M Davis jmdavisp...@gmx.com: On Sunday, April 15, 2012 04:21:09 Joseph Rushton Wakeling wrote: On 14/04/12 23:03, q66 wrote: He also uses a class. And -noboundscheck should be automatically induced by -release. ... but the

Re: Stack overflow / recursive expansion with alias this

2012-04-24 Thread Namespace
You missed the 'immutable' and 'inout cases. Just use inout(T) _get() inout { return _value; } instead of the two declarations you have. Oh, thanks a lot, i'm forgetting this often. ... And therefore i get the same error, as if i wrote return NotNull!(Foo)(this); instead of return

Re: Why has base class protection been deprecated?

2012-04-24 Thread Don Clugston
On 24/04/12 15:29, David Bryant wrote: Because it doesn't make sense. All classes are derived from Object. That _has_ to be public, otherwise things like == wouldn't work. Does the same apply for interfaces? I'm specifically implementing an interface with non-public visibility. This

Re: Range of random numbers

2012-04-24 Thread bearophile
trav...@phare.normalesup.org: That looks like a workarround, not meaningful code. It wasn't terrible code :-) How about return repeat(_ =uniform(lower, upper)).map!(x = x())(); ? Why don't you write a little benchmark to compare the performance of the two versions? Using

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-24 Thread Marco Leise
Am Sat, 14 Apr 2012 21:05:36 +0200 schrieb ReneSac renedu...@yahoo.com.br: I have this simple binary arithmetic coder in C++ by Mahoney and translated to D by Maffi. I added notrow, final and pure and GC.disable where it was possible, but that didn't made much difference. Adding const to

Re: Why has base class protection been deprecated?

2012-04-24 Thread David Bryant
On 04/24/2012 11:07 PM, Don Clugston wrote: On 24/04/12 15:29, David Bryant wrote: Because it doesn't make sense. All classes are derived from Object. That _has_ to be public, otherwise things like == wouldn't work. Does the same apply for interfaces? I'm specifically implementing an

Re: Why has base class protection been deprecated?

2012-04-24 Thread David Bryant
On 04/24/2012 11:47 PM, David Bryant wrote: On 04/24/2012 11:07 PM, Don Clugston wrote: On 24/04/12 15:29, David Bryant wrote: Because it doesn't make sense. All classes are derived from Object. That _has_ to be public, otherwise things like == wouldn't work. Does the same apply for

Forcing static foreach

2012-04-24 Thread Robert Clipsham
Is there anyway to force a static foreach to occur? template TT(T...) { alias T TT; } void main() { // This works foreach(s; TT!(a, b, c)) { mixin(`int ` ~ s ~ `;`); } enum foo = TT!(a, b, c); // This fails foreach(s; foo) { mixin(`int ` ~

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-24 Thread Steven Schveighoffer
On Tuesday, 24 April 2012 at 11:24:44 UTC, Regan Heath wrote: On Mon, 23 Apr 2012 16:43:20 +0100, Steven Schveighoffer schvei...@yahoo.com wrote: While dealing with unicode in my std.stream rewrite, I've found that hand-decoding dchars is way faster than using library calls. After watching

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-24 Thread Steven Schveighoffer
On Tuesday, 24 April 2012 at 14:54:48 UTC, Steven Schveighoffer wrote: On Tuesday, 24 April 2012 at 11:24:44 UTC, Regan Heath wrote: After watching Andrei's talk on generic and generative programming I have to ask, which routines are you avoiding .. it seems we need to make them as good as the

Re: Forcing static foreach

2012-04-24 Thread David
Am 24.04.2012 16:34, schrieb Robert Clipsham: enum foo = TT!(a, b, c); alias TT!(a, b, c) foo; btw. there is std.typecons : TypeTuple with helpers (like staticMap)

Re: Nested RegEx

2012-04-24 Thread nrgyzer
== Auszug aus Dmitry Olshansky (dmitry.o...@gmail.com)'s Artikel On 21.04.2012 22:46, H. S. Teoh wrote: On Sat, Apr 21, 2012 at 09:41:18PM +0400, Dmitry Olshansky wrote: On 21.04.2012 21:24, nrgyzer wrote: Hi guys, I'm trying to use std.regex to parse a string like the following:

Re: Keyword to avoid not null references

2012-04-24 Thread Namespace
After i'm sure, that this is a bug: Great work again. If this bug will be fixed soon or someone can help me to find a workaround, then NotNull would be exactly what I always wanted.

Object Serialization?

2012-04-24 Thread dcoder
Hello. I'm probably not looking hard enough, but Do we have any standard d-library for serializing an object/object tree into -for example- an xml file? thanks.

Re: Object Serialization?

2012-04-24 Thread David Nadlinger
On Tuesday, 24 April 2012 at 16:42:19 UTC, dcoder wrote: I'm probably not looking hard enough, but Do we have any standard d-library for serializing an object/object tree into -for example- an xml file? There is no standard library support yet, but you might want to look at Orange (full

Re: Why has base class protection been deprecated?

2012-04-24 Thread David Nadlinger
On Tuesday, 24 April 2012 at 12:22:14 UTC, David Bryant wrote: This bothers me for two reasons: firstly it's not a base class, and secondly, it's a standard OO pattern of mine. What's up with this? Generally (and slightly inaccurately) speaking, D follows the Java model for inheritance

Re: Stack overflow / recursive expansion with alias this

2012-04-24 Thread Namespace
... And therefore i get the same error, as if i wrote return NotNull!(Foo)(this); instead of return assumeNotNull(this);, in the _convert method of NotNull. The Output is Stack overflow. I think that comes from recursive calls which fills the stack? Is that a bug? Yes. I found nothing

How to pass list of strings as compile-time parameters?

2012-04-24 Thread H. S. Teoh
I'm trying to write a template function for doing member-wise comparisons between two objects, with an optional list of members to ignore. But I can't seem to figure out the syntax for passing a list of strings (or an AA of strings) to the function? I tried this: bool

Re: How to pass list of strings as compile-time parameters?

2012-04-24 Thread Trass3r
bool compareByMemb(string[] ignores, T)(T obj1, T obj2) { foreach (name; __traits(getAllMembers, T)) { ... } In this particular case you could try foo(T, U...)(T obj1, T obj2, U ignores)

Re: How to pass list of strings as compile-time parameters?

2012-04-24 Thread H. S. Teoh
On Tue, Apr 24, 2012 at 07:39:42PM +0200, Trass3r wrote: bool compareByMemb(string[] ignores, T)(T obj1, T obj2) { foreach (name; __traits(getAllMembers, T)) { ... } In this particular case you could try foo(T, U...)(T obj1, T obj2, U

Re: How to pass list of strings as compile-time parameters?

2012-04-24 Thread H. S. Teoh
On Tue, Apr 24, 2012 at 10:47:53AM -0700, H. S. Teoh wrote: On Tue, Apr 24, 2012 at 07:39:42PM +0200, Trass3r wrote: bool compareByMemb(string[] ignores, T)(T obj1, T obj2) { foreach (name; __traits(getAllMembers, T)) { ... } In this

Re: How to pass list of strings as compile-time parameters?

2012-04-24 Thread Timon Gehr
On 04/24/2012 07:37 PM, H. S. Teoh wrote: I'm trying to write a template function for doing member-wise comparisons between two objects, with an optional list of members to ignore. But I can't seem to figure out the syntax for passing a list of strings (or an AA of strings) to the function? I

Re: How to pass list of strings as compile-time parameters?

2012-04-24 Thread H. S. Teoh
On Tue, Apr 24, 2012 at 08:03:07PM +0200, Timon Gehr wrote: On 04/24/2012 07:37 PM, H. S. Teoh wrote: I'm trying to write a template function for doing member-wise comparisons between two objects, with an optional list of members to ignore. But I can't seem to figure out the syntax for passing

Recommended way to access numeric_limits epsilon()

2012-04-24 Thread Timo Westkämper
What is the recommended way to access the equivalent of numeric_limits epsilon() in D? I am searching especially for the double version. http://www.cplusplus.com/reference/std/limits/numeric_limits/

Re: Recommended way to access numeric_limits epsilon()

2012-04-24 Thread H. S. Teoh
On Tue, Apr 24, 2012 at 08:36:34PM +0200, digitalmars-d-learn-boun...@puremagic.com wrote: What is the recommended way to access the equivalent of numeric_limits epsilon() in D? I am searching especially for the double version. http://www.cplusplus.com/reference/std/limits/numeric_limits/

Re: Object Serialization?

2012-04-24 Thread Jacob Carlborg
On 2012-04-24 18:42, dcoder wrote: Hello. I'm probably not looking hard enough, but Do we have any standard d-library for serializing an object/object tree into -for example- an xml file? thanks. You can have a look at Orange: https://github.com/jacob-carlborg/orange Tutorials:

Re: Recommended way to access numeric_limits epsilon()

2012-04-24 Thread Timo Westkämper
On Tuesday, 24 April 2012 at 18:48:15 UTC, H. S. Teoh wrote: On Tue, Apr 24, 2012 at 08:36:34PM +0200, digitalmars-d-learn-boun...@puremagic.com wrote: What is the recommended way to access the equivalent of numeric_limits epsilon() in D? I am searching especially for the double version.

Re: Stack overflow / recursive expansion with alias this

2012-04-24 Thread Timon Gehr
On 04/24/2012 07:09 PM, Namespace wrote: ... And therefore i get the same error, as if i wrote return NotNull!(Foo)(this); instead of return assumeNotNull(this);, in the _convert method of NotNull. The Output is Stack overflow. I think that comes from recursive calls which fills the stack? Is

Re: Stack overflow / recursive expansion with alias this

2012-04-24 Thread Namespace
On Tuesday, 24 April 2012 at 19:34:26 UTC, Timon Gehr wrote: On 04/24/2012 07:09 PM, Namespace wrote: ... And therefore i get the same error, as if i wrote return NotNull!(Foo)(this); instead of return assumeNotNull(this);, in the _convert method of NotNull. The Output is Stack overflow. I

Re: avoid toLower in std.algorithm.sort compare alias

2012-04-24 Thread Jonathan M Davis
On Tuesday, April 24, 2012 12:24:44 Regan Heath wrote: On Mon, 23 Apr 2012 16:43:20 +0100, Steven Schveighoffer schvei...@yahoo.com wrote: While dealing with unicode in my std.stream rewrite, I've found that hand-decoding dchars is way faster than using library calls. After watching

Re: Object Serialization?

2012-04-24 Thread sclytrack
On 04/24/2012 08:50 PM, Jacob Carlborg wrote: On 2012-04-24 18:42, dcoder wrote: Hello. I'm probably not looking hard enough, but Do we have any standard d-library for serializing an object/object tree into -for example- an xml file? thanks. You can have a look at Orange:

Extending std.format.formattedRead

2012-04-24 Thread H. S. Teoh
What's the correct way of implementing formattedRead support for user-defined types? I tried overloading the unformatValue() template, but for some reason the compiler doesn't seem to be picking it up. T -- People walk. Computers run.

Re: D 50% slower than C++. What I'm doing wrong?

2012-04-24 Thread bearophile
Marco Leise: I ported fast paq8 (fp8) to D, and with some careful D-ification and optimization it runs a bit faster than the original C program when compiled with the GCC on Linux x86_64, Core 2 Duo. I guess you mean GDC. With DMD, even if you are a good D programmer, it's not easy to beat

Re: Range of random numbers

2012-04-24 Thread Joseph Rushton Wakeling
On 24/04/12 13:50, Christophe wrote: We could also use a template to make a range out of a delegate and avoid this workarround... What I'd _really_ like to see is something which would allow you to generate a range of random numbers with an expression like, auto rr =

Re: Extending std.format.formattedRead

2012-04-24 Thread Kenji Hara
On Tuesday, 24 April 2012 at 21:50:03 UTC, H. S. Teoh wrote: What's the correct way of implementing formattedRead support for user-defined types? I tried overloading the unformatValue() template, but for some reason the compiler doesn't seem to be picking it up. Unfortunately, there is not

Re: Extending std.format.formattedRead

2012-04-24 Thread bearophile
H. S. Teoh: What's the correct way of implementing formattedRead support for user-defined types? I tried overloading the unformatValue() template, but for some reason the compiler doesn't seem to be picking it up. Maybe do you want to open this discussion in the main D newsgroup? I think

No implicitly convert derived ptr to base ptr?

2012-04-24 Thread Nick Sabalausky
The compiler rejects this: class Base {} class Derived : Base {} void main() { Base*basePtr; Derived* derivedPtr; basePtr = derivedPtr; // ERROR } Is that really correct that it shouldn't be allowed?