Re: Compilation failure

2012-07-20 Thread bearophile
Timon Gehr: Usually bugs are reported by the guy who finds them, but here you go: http://d.puremagic.com/issues/show_bug.cgi?id=8400 Thank you, already fixed, it seems. Even if the fix is the opposite of what I have thought (I was thinking about forbidding global immutables too to be used a

Re: ufcs and integer params

2012-07-20 Thread Philippe Sigaud
Marco: >>> auto distance = 100.km; >>> auto speed = 120.km/hour; >> Sounds fun. I mean, it makes me happy to see code written like this instead of >> Distance distance = new Kilometers(100); >> Speed speed = Speed.fromDistanceByTime(new Kilometers(120), new Hours(1)); Yeah, that was exactly one

More WinAPI problems

2012-07-20 Thread DLimited
Hello everyone, I encountered a few more problems while creating my system-wide makro program. 1) I can't load my dll with LoadLibraryW, only LoadLibraryA. Why? 2) The LoadLibraryA function "fails" with Error Code 127 - I still get a Handle and can register my function as a LowLevelKeyboard

Re: ~= call copy ctor?

2012-07-20 Thread Namespace
New question: I have this code: [code] import std.stdio; struct Test { public: this(int i = 0) { writeln("CTOR"); } this(this) { writeln("COPY CTOR"); } ~this() { writeln("DTOR"); } } void main() {

Re: More WinAPI problems

2012-07-20 Thread Regan Heath
On Fri, 20 Jul 2012 14:07:51 +0100, DLimited wrote: Hello everyone, I encountered a few more problems while creating my system-wide makro program. 1) I can't load my dll with LoadLibraryW, only LoadLibraryA. Why? How are you passing the DLL filename to LoadLibraryA/W? Are you passing

Re: ~= call copy ctor?

