Is GC.setAttr(p, GC.BlkAttr.NO_MOVE) guaranteed to work?

2014-07-02 Thread Ali Çehreli via Digitalmars-d-learn
There is an example in GC.addRoot() documentation where the programmer is trying to mark a memory block as NO_MOVE: http://dlang.org/phobos/core_memory.html#.GC.addRoot auto context = new Object; GC.addRoot(cast(void*)context); GC.setAttr(cast(void*)context, GC.BlkAttr.NO_MOVE);

Re: Is GC.setAttr(p, GC.BlkAttr.NO_MOVE) guaranteed to work?

2014-07-02 Thread Rainer Schuetze via Digitalmars-d-learn
On 02.07.2014 08:17, Ali Çehreli wrote: There is an example in GC.addRoot() documentation where the programmer is trying to mark a memory block as NO_MOVE: http://dlang.org/phobos/core_memory.html#.GC.addRoot auto context = new Object; GC.addRoot(cast(void*)context);

Integer max value

2014-07-02 Thread pgtkda via Digitalmars-d-learn
Is there a way to get the max size of an integer?

Re: Integer max value

2014-07-02 Thread Rene Zwanenburg via Digitalmars-d-learn
On Wednesday, 2 July 2014 at 08:39:06 UTC, pgtkda wrote: Is there a way to get the max size of an integer? int.max The same exists for other built-ins and enums.

Re: Integer max value

2014-07-02 Thread pgtkda via Digitalmars-d-learn
On Wednesday, 2 July 2014 at 08:58:46 UTC, Rene Zwanenburg wrote: On Wednesday, 2 July 2014 at 08:39:06 UTC, pgtkda wrote: Is there a way to get the max size of an integer? int.max The same exists for other built-ins and enums. thank you very much

similar method as Math.Ceiling in c#

2014-07-02 Thread pgtkda via Digitalmars-d-learn
Is there a similar method as Math.Ceiling in D? http://msdn.microsoft.com/en-US/en-en/library/zx4t0t48(v=vs.110).aspx

Re: similar method as Math.Ceiling in c#

2014-07-02 Thread via Digitalmars-d-learn
On Wednesday, 2 July 2014 at 13:36:17 UTC, pgtkda wrote: Is there a similar method as Math.Ceiling in D? http://msdn.microsoft.com/en-US/en-en/library/zx4t0t48(v=vs.110).aspx http://dlang.org/phobos/std_math.html#.ceil

overloading InExpression

2014-07-02 Thread Vlad Levenfeld via Digitalmars-d-learn
Is this possible? The documentation for std.container lists in as an operator in the container API but only associative arrays actually seem to support it.

Re: overloading InExpression

2014-07-02 Thread Dicebot via Digitalmars-d-learn
struct S { int opIn_r(int key) { return key*2; } } void main() { assert((42 in S.init) == 84); }

Re: Can't modify this

2014-07-02 Thread Maxim Fomin via Digitalmars-d-learn
On Saturday, 28 June 2014 at 20:40:21 UTC, Ary Borenszweig wrote: This doesn't work: class Foo { this() { this = new Foo; } } Error: Cannot modify 'this' However you can do this: class Foo { this() { auto p = this; *p = new Foo(); } } It even changes the value of this!

Re: overloading InExpression

2014-07-02 Thread Vlad Levenfeld via Digitalmars-d-learn
On Wednesday, 2 July 2014 at 14:14:57 UTC, Dicebot wrote: struct S { int opIn_r(int key) { return key*2; } } void main() { assert((42 in S.init) == 84); } Thanks! I wonder, why the _r and lack of documentation?

Re: overloading InExpression

2014-07-02 Thread Ali Çehreli via Digitalmars-d-learn
On 07/02/2014 07:35 AM, Vlad Levenfeld wrote: On Wednesday, 2 July 2014 at 14:14:57 UTC, Dicebot wrote: struct S { int opIn_r(int key) { return key*2; } } void main() { assert((42 in S.init) == 84); } Thanks! I wonder, why the _r I think it is the old syntax,

Re: overloading InExpression

2014-07-02 Thread Dicebot via Digitalmars-d-learn
On Wednesday, 2 July 2014 at 15:36:23 UTC, Kozzi11 wrote: Thanks! I wonder, why the _r and lack of documentation? Maybe something from old days? But in current a href=http://dlang.org/operatoroverloading.html#Binary; target=_blankdoc/a there is a opBinary: Yep, I think it is D1 legacy

Re: overloading InExpression

