Re: Partial specialisation: howto? (in the right news group this time. *sigh*)

2009-05-17 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jason House wrote: div0 wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Thanks Simen, That's nicer than the chained static ifs. Is there anyway to get rid of the enum though? Using the enum is a pain as it means you have to edit

Re: Applying const to an object but not the container (D 2.0)

2009-05-24 Thread div0
Burton Radons wrote: I'm writing an XML class. There are two tests for this class, isAncestorOf and isDescendantOf, that are implemented in terms of one another. They're both const, and look like this: class Node { Node parentNode; /// ... /// Return whether this is

Re: [SO] Modifing local class instance in pure function

2009-06-18 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jesse Phillips wrote: http://stackoverflow.com/questions/1008803/how-to-use-pure-in-d-2-0 class TestPure { string[] msg; void addMsg( string s ) { msg ~= s; } }; pure TestPure run2() { TestPure t = new TestPure();

Re: At compile time

2009-08-05 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 bearophile wrote: D2 is now able to execute math functions (sin, cos, sqrt, etc) at compile time. This little C++ program compiles correctly with G++: // C++ code #include math.h #include stdio.h struct V3 { double x, y, z;

Re: CRTP in D?

2009-08-19 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 downs wrote: bearophile wrote: I don't know much C++. Can CRTP be used in D1 too, to improve the performance of some D1 code? http://en.wikipedia.org/wiki/Curiously_Recurring_Template_Pattern Bye, bearophile We have this, except we call it

Re: CRTP in D?

2009-08-19 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bill Baxter wrote: On Wed, Aug 19, 2009 at 10:32 AM, div0d...@users.sourceforge.net wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 downs wrote: bearophile wrote: I don't know much C++. Can CRTP be used in D1 too, to improve the

Re: CRTP in D?

2009-08-19 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bill Baxter wrote: On Wed, Aug 19, 2009 at 10:32 AM, div0d...@users.sourceforge.net wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 downs wrote: bearophile wrote: I don't know much C++. Can CRTP be used in D1 too, to improve the

Re: CRTP in D?

2009-08-20 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 John C wrote: div0 Wrote: While we're on the subject, is it possible to mixin in a tuple? Doesn't seem like you can... class C(M...) { mixin M; } Doesn't work. import std.typetuple; class C(M...) { mixin TypeTuple!(M

Re: CRTP in D?

2009-08-20 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bill Baxter wrote: On Thu, Aug 20, 2009 at 12:15 PM, div0d...@users.sourceforge.net wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 John C wrote: div0 Wrote: While we're on the subject, is it possible to mixin in a tuple? Doesn't seem

Re: Template mixins: Why is the decision to mixin made at the call site?

2009-08-21 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Chad J wrote: Regarding template mixins, I'm curious, why is the decision to mixin a template made at the call site and not at the declaration of the template/mixin? In other words, why do we write template foo() {

Re: Template mixins: Why is the decision to mixin made at the call site?

2009-08-21 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jarrett Billingsley wrote: On Fri, Aug 21, 2009 at 1:36 PM, div0d...@users.sourceforge.net wrote: That's what he's suggesting, and it does make sense. When you write a template, *either* it's meant to be used as a mixin, *or* it's meant to be

Re: Template mixins: Why is the decision to mixin made at the call site?

2009-08-21 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ary Borenszweig wrote: div0 wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jarrett Billingsley wrote: On Fri, Aug 21, 2009 at 1:36 PM, div0d...@users.sourceforge.net wrote: That's what he's suggesting, and it does make sense. When you

Re: wchar* question

2009-09-03 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Max Samukha wrote: Sam Hu wrote: Given below code(Win32 SDK): int /*LRESULT*/ wndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch(msg) { case WM_LBUTTONDOWN: { wchar* szFileName=cast(wchar*)(new wchar[1024]);//

Re: Trying to get DMD bundled with libs

2009-09-05 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Joel Christensen wrote: I noticed you can get DMD bundled with various libraries. I found you had to login to another web site, but the registery page has 3 must fill in textbox's that are crazy. Where's that? AFAIK nobody has permission to

Re: A writefln issue or a Thread issue?

2009-09-05 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Sam Hu wrote: Fyi: 1.with DMD2032 under windows xp; 2.Tried printf,write,writeln,writef,writefln but all the same result:blank DOS console under current exe path; 3.In c/c++ it opens total 2 DOS windows which works properly: the main one and

Re: Trying to get DMD bundled with libs

2009-09-05 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jarrett Billingsley wrote: On Sat, Sep 5, 2009 at 6:53 AM, div0d...@users.sourceforge.net wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Joel Christensen wrote: I noticed you can get DMD bundled with various libraries. I found you had to

Re: delegate !is null

2009-09-08 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Saaa wrote: The problem lies more in that I'd like to point to something which is not there yet. In the code 'c.method()' is not there yet, as c is null. Maybe I should create a dummy object for c to point to in stead of null ? That way I point

Re: Cannot convert of type HANDLE to HANDLE

2009-09-08 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Sam Hu wrote: Under DMD 2.032+Window Xp: Can I use HMODULE LoadLibraryEx( LPCTSTR lpFileName, // file name of module HANDLE hFile, // reserved, must be NULL DWORD dwFlags // entry-point execution option ); in

Re: delegate !is null

2009-09-08 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Saaa wrote: The only way I've found so far to do static binding like you are talking about is using string mixins. I need to rethink stuff a bit, but mixins might be the solution. My port of Atl's window classes uses a MFC like message map:

Re: Using OpenGL (custom port)

2009-10-06 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 David Butler wrote: Is there a difference between a pointer to a D array and an int* in C? How do I convert between the two? Am I even looking in the right place? Thanks for any help! -Dave Butler There's nothing wrong with your int array.

Re: HWND is NULL but GetLastError returns 0x00

2009-10-16 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Zarathustra wrote: I have the problem with the following code in D2: CreateWindowEx returns NULL but I haven't got idea why? snip That's because your are not properly processing all of the messages that are involved in window creation. See:

Re: some questions about D

2009-10-22 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 bearophile wrote: Luis P. Mendes: I'm about to begin a project on artificial intelligence, decision trees and some other algorithmic stuff that needs runtime and development speed. Very good, D sounds fit for such kind of code. If you need

Re: Help needed to actualizing allegro bindings (or this bindings are complex and I am dumb)

2009-11-15 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 g wrote: g Wrote: I have been trying to actualize the http://www.dsource.org/projects/dallegro binings to the lastest typo: it is bindings, not binings Downgrade your compiler version. Every version after 2.028 has bugs which prevent non

Re: Bypassing the const promise

2009-11-19 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Tomek Sowiñski wrote: const on a function forbids changing members: class Wrong { int a; void foo() const { a = 4; } } The above rightly doesn't compile. But with a little twist... class A { int a; void

Re: Member function address

2009-11-21 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 David Nadlinger wrote: Although the code works fine with DMD, LDC complains that »this« is needed to evaluate foo in addressOf. That looks like a ldc bug. foo is occurring in a normal method so it does have 'this'. Is this a bug in LDC or in

Re: Anonymous nested class of problems

2009-12-12 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Tomek Sowiñski wrote: Dnia 12-12-2009 o 13:09:49 Tomek Sowiñski j...@ask.me napisa³(a): Error: no constructor for __anonclass10 This one seems to be unrelated to anonymous stuff. class M { this(byte a) { _a = a; } byte _a;

Re: floating point verification using is?

2009-12-18 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Steven Schveighoffer wrote: If I have 2 identical floating point values, how do I ensure they are binary equivalents of eachother? I'm trying to write some unittest/assert code, and it's not exactly trivial. I thought 'a is b' would work, but

Re: Reappearing error with sorting

2009-12-26 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 nnk wrote: It is quite strange, but the following code sometimes produces a core.exception.asserter...@c:\d\dmd2\src\phobos\std\array.d(253): Attempting to fetch the front of an empty array while trying to sort the array and sometimes runs just

Re: Are scope class useful ?

2010-01-05 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 #ponce wrote: When I started D, it was possible to define a scope class like this. scope class Something { // blah } An instance declaration would then _require_ the scope storage class. { scope Something myVar; // do something

Re: When is array-to-array cast legal, and what does actually happen?

2010-02-23 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ali Çehreli wrote: Daniel Keep wrote: ... snip Well I forget the details, but it's been pointed out before that D's cast is fundamentally broken. You get one cast operator that hides the full set of c++ static, dynamic, const reinterpret casts.

Re: Static attributes aren' immutable

2010-03-05 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 bearophile wrote: I'm playing some more with immutables in D2. This program compiles: struct Foo { static int x; } void main() { immutable Foo f; Foo.x++; f.x++; } Is this code supposed to be correct? If I have an

Re: Static attributes aren' immutable

2010-03-05 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Pelle Månsson wrote: On 03/05/2010 07:50 PM, bearophile wrote: div0: putting it in Foo simply puts it in a namespace. So my (wrong) idea of immutable applied to a struct was that every thing in such namespace becomes immutable (I think

Re: Enum equality test

2010-03-22 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 bearophile wrote: I'm looking for D2 rough edges. I've found that this D2 code compiles and doesn't assert at runtime: enum Foo { V1 = 10 } void main() { assert(Foo.V1 == 10); } But I think enums and integers are not the same type,

Re: Never called destructor

2010-03-25 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Zarathustra wrote: Why, in the following piece of code, destructor for 'x' is never called? snip Because it is not guaranteed to be called. http://www.digitalmars.com/d/2.0/class.html#destructors According to the spec, for the cases you've

Re: Never called destructor

2010-03-27 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Don wrote: div0 wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Same as bug 3285 / bug 3516? No, they are for structs, not classes. I had a bit more of a play, and it seems that the scope object is on the stack, so it's memory

Re: ctfe library

2010-04-20 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ellery Newcomer wrote: As ctfe support matures, I dream of a full-fledged parser generator that can be evaluated at compile time, although that's way more heavy duty than what most people will need. My spirit port might be an option at some

Re: Operators overloading in D2

2010-04-24 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dan wrote: Hi All, So there's my questions Why D2 changed in this way the operators overloading? I saw the the compiler compiles both the functions, even considering this I assume it's not safe to use the old D1 way, right? Because Walter got

Re: Is using a union through more than one member legal in D?

2010-05-04 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ali Çehreli wrote: It is unspecified behavior in C++ to access any member of a union other than the one that was used last to store a value in it. Is that the case with D as well? Ali yes, union in D is the same as C/C++ - -- My enormous

Re: Is using a union through more than one member legal in D?

2010-05-04 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 bearophile wrote: are several other undecided things like this, It's not undecided. It's very clear that a union is exactly equivalent to it's C/C++ counter for the specific purposes of C/C++ interop and other low level features like painting

Re: std.complex

2010-05-09 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 eles wrote: Thanks for your answer. Me too, I prefer working on linux but for some reasons I remain on windows until dmd goes 64-bit. For the record, std.stdio works fine: Compiling import std.stdio; int main(){ writefln(hello!\n);

Re: Yet more OPTLINK woes

2010-05-12 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Simen kjaeraas wrote: Daniel Keep daniel.keep.li...@gmail.com wrote: That's right, it's time for everyone's favourite [1] game: guess why OPTLINK's not working! [2] [...] Does anyone have any idea, any idea at all, on what could be causing

Re: Yet more OPTLINK woes

2010-05-13 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Daniel Keep wrote: Well, except for this: _D11TokenStream808d8d5_ctorMFC6Sourcef6P809091 DFS8Location808989AaYvJS68085cfs5f4Zb80 99aaZC819a87 (broken across 3 lines; xx are bytes in hex since several of them were non-printable.) As

Re: Loop optimization

2010-05-15 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jérôme M. Berger wrote: That depends. In C/C++, the default value for any global variable is to have all bits set to 0 whatever that means for the actual data type. No it's not, it's always uninitialized. Visual studio will initialise

Re: Loop optimization

2010-05-16 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jérôme M. Berger wrote: div0 wrote: Jérôme M. Berger wrote: That depends. In C/C++, the default value for any global variable is to have all bits set to 0 whatever that means for the actual data type. No it's not, it's always uninitialized

Re: template mixin in class is virtual function?

2010-05-21 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 strtr wrote: Or more to the point: Can (Class) template mixin functions be devirtualized by the compiler or do I (as optimization) need to manually copy paste the boiler plate code? You can just wrap the mixin in a final block: import

Re: template mixin in class is virtual function?

2010-05-21 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 strtr wrote: == Quote from div0 (d...@users.sourceforge.net)'s article -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 strtr wrote: Or more to the point: Can (Class) template mixin functions be devirtualized by the compiler or do I

Re: Finding and invoking struct destructors in D2

2010-05-27 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Pillsy wrote: Hi, all, I was wondering if there's any way to determine at compile time whether a struct has a (non-trivial) destructor associated with it, and whether there's any way to call that destructor without using the delete operator. It

Re: What does 'scope' mean for non-class types?

2010-05-30 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Stewart Gordon wrote: div0 wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Lars T. Kyllingstad wrote: In D2, what is the effect (if any) of 'scope' in the following situations? scope int a; Nothing http://www.digitalmars.com/d/2.0

Re: Arithmetic conversions and a surprise with 'max'

2010-06-11 Thread div0
On 11/06/2010 20:00, Ali Çehreli wrote: The following program demonstrates a problem that I just hit. It is a known gotcha of arithmetic conversion rules. The program is trying to center some text around an index of a char array. To avoid negative index values, it calls 'max' to limit the

Re: Arithmetic conversions and a surprise with 'max'

2010-06-11 Thread div0
On 11/06/2010 21:02, div0 wrote: On 11/06/2010 20:00, Ali Çehreli wrote: The following program demonstrates a problem that I just hit. It is a known gotcha of arithmetic conversion rules. The program is trying to center some text around an index of a char array. To avoid negative index values

Re: Best way to make Until! into string

2010-06-22 Thread div0
On 22/06/2010 07:29, Jonathan M Davis wrote: Okay. If you call until like so str.until('\') you get a Until!(pred,string,char). I want to turn that into a string. array() doesn't seem to do the trick right now. It used to work, but now it gives me main.d(47): Error: template

Re: Best way to make Until! into string

2010-06-22 Thread div0
On 22/06/2010 19:26, Jonathan M Davis wrote: div0 wrote: On 22/06/2010 07:29, Jonathan M Davis wrote: Okay. If you call until like so str.until('\') you get a Until!(pred,string,char). I want to turn that into a string. array() doesn't seem to do the trick right now. It used to work

Re: Best way to make Until! into string

2010-06-23 Thread div0
On 22/06/2010 23:05, Jonathan M Davis wrote: Oh my, you caveman! ;) I'd have to go look at all of the changelogs to even have a clue of what's been changed since then. Oh well, I guess that it means that you don't have to worry about stuff changing on you each upgrade by sticking to the same

Re: Best way to make Until! into string

2010-06-24 Thread div0
On 23/06/2010 23:14, bearophile wrote: div0: and now with 2.047 I've been bitten by the removal of struct initialisers. What do you mean? Bye, bearophile curly brace initialisers: struct c4 { float[4]_vals; } c4 dat = { [0,0,0,0] }; Needs to be changed to use

Re: alias function this - limitations

2010-06-24 Thread div0
On 24/06/2010 13:52, Simen kjaeraas wrote: struct Ref( T ) { T* payload; @property ref T getThis( ) { return *payload; } @property ref T getThis( ref T value ) { payload = value; return *payload; } alias getThis this; } void bar( ) { Ref!int f; int n; f = n; int b = f; } This code fails on the

Re: alias function this - limitations

2010-06-24 Thread div0
On 24/06/2010 19:23, Simen kjaeraas wrote: div0 d...@users.sourceforge.net wrote: This code fails on the line 'int b = f;'. Is it supposed to? I think so. 'alias this' is used to forward stuff that appears to the right of a dot onto the named member. Not only. Assignment of the wrapped

Re: std.file bug? std.regex bug?

2010-06-26 Thread div0
On 26/06/2010 12:23, Simen kjaeraas wrote: Daniel Murphy yebbl...@nospamgmail.com wrote: It could be that the string returned from the regex looks the same as the hardcoded string but contains characters that don't show up when you print it. Does adding assert(regexResult == expectedFilename);

Re: dmd -o- -map prevents creation of map file?

2010-06-26 Thread div0
On 26/06/2010 22:00, Pierre Rouleau wrote: Hi all, dmd 2.047 help states that the -map option switch generate linker .map file. But when compiling a single (stand-alone) source file, dmd seems to generate the .map file even if the -map switch is not present. Is this wanted? Should it not

Re: Grokking concurrency, message passing and Co

2010-07-11 Thread div0
On 11/07/2010 15:28, Philippe Sigaud wrote: - Why is a 2 threads version repeatedly thrice as fast as a no thread version? I thought it'd be only twice as fast. Well if you are running on windows, my guess is that your 2nd cpu is completely free of tasks, so the thread running on that one is

Re: Grokking concurrency, message passing and Co

2010-07-11 Thread div0
On 11/07/2010 20:00, BCS wrote: Hello div0, The rule of thumb is don't bother spawning more threads than you have cpus. You're just wasting resources mostly. You REALLY don't want more threads trying to run than you have cores. Threads in a wait state, are less of an issue, but they still

Re: Grokking concurrency, message passing and Co

2010-07-11 Thread div0
On 11/07/2010 20:29, Philippe Sigaud wrote: On Sun, Jul 11, 2010 at 20:00, div0 d...@users.sourceforge.net mailto:d...@users.sourceforge.net wrote: On 11/07/2010 15:28, Philippe Sigaud wrote: - Why is a 2 threads version repeatedly thrice as fast as a no thread version

Re: Grokking concurrency, message passing and Co

2010-07-12 Thread div0
On 12/07/2010 02:50, sybrandy wrote: The rule of thumb is don't bother spawning more threads than you have cpus. You're just wasting resources mostly. You REALLY don't want more threads trying to run than you have cores. Threads in a wait state, are less of an issue, but they still use up

Re: const(type) vs. const type

2010-07-20 Thread div0
On 20/07/2010 23:57, Mike Linford wrote: I'm playing with QtD, and I tried to override a QWidget's sizeHint() function, which is declared as const QSize sizeHint(). I tried to override it by declaring my function as override const(QSize) sizeHint () . I got a compiler error that it was not

Re: really strange function errors

2010-07-23 Thread div0
On 23/07/2010 23:39, Trass3r wrote: Getting a bunch of strange errors, anybody got an inkling what the cause might be? Error: function Sprite.size () is not callable using argument types () - wtf? Error: function Sprite.getPixel (uint x, uint y) is not callable using argument types

Re: No constructor for a templated class?

2010-07-25 Thread div0
On 25/07/2010 13:55, Philippe Sigaud wrote: OK, I must be tired, I don't know. Nope you're not tired. Templated constructor functions are not currently supported in D. :(

Re: Doubled newlines

2010-08-01 Thread div0
On 01/08/2010 13:12, bearophile wrote: Andrej Mitrovic: The point is that probably there is a newline-related bug somewhere in Phobos and I'd like to find it. Bye, bearophile Yeah there is. I get doubled new lines as well when passing a handle opened with fopen to a CFile thingy.

Re: Doubled newlines

2010-08-01 Thread div0
On 01/08/2010 18:22, div0 wrote: On 01/08/2010 13:12, bearophile wrote: Andrej Mitrovic: The point is that probably there is a newline-related bug somewhere in Phobos and I'd like to find it. Bye, bearophile Yeah there is. I get doubled new lines as well when passing a handle opened

Re: xfbuild, optlink and pragma(lib)

2010-08-01 Thread div0
On 01/08/2010 16:22, Mafi wrote: libSDL.dll.a is a MingW- or Cygwin-compiled link library. That's not going to work on Windows with DMD and may very likely be the source of your problem. If you want to link with a DLL link lib, then you need to get the tool coff2omf[1] (part of the Extended

Re: Operator overloading problem

2010-08-06 Thread div0
On 06/08/2010 21:08, Blonder wrote: Hello, I am trying to understand how operator overloading works with D. I am a C++ programmer and I am reading the book of Andrei Alexandrescu and try to understand D and it's language features. My Group example don't compile, the error is: Error: template

Re: Operator overloading problem

2010-08-06 Thread div0
On 06/08/2010 21:37, div0 wrote: You need to add a second template parameter for the function arguments and add a template constrait like so: struct Group { int i1; Group opBinary(string op, U) (U x) if(op == + is(U: int)) { // do somehting return

Re: inheriting ctors?

2010-08-07 Thread div0
On 06/08/2010 22:57, Andrej Mitrovic wrote: // Offtopic Template errors are so hard to grasp, most of the time it's best to just ignore them and take some logical steps to fix the errors. At least that's in my case true.. lol, that's true. I've been basing out c++ d template code for years

Re: Slicing to convert pointers to bound arrays

2010-08-07 Thread div0
On 07/08/2010 13:45, simendsjo wrote: When I do the same with a static array, I get 0. But this is just actually garbage, right? It might contain other data, and not always 0? Yes. It's entirely undefined what will happen, you might find that the extra bit of memory you try and access is a

Re: Operator overloading problem

2010-08-07 Thread div0
On 07/08/2010 16:25, Blonder wrote: Is there a difference (performance) or something else between the two solutions? I doubt it, templates are applied at compile time in the front end of the compiler so the generated code should be the same. The if style syntax allows much more

Re: Casting away const

2010-08-08 Thread div0
On 08/08/2010 22:56, simendsjo wrote: I'm totally new to the const/immutable thing, so this might be a naive question.. The spec says: modification after casting away const = undefined behavior Casting away const is mostly for dealing with external non D libraries. Some languages have no

Re: What is the term for a function that can be CTFEed?

2010-08-10 Thread div0
On 10/08/2010 13:59, BCS wrote: Hello Jonathan, On Monday 09 August 2010 21:18:42 BCS wrote: We have pure functions, member functions, static functions and global functions; but what kind of function can always be used with CTFE? Haven't we typical called them CTFE or CTFEable functions?

Re: DirectX 11 bindings?

2010-08-10 Thread div0
On 09/08/2010 23:12, Trass3r wrote: No one? Eugh. Nope got OpenGL 3 bindings though. -- My enormous talent is exceeded only by my outrageous laziness. http://www.ssTk.co.uk

Re: Can't get D calling C to build.

2010-08-20 Thread div0
On 20/08/2010 09:17, Bob Cowdery wrote: I'm still concerned it's a bit too soon as a lot of things seem to be either Windows or Linux (cmake says its only tested for *nix) but not both and there is very little guidance on building. I really want to get this working on Windows first. As D makes

Re: Problem with using as shorthand for if

2010-08-20 Thread div0
On 20/08/2010 21:16, Jonathan M Davis wrote: It's legal according to TDPL. It seems to be intended to be used as a shorthand for if. So, stuff like condition writeln(my output); are supposed to be perfectly legal as bizarre as that may seem. I don't believe that it would be legal to do

Re: Can't get D calling C to build.

2010-08-21 Thread div0
On 21/08/2010 22:07, Bob Cowdery wrote: On 20/08/2010 18:44, div0 wrote: On 20/08/2010 09:17, Bob Cowdery wrote: I'm still concerned it's a bit too soon as a lot of things seem to be either Windows or Linux (cmake says its only tested for *nix) but not both and there is very little guidance

Re: Any usable parsers for D2 around?

2010-10-15 Thread div0
On 14/10/2010 23:47, Andrej Mitrovic wrote: Hey, I've been looking for a D2 parser.. there seems to be a few D1 lexers, parsers, and even some minimal semantic analysis tools but I can't find much of anything for D2. Perhaps Goldie will be D2 compatible some day soon. :) There's a

Re: Class template argument deduction from constructor call

2010-10-27 Thread div0
On 27/10/2010 20:36, sergk wrote: class Foo(T) { this(T t) { bar = t; } T bar; } void main() { auto a = new Foo(123); // doesn't work auto b = new Foo!(int)(123); // work, but redundant } Is there any technical limitations preventing this, or its just a

Re: string ~ ubyte

2010-10-31 Thread div0
On 31/10/2010 11:36, Bob Cowdery wrote: Hi I'm implementing a web sockets server as part of the UI for my application. It's almost working but the connection closes on me just after the handshake. I'm pretty sure the handshake response I'm sending is incorrect. This is the last bit of the code

Re: Converting Fuse headers

2010-11-09 Thread div0
On 09/11/2010 05:49, Jesse Phillips wrote: Jesse Phillips Wrote: I'm trying to make fuse work in D[1]. I had some help from htod, but not everything was successful. And I'm not exactly sure how to properly convert strings and such. When saying D[1], I was referencing the link, not the

Re: struct constructors and function parameters

2010-11-09 Thread div0
On 09/11/2010 23:57, Simen kjaeraas wrote: Adam Burton adz...@gmail.com wrote: Hi, should the below work? struct A { public this(B b) {} } struct B {} void foo(A a) {} void main() { B b; foo(b); // Fails } The constructor parameter doesn't need to be a struct, it could be an int. The

Re: How to uncompress gzip archive compressed by deflate method.

2010-11-12 Thread div0
On 12/11/2010 23:33, Zarathustra wrote: Maybe it is a stupid question but I need yours help. As in the topic. I have a Gzip archive in the buffer and I need to extract these archive into another buffer. I tried: void[] _uncompressed = uncompress(_compressed); but it throws

Re: Nested associative arrays

2010-11-13 Thread div0
On 13/11/2010 11:02, Jacob Carlborg wrote: On 2010-11-12 17:44, Ellery Newcomer wrote: Should be. Are you having problems? (I don't use them much, but fwiw, it seems like tango had some [trivial?] problems with them) On 11/12/2010 10:08 AM, Jacob Carlborg wrote: Is D supposed to be able to

Re: Nested associative arrays

2010-11-13 Thread div0
On 13/11/2010 15:49, Jacob Carlborg wrote: On 2010-11-13 14:56, div0 wrote: On 13/11/2010 11:02, Jacob Carlborg wrote: On 2010-11-12 17:44, Ellery Newcomer wrote: Should be. Are you having problems? (I don't use them much, but fwiw, it seems like tango had some [trivial?] problems with them

Re: Nested associative arrays

2010-11-13 Thread div0
On 13/11/2010 20:02, spir wrote: On Sat, 13 Nov 2010 17:27:08 + div0d...@sourceforge.net wrote: How about associative array literal then? Regardless of what you call it I shouldn't get an assertion failure. True. It's been fixed in dmd2 though, you get: Error: Integer constant

Re: struct vs class

2010-11-14 Thread div0
On 14/11/2010 11:08, spir wrote: Hello, There seems to be 2 main differences between structs classes: 1. structs instances are direct values, implement value semantics; while class instances are referenced (actually pointed) 2. classes can be subtyped/subclassed in a simple way; structs

Re: CTFE of yl2x() and other intrinsics

2010-11-15 Thread div0
On 15/11/2010 12:12, div0 wrote: On 15/11/2010 11:00, Lars T. Kyllingstad wrote: I thought that the compiler could evaluate all intrinsics at compile time, but this doesn't seem to be the case for std.math.yl2x(). Is my assumption wrong, or is this a bug that should be reported? -Lars Looks

Re: effect of a label on following block

2010-11-15 Thread div0
On 15/11/2010 16:45, Ellery Newcomer wrote: poking around a little more and I really don't know what's going on. fun piece of trivia though: while loops get rewritten to for loops, so for(;;) l1 { int v; } v = 4; exhibits the same behavior as the while loop. do loops seem to do the same

Re: Signal and slot trouble

2010-11-21 Thread div0
This is just a random stab in the dark, but my guess is that std.signals hasn't been updated since the changes that make global vars live in TLS. Try __gshared SignalForwarder sigWinchSignal; __gshared SignalForwarder sigAlrmSignal; On 21/11/2010 08:05, Peter Federighi wrote: So, I've been

Re: publish a lib

2010-11-21 Thread div0
On 21/11/2010 13:58, Jonathan M Davis wrote: On Sunday 21 November 2010 05:49:14 spir wrote: Hello, On which list is one supposed to publish about a lib (text processing toolkit) that may or not be useful to others, that may or not be interesting in stdlib? general D list, Phobos, announce,...