Re: Scale advocacy

2011-07-04 Thread Daniel Murphy
Ali Çehreli acehr...@yahoo.com wrote in message news:iuqja8$7nl$2...@digitalmars.com... { bool result = ElementType!Range.init is null; } )) is(typeof(ElementType!Range.init is null)) __traits(compiles, cast(void)ElementType!Range.init is null) __traits(compiles, { return ElementType!Range.init

Re: Using a C function with command line parameters

2011-07-04 Thread Steven Schveighoffer
On Mon, 04 Jul 2011 10:31:58 -0400, Jonathan Sternberg jonathansternb...@gmail.com wrote: glut has the function: void glutInit( int* pargc, char** argv ); In order to use it. Since D has an ABI compatible with C, I should be able to write a D file with extern (C) on the glut

swap doesn't work in CTFE?

2011-07-04 Thread Johann MacDonagh
Although CTFE supports ref parameters, swap doesn't appear to work. This casues dmd to segfault in 2.053 and the current dmd master. import std.algorithm; import std.stdio; string ctfeRef(ref string a, ref string b) { return a; } string ctfeSort() { auto x = [ a, c, b ];

Re: Using a C function with command line parameters

2011-07-04 Thread Jacob Carlborg
On 2011-07-04 16:31, Jonathan Sternberg wrote: glut has the function: void glutInit( int* pargc, char** argv ); In order to use it. Since D has an ABI compatible with C, I should be able to write a D file with extern (C) on the glut functions. How would I wrap this function to be used

Re: Using a C function with command line parameters

2011-07-04 Thread Steven Schveighoffer
On Mon, 04 Jul 2011 12:51:48 -0400, Jacob Carlborg d...@me.com wrote: On 2011-07-04 16:31, Jonathan Sternberg wrote: glut has the function: void glutInit( int* pargc, char** argv ); In order to use it. Since D has an ABI compatible with C, I should be able to write a D file with

Pre and Post contracts and signature constraints

2011-07-04 Thread Zardoz
How is the correct way of mix Pre and Post contracts and signature constraints ? I try this that looks logic way and not compile : T foo (T) (T a) if ( is(T : real)) { in { assert (a 0); } body { return a*2; } } I get this errors : Declaration expected, not 'if'

Re: swap doesn't work in CTFE?

2011-07-04 Thread Daniel Murphy
Johann MacDonagh johann.macdonagh@spam..gmail.com wrote in message news:iusp80$vnr$1...@digitalmars.com... Although CTFE supports ref parameters, swap doesn't appear to work. This casues dmd to segfault in 2.053 and the current dmd master. import std.algorithm; import std.stdio;

Re: Pre and Post contracts and signature constraints

2011-07-04 Thread simendsjo
On 04.07.2011 19:20, Zardoz wrote: How is the correct way of mix Pre and Post contracts and signature constraints ? I try this that looks logic way and not compile : T foo (T) (T a) if ( is(T : real)) { in { assert (a 0); } body { return a*2; } } I get this errors :

Re: Pre and Post contracts and signature constraints

2011-07-04 Thread simendsjo
On 04.07.2011 19:42, simendsjo wrote: The in should be in a block of it's own: T foo(T)(T a) if(...) // notice no { here in { } body { } I of course mean that if should not create a new block.

Bits in reverse order in BitArray

2011-07-04 Thread Christian Manning
Hi, when I populate a BitArray using .init, the bits are in reverse order, although the bytes are in the correct order. eg: import std.stdio,std.bitmanip; void main() { ubyte[] arr = [130,56,43,2]; BitArray ba; ba.init(cast(void[])arr,32); foreach(b; ba)

Re: Pre and Post contracts and signature constraints

2011-07-04 Thread Zardoz
On Mon, 04 Jul 2011 19:52:10 +0200, simendsjo wrote: On 04.07.2011 19:42, simendsjo wrote: The in should be in a block of it's own: T foo(T)(T a) if(...) // notice no { here in { } body { } I of course mean that if should not create a new block. Thanks ! I thought that the if () needs

Re: swap doesn't work in CTFE?

2011-07-04 Thread bearophile
Daniel Murphy: Same thing happens with pointers. Reduced: Pointers to structs in CTFE will work in DMD 2.054 :-) Bye, bearophile

Re: Bits in reverse order in BitArray

2011-07-04 Thread Steven Schveighoffer
On Mon, 04 Jul 2011 14:03:35 -0400, Christian Manning cmanning...@gmail.com wrote: Hi, when I populate a BitArray using .init, the bits are in reverse order, although the bytes are in the correct order. eg: import std.stdio,std.bitmanip; void main() { ubyte[] arr = [130,56,43,2];

Re: Pre and Post contracts and signature constraints

2011-07-04 Thread simendsjo
On 04.07.2011 20:12, Zardoz wrote: On Mon, 04 Jul 2011 19:52:10 +0200, simendsjo wrote: On 04.07.2011 19:42, simendsjo wrote: The in should be in a block of it's own: T foo(T)(T a) if(...) // notice no { here in { } body { } I of course mean that if should not create a new block. Thanks

Re: Bits in reverse order in BitArray

2011-07-04 Thread Christian Manning
On 04/07/2011 19:34, Steven Schveighoffer wrote: On Mon, 04 Jul 2011 14:03:35 -0400, Christian Manning cmanning...@gmail.com wrote: Hi, when I populate a BitArray using .init, the bits are in reverse order, although the bytes are in the correct order. eg: import std.stdio,std.bitmanip; void

Re: Operator Overloading and boilerplate code

2011-07-04 Thread Loopback
I've researched a bit though I still haven't come up with a solution. Since the problem lies within (the most simple) constructor, I tried to modify it for another outcome. If I supplied a generic parameter to the pre-constructor the Cannot evaluate at compile time message disappeared but two new

Re: Operator Overloading and boilerplate code

2011-07-04 Thread Ali Çehreli
On Tue, 05 Jul 2011 02:44:03 +0200, Loopback wrote: I've researched a bit though I still haven't come up with a solution. Since the problem lies within (the most simple) constructor, I tried to modify it for another outcome. If I supplied a generic parameter to the pre-constructor the Cannot

Re: swap doesn't work in CTFE?

2011-07-04 Thread Daniel Murphy
bearophile bearophileh...@lycos.com wrote in message news:iut093$1bjg$1...@digitalmars.com... Daniel Murphy: Same thing happens with pointers. Reduced: Pointers to structs in CTFE will work in DMD 2.054 :-) When they don't crash the compiler, that is.