2012-07-20 Thread Regan Heath
On Fri, 20 Jul 2012 14:50:19 +0100, Namespace wrote: New question: I have this code: [code] import std.stdio; struct Test { public: this(int i = 0) { writeln("CTOR"); } this(this) { writeln("COPY CTOR"); } ~this() {

Re: ~= call copy ctor?

2012-07-20 Thread Namespace
For correctness: A copy call is still fine if I assign a local variable to _arr (even if i think that ref parameters should'nt be copied), but i think that it is not fine if I assign directly, as you see above.

Re: ~= call copy ctor?

2012-07-20 Thread Namespace
Does: _arr[0] = Test(0); avoid the copy construction? R [code] void main() { Test[2] _arr = void; _arr[0] = Test(0); writeln("end main"); } [/code] puts CTOR DTOR end main DTOR DTOR If i wrote Test[] instead of Test[2] i get an exception. There is no dynamic way f

Re: ~= call copy ctor?

2012-07-20 Thread Jonathan M Davis
On Friday, July 20, 2012 15:50:19 Namespace wrote: > Why on earth? http://stackoverflow.com/questions/6884996/questions-about-postblit-and-move- semantics If you want to guarantee that you don't get any copies while moving an object around, it needs to be a reference type (which would includ

Re: ~= call copy ctor?

2012-07-20 Thread monarch_dodra
On Friday, 20 July 2012 at 13:50:20 UTC, Namespace wrote: New question: I have this code: [code] import std.stdio; struct Test { public: this(int i = 0) { writeln("CTOR"); } Be careful about "int i = O". Structs are not allowed to have default constructors. Th

Re: ~= call copy ctor?

2012-07-20 Thread Jonathan M Davis
On Friday, July 20, 2012 08:08:47 Jonathan M Davis wrote: > On Friday, July 20, 2012 15:50:19 Namespace wrote: > > Why on earth? > > http://stackoverflow.com/questions/6884996/questions-about-postblit-and-move > - semantics > > If you want to guarantee that you don't get any copies while movi

Re: ufcs and integer params

2012-07-20 Thread David Nadlinger
On Friday, 20 July 2012 at 12:28:52 UTC, Philippe Sigaud wrote: Hmm, looking at it, I guess kilo is just 1000 as an enum in your code? That's a good idea. Sorry, that should have been »kilo!gram«. It actually creates a new unit with a conversion factor of 1000 relative to the base unit (well,

Re: ~= call copy ctor?

2012-07-20 Thread Namespace
If i @disable the postblit i get a strange behaviour: [code] struct Test { public: int _id; this(int i) { _id = i; writeln("CTOR"); } @disable this(this); ~this() { writeln("DTOR"); } } vo

Re: ~= call copy ctor?

2012-07-20 Thread monarch_dodra
On Friday, 20 July 2012 at 16:02:18 UTC, Namespace wrote: If i @disable the postblit i get a strange behaviour: @disable this(this); I think @disable is broken right now, and does nothing (ei: allows a default implementation of this(this) ). If you replace by the C++ "declar

Re: ~= call copy ctor?

2012-07-20 Thread Namespace
It seems structs are very broken right now... I would use classes, but they are nullable and without correct/good error handling instead of "access violation" i prefer structs. Funny, all variables are default initialized which would be even done by the OS. But Null Exceptions aren't exists and

Re: ~= call copy ctor?

2012-07-20 Thread Ali Çehreli
On 07/20/2012 09:02 AM, Namespace wrote: > If i @disable the postblit i get a strange behaviour: Something is not right. Compiled with dmd 2.059, the linker says: undefined reference to `_D6deneme4Test10__postblitMFZv' 64 bit Linux... Ali

Predictable seed for pseudo-random number generation

2012-07-20 Thread Joseph Rushton Wakeling
Hello all, Often when writing simulations with pseudo-random number generation you want to be able to use a predictable seed for testing purposes, e.g. to confirm whether an alteration to the code produces changes in output. In a single-threaded piece of code this is easy -- one can just put

Re: Predictable seed for pseudo-random number generation

2012-07-20 Thread Jonathan M Davis
On Friday, July 20, 2012 19:52:17 Joseph Rushton Wakeling wrote: > On a related note, is it possible to override the default random number > generator with another type? As long as rndGen isn't called with its full path (std.random.rndGen), any module which uses it could declare its own rndGen, a

Problem: handling a function dependent on release mode.

2012-07-20 Thread Damian
Trying to convert the below code to D, for the life of me I cannot do it :( I'm guess I need to use a template for this but I just cannot get my head around it. Any help please? #ifdef SFML_DEBUG // If in debug mode, perform a test on every call #define alCheck(Func) ((Func), priv::alC

Re: ~= call copy ctor?

2012-07-20 Thread Namespace
Something else which is against classes: incorrect scope behaviour: [code] import std.stdio; class TestC { public: this() { writeln("CTOR class"); } ~this() { writeln("DTOR class"); } } struct TestS { public: this(int i) {

Re: Problem: handling a function dependent on release mode.

2012-07-20 Thread Namespace
On Friday, 20 July 2012 at 21:36:59 UTC, Damian wrote: Trying to convert the below code to D, for the life of me I cannot do it :( I'm guess I need to use a template for this but I just cannot get my head around it. Any help please? #ifdef SFML_DEBUG // If in debug mode, perform a test on

Re: ~= call copy ctor?

2012-07-20 Thread David Nadlinger
On Friday, 20 July 2012 at 21:41:45 UTC, Namespace wrote: Why comes "DTOR class" _after_ "end main" and not before? If i write "scope TestC c = ...;" it is correct, but i read that "scope" will be deprecated. Can someone explain me that behaviour? The destructor will be invoked when the GC col

Re: Compilation failure

2012-07-20 Thread Timon Gehr
On 07/20/2012 01:53 PM, bearophile wrote: Timon Gehr: Usually bugs are reported by the guy who finds them, but here you go: http://d.puremagic.com/issues/show_bug.cgi?id=8400 Thank you, already fixed, it seems. Even if the fix is the opposite of what I have thought (I was thinking about forbi

Re: ~= call copy ctor?

2012-07-20 Thread Namespace
On Friday, 20 July 2012 at 21:51:02 UTC, David Nadlinger wrote: On Friday, 20 July 2012 at 21:41:45 UTC, Namespace wrote: Why comes "DTOR class" _after_ "end main" and not before? If i write "scope TestC c = ...;" it is correct, but i read that "scope" will be deprecated. Can someone explain me

Re: Problem: handling a function dependent on release mode.

2012-07-20 Thread Damian
On Friday, 20 July 2012 at 21:47:55 UTC, Namespace wrote: On Friday, 20 July 2012 at 21:36:59 UTC, Damian wrote: Trying to convert the below code to D, for the life of me I cannot do it :( I'm guess I need to use a template for this but I just cannot get my head around it. Any help please? #ifd

Re: ~= call copy ctor?

2012-07-20 Thread Lukasz
On Friday, 20 July 2012 at 21:41:45 UTC, Namespace wrote: Something else which is against classes: incorrect scope behaviour: [code] import std.stdio; class TestC { public: this() { writeln("CTOR class"); } ~this() { writeln("DTOR class")

Re: ~= call copy ctor?

2012-07-20 Thread Ali Çehreli
On 07/20/2012 02:54 PM, Namespace wrote: On Friday, 20 July 2012 at 21:51:02 UTC, David Nadlinger wrote: On Friday, 20 July 2012 at 21:41:45 UTC, Namespace wrote: Why comes "DTOR class" _after_ "end main" and not before? If i write "scope TestC c = ...;" it is correct, but i read that "scope" w

Re: ~= call copy ctor?

2012-07-20 Thread Namespace
That happens because the destructor is being called when Garbage collector is cleaning the memory used by the class instance. How can i call the DTOR or at least a Release method after end of scope? Optimally automatic without any explicit calls.

Re: ~= call copy ctor?

2012-07-20 Thread Lukasz
On Friday, 20 July 2012 at 21:54:05 UTC, Namespace wrote: On Friday, 20 July 2012 at 21:51:02 UTC, David Nadlinger wrote: On Friday, 20 July 2012 at 21:41:45 UTC, Namespace wrote: Why comes "DTOR class" _after_ "end main" and not before? If i write "scope TestC c = ...;" it is correct, but i re

Re: Predictable seed for pseudo-random number generation

2012-07-20 Thread Joseph Rushton Wakeling
On 20/07/12 19:59, Jonathan M Davis wrote: As long as rndGen isn't called with its full path (std.random.rndGen), any module which uses it could declare its own rndGen, and it would be used instead of std.random's, in which case you could do whatever you want with its type or seed. I did consid

Re: Getting a range over a const Container

2012-07-20 Thread Ellery Newcomer
On 07/19/2012 06:09 PM, Ellery Newcomer wrote: On 07/19/2012 02:51 AM, Artur Skawina wrote: Range!Node opSlice() { return Range!Node(first); } Range!(const Node) opSlice() const { return Range!(const Node)(first); } it looks like you could almost merge these two into one using

Re: Problem: handling a function dependent on release mode.

2012-07-20 Thread Jonathan M Davis
On Friday, July 20, 2012 23:36:58 Damian wrote: > Trying to convert the below code to D, for the life of me I > cannot do it :( I'm guess I need to use a template for this > but I just cannot get my head around it. Any help please? > > #ifdef SFML_DEBUG > > // If in debug mode, perform a test on

Re: Getting a range over a const Container

2012-07-20 Thread Jonathan M Davis
On Friday, July 20, 2012 17:15:53 Ellery Newcomer wrote: > On 07/19/2012 06:09 PM, Ellery Newcomer wrote: > > On 07/19/2012 02:51 AM, Artur Skawina wrote: > >> Range!Node opSlice() { return Range!Node(first); } > >> Range!(const Node) opSlice() const { return Range!(const > >> > >> Node)(first); }

Parameter specialization

2012-07-20 Thread Eyyub
Hello, I have a question about the semantic of parameter specialization(TemplateTypeParameterSpecialization) In this following code, there are 2 forms of the same function 'add' : T add(T, U : T) (T a, U b) //doesn't work { return a + b; } T add(T, U) (T a, U b) if(is(U : T)) //works

Re: ~= call copy ctor?

2012-07-20 Thread Jonathan M Davis
On Saturday, July 21, 2012 00:04:21 Namespace wrote: > > That happens because the destructor is being called when Garbage > > collector is cleaning the memory used by the class instance. > > How can i call the DTOR or at least a Release method after end of > scope? > Optimally automatic without an

Re: Parameter specialization

2012-07-20 Thread Ali Çehreli
On 07/20/2012 06:47 PM, Eyyub wrote: Hello, I have a question about the semantic of parameter specialization(TemplateTypeParameterSpecialization) In this following code, there are 2 forms of the same function 'add' : T add(T, U : T) (T a, U b) //doesn't work { return a + b; } T add(T, U) (T a

Re: ufcs and integer params

2012-07-20 Thread Philippe Sigaud
> Sorry, that should have been »kilo!gram«. It actually creates a new unit > with tbua conversion factor of 1000 relative to the base unit (well, it does a > few more things to handle cases like kilo!(milli!meter)), with the point > being that the quantities are actually stored in memory "verbatim"