Re: accessing your scope for template metaprogramming ?

2011-04-16 Thread bearophile
Sean Cavanaugh: > Is there any way to access the your current scope? For instance the > following pseudocode is what I am after more or less: > > > class Foo > { >alias byte function(int) BarCompatibleInterface; > >byte Bar(int) >{ > static assert(is(typeof(localscope) == fun

accessing your scope for template metaprogramming ?

2011-04-16 Thread Sean Cavanaugh
Is there any way to access the your current scope? For instance the following pseudocode is what I am after more or less: class Foo { alias byte function(int) BarCompatibleInterface; byte Bar(int) { static assert(is(typeof(localscope) == function)); static assert(is(std.traits.

Re: A use case for fromStringz

2011-04-16 Thread Andrej Mitrovic
Yeah I basically took the idea from the existing D implementation. Although D's arrays are a struct with a length and a pointer (I think so).

Re: Vector operations doesn't convert to a common type?

2011-04-16 Thread bearophile
simendsjo: > int[3] a = [1,2,4]; > float[3] b = [1,2,4]; > float[3] c; > // Why doesn't this work? > c = a[] + b[]; // Error: incompatible types for ((a[]) + (b[])): > 'int[]' and 'float[]' > // When this works? > c[0] = a[0] + b[0]; > c[1] = a[1] + b[1]

Re: auto arr = new int[10];

2011-04-16 Thread Piotr Szturmaj
%u wrote: is there any different b/w: auto arr = new int[10]; arr is dynamic array of int with ten elements and int[10] arr; ? arr is static array of int with ten elements

auto arr = new int[10];

2011-04-16 Thread %u
is there any different b/w: auto arr = new int[10]; and int[10] arr; ?

Re: Vector operations doesn't convert to a common type?

2011-04-16 Thread simendsjo
On 16.04.2011 12:12, simendsjo wrote: int[3] a = [1,2,4]; float[3] b = [1,2,4]; float[3] c; // Why doesn't this work? c = a[] + b[]; // Error: incompatible types for ((a[]) + (b[])): 'int[]' and 'float[]' // When this works? c[0] = a[0] + b[0]; c[1] = a[1] + b[1]; c[2] = a[2] + b[2]; assert(c ==

Vector operations doesn't convert to a common type?

2011-04-16 Thread simendsjo
int[3] a = [1,2,4]; float[3] b = [1,2,4]; float[3] c; // Why doesn't this work? c = a[] + b[]; // Error: incompatible types for ((a[]) + (b[])): 'int[]' and 'float[]' // When this works? c[0] = a[0] + b[0]; c[1] = a[1] + b[1]; c[2] = a[2] + b[2]; assert(

Re: A use case for fromStringz

2011-04-16 Thread spir
On 04/16/2011 06:55 AM, Andrej Mitrovic wrote: I wonder.. in all these years.. have they ever thought about using a convention in C where the length is embedded as a 32/64bit value at the pointed location of a pointer, followed by the array contents? Sometimes called "Pascal strings" (actually,