2014-07-02 Thread Kozzi11 via Digitalmars-d-learn
On Wednesday, 2 July 2014 at 14:35:55 UTC, Vlad Levenfeld wrote: On Wednesday, 2 July 2014 at 14:14:57 UTC, Dicebot wrote: struct S { int opIn_r(int key) { return key*2; } } void main() { assert((42 in S.init) == 84); } Thanks! I wonder, why

Re: overloading InExpression

2014-07-02 Thread bearophile via Digitalmars-d-learn
Dicebot: Yep, I think it is D1 legacy approach. opBinary should be more appropriate. I hope the usage of the old operator overloading functions will generate deprecation messages soon. Bye, bearophile

Building D on windows

2014-07-02 Thread Kashyap via Digitalmars-d-learn
Hi, I was able to build dmd on my windows machine using VS2013 (using the vs2010 sln file). However, I am not sure how to proceed with building the druntime and phobos. Could someone please point me to instructions for the same? I tried the following 1. Downloaded make and shell (digital

Re: Building D on windows

2014-07-02 Thread Vladimir Panteleev via Digitalmars-d-learn
On Wednesday, 2 July 2014 at 16:06:08 UTC, Kashyap wrote: I got the following error - C:\Users\labuser\dlang\druntimedir ..\dmd\src\vcbuild\Win32\Release\dmd_msc.exe C:\Users\labuser\dlang\druntimeshell script.sh shell 1.01 make -f posix.mak DMD=../dmd/src/vcbuild/Win32/Release/dmd_msc.exe

Re: Why is the Win32 boilerplate the way it is?

2014-07-02 Thread Vladimir Panteleev via Digitalmars-d-learn
On Sunday, 29 June 2014 at 15:06:25 UTC, Jeremy Sorensen wrote: The only question I have is what happens when you use SUBSYSTEM:WINDOWS:4.0 (Which I understand means XP or higher) and the program runs on something older? Windows XP is version 5.1. 4.0 was Windows NT 4 (which I believe was the

Re: overloading InExpression

2014-07-02 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 02, 2014 at 02:35:54PM +, Vlad Levenfeld via Digitalmars-d-learn wrote: On Wednesday, 2 July 2014 at 14:14:57 UTC, Dicebot wrote: struct S { int opIn_r(int key) { return key*2; } } void main() { assert((42 in S.init) == 84); }

Re: overloading InExpression

2014-07-02 Thread Vlad Levenfeld via Digitalmars-d-learn
Ah yes I never noticed that in was in the binary op table. In my defense, searching for in usually yields too many results to be useful. Thanks to everyone for your help!

CTFE bug or enhancement?

2014-07-02 Thread safety0ff via Digitalmars-d-learn
Everything compiles fine except for function qux2: http://dpaste.dzfl.pl/9d9187e0b450 Is this a bug or an enhancement for CTFE? It would be really nice to have this feature because core.simd has functions such as: void16 __simd(XMM opcode, void16 op1, void16 op2, ubyte imm8); Where all the

Re: CTFE bug or enhancement?

2014-07-02 Thread safety0ff via Digitalmars-d-learn
Actually, this is an enhancement because adding: enum b = blah Makes them fail. :(

Re: CTFE bug or enhancement?

2014-07-02 Thread safety0ff via Digitalmars-d-learn
On Thursday, 3 July 2014 at 01:55:14 UTC, safety0ff wrote: Actually, this is an enhancement because adding: enum b = blah Makes them fail. :( The question is now: how can the delegate be evaluated for the return value but not for the enum?

Re: CTFE bug or enhancement?

2014-07-02 Thread safety0ff via Digitalmars-d-learn
On Thursday, 3 July 2014 at 02:02:19 UTC, safety0ff wrote: On Thursday, 3 July 2014 at 01:55:14 UTC, safety0ff wrote: Actually, this is an enhancement because adding: enum b = blah Makes them fail. :( The question is now: how can the delegate be evaluated for the return value but not for

spawn and wait

2014-07-02 Thread Puming via Digitalmars-d-learn
Hi, I want to spawn several similar tasks and then wait for all of them to complete to go on do some other things, like: ```d void task(int id) { // do the stuff } void main() { foreach (i; 0..10) { spawn(task, i); } wait(?); // wait for all task to complete

DUB help plz

2014-07-02 Thread K.K. via Digitalmars-d-learn
I've been trying to figure DUB out and have been having a bit of trouble. I'm trying to make a simple program that uses Derelict GL3 and SDL2. I keep getting this error though:

Re: spawn and wait

2014-07-02 Thread Ali Çehreli via Digitalmars-d-learn
On 07/02/2014 08:29 PM, Puming wrote: I want to spawn several similar tasks and then wait for all of them to complete to go on do some other things If you don't care about account for each of them individually, core.thread.thread_joinAll would work. The following program starts two waves of