Re: Is there a way to get the types of all template parameters?

2015-06-04 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-06-04 15:38, Atila Neves wrote: For regular runtime parameters, there's ParameterTypeTuple. How would I write an equivalent template for template parameters? i.e. void fun(Foo foo, Bar bar)() {} alias types = CtParameterTypeTuple!fun; //TypeTuple!(Foo, Bar) I've tried but my

Re: string to char array?

2015-06-04 Thread Ali Çehreli via Digitalmars-d-learn
On 06/04/2015 03:28 PM, anonymous wrote: > Generally, a `char**` is a pointer to a pointer to a char. There may be > more pointers to chars behind the pointed-to one. And there may be more > chars behind the pointed-to ones. You can't know just from the type. Yep, "C's biggest mistake": http:/

Re: string to char array?

2015-06-04 Thread anonymous via Digitalmars-d-learn
On Thursday, 4 June 2015 at 21:35:40 UTC, Kyoji Klyden wrote: On Thursday, 4 June 2015 at 03:25:24 UTC, ketmar wrote: On Wed, 03 Jun 2015 11:59:56 +, Kyoji Klyden wrote: [...] what exactly is char**? Is it pointing to the first char of the first string in an array? it's a pointer to a

Re: string to char array?

2015-06-04 Thread Kyoji Klyden via Digitalmars-d-learn
On Thursday, 4 June 2015 at 03:25:24 UTC, ketmar wrote: On Wed, 03 Jun 2015 11:59:56 +, Kyoji Klyden wrote: That's what I found so confusing about the opengl docs. Just guessing here but char* is a pointer to the first char in the string, then what exactly is char**? Is it pointing to the

Re: Array declaration warning

2015-06-04 Thread Meta via Digitalmars-d-learn
On Thursday, 4 June 2015 at 16:52:30 UTC, Ali Çehreli wrote: On 06/04/2015 04:27 AM, Meta wrote: > On Wednesday, 3 June 2015 at 21:05:42 UTC, Ali Çehreli wrote: >> a[] = b;// makes the elements of 'a' same as 'b's elements > Isn't a[] = b deprecated syntax? I believe you have to use a[]

Re: Function Error: cannot be read at compile time

2015-06-04 Thread jmh530 via Digitalmars-d-learn
On Thursday, 4 June 2015 at 17:25:52 UTC, Alex Parrill wrote: On Thursday, 4 June 2015 at 17:04:06 UTC, jmh530 wrote: float output[len]; This creates a fixed-sized array of length `len` (using the deprecated syntax). Since the length is part of the type, it needs to be known at compi

Re: Function Error: cannot be read at compile time

2015-06-04 Thread Alex Parrill via Digitalmars-d-learn
On Thursday, 4 June 2015 at 17:04:06 UTC, jmh530 wrote: float output[len]; This creates a fixed-sized array of length `len` (using the deprecated syntax). Since the length is part of the type, it needs to be known at compile time. You probably want a dynamic array instead. `auto out

Function Error: cannot be read at compile time

2015-06-04 Thread jmh530 via Digitalmars-d-learn
I'm trying to run the following code (to create an array of uniform random variables) on the latest version of rdmd (2.067.1). import std.random; auto uniform_array(int len, float a, float b) { Random gen; float output[len]; foreach(ref float i; output) {

Re: Array declaration warning

2015-06-04 Thread Ali Çehreli via Digitalmars-d-learn
On 06/04/2015 04:27 AM, Meta wrote: > On Wednesday, 3 June 2015 at 21:05:42 UTC, Ali Çehreli wrote: >> a[] = b;// makes the elements of 'a' same as 'b's elements > Isn't a[] = b deprecated syntax? I believe you have to use a[] = b[] now. Thanks. Unfortunately, 2.067.1 'dmd -w -de' is st

Re: Variadic std.algorithm.equal()

2015-06-04 Thread Meta via Digitalmars-d-learn
On Thursday, 4 June 2015 at 14:42:43 UTC, Per Nordlöw wrote: Is there a reason why std.algorithm.equal() isn't variadic? Probably an oversight. Does any language have a variadic equals? If any language were to have it, I'd expect it to be one of the Lisps, but even Lisp only has binary equa

Re: Is there a way to get the types of all template parameters?

2015-06-04 Thread Atila Neves via Digitalmars-d-learn
On Thursday, 4 June 2015 at 14:12:08 UTC, ketmar wrote: On Thu, 04 Jun 2015 13:38:18 +, Atila Neves wrote: For regular runtime parameters, there's ParameterTypeTuple. How would I write an equivalent template for template parameters? i.e. void fun(Foo foo, Bar bar)() {} alias ty

Re: Is there a way to get the types of all template parameters?

2015-06-04 Thread Atila Neves via Digitalmars-d-learn
On Thursday, 4 June 2015 at 13:50:02 UTC, Meta wrote: On Thursday, 4 June 2015 at 13:38:20 UTC, Atila Neves wrote: For regular runtime parameters, there's ParameterTypeTuple. How would I write an equivalent template for template parameters? i.e. void fun(Foo foo, Bar bar)() {} alias ty

Variadic std.algorithm.equal()

2015-06-04 Thread via Digitalmars-d-learn
Is there a reason why std.algorithm.equal() isn't variadic?

Re: Is there a way to get the types of all template parameters?

2015-06-04 Thread ketmar via Digitalmars-d-learn
On Thu, 04 Jun 2015 13:38:18 +, Atila Neves wrote: > For regular runtime parameters, there's ParameterTypeTuple. How would I > write an equivalent template for template parameters? i.e. > > void fun(Foo foo, Bar bar)() {} > > alias types = CtParameterTypeTuple!fun; //TypeTuple!(Foo

Re: Is there a way to get the types of all template parameters?

2015-06-04 Thread Meta via Digitalmars-d-learn
On Thursday, 4 June 2015 at 13:38:20 UTC, Atila Neves wrote: For regular runtime parameters, there's ParameterTypeTuple. How would I write an equivalent template for template parameters? i.e. void fun(Foo foo, Bar bar)() {} alias types = CtParameterTypeTuple!fun; //TypeTuple!(Foo, Ba

Is there a way to get the types of all template parameters?

2015-06-04 Thread Atila Neves via Digitalmars-d-learn
For regular runtime parameters, there's ParameterTypeTuple. How would I write an equivalent template for template parameters? i.e. void fun(Foo foo, Bar bar)() {} alias types = CtParameterTypeTuple!fun; //TypeTuple!(Foo, Bar) I've tried but my is expression kung fu was weak. Atila

Re: Call-ie return on behalf of caller?

2015-06-04 Thread Artur Skawina via Digitalmars-d-learn
On 06/04/15 00:37, Tofu Ninja via Digitalmars-d-learn wrote: > Is there a way other than exceptions for a called function to force the > caller to return? > > Specifically, I know the return type of the caller(its always bool) and under > certain circumstances I would like the caller to just giv

Re: Does using "const" keyword for scalar parameters mean anything?

2015-06-04 Thread anonymous via Digitalmars-d-learn
On Thursday, 4 June 2015 at 11:28:51 UTC, tcak wrote: [code] void test( const int a ){} [/code] Does that "const" make any difference at all? At the end, it is a scalar, and passed as value. All it does is it makes the variable "a" const: void test( const int a ) { a = 42; /* Error:

Does using "const" keyword for scalar parameters mean anything?

2015-06-04 Thread tcak via Digitalmars-d-learn
[code] void test( const int a ){} [/code] Does that "const" make any difference at all? At the end, it is a scalar, and passed as value.

Re: Array declaration warning

2015-06-04 Thread Meta via Digitalmars-d-learn
On Wednesday, 3 June 2015 at 21:05:42 UTC, Ali Çehreli wrote: On 06/03/2015 01:45 PM, Paul wrote: > On Wednesday, 3 June 2015 at 20:33:02 UTC, Ali Çehreli wrote: >> > pathList[][n] ~= CoOrd(cX, cY); >> >> I don't think you need the empty [] there. pathList[n] is one of the >> paths and you are a

Re: What does program do when array is returned from function?

2015-06-04 Thread tcak via Digitalmars-d-learn
On Thursday, 4 June 2015 at 09:42:04 UTC, Marc Schütz wrote: On Thursday, 4 June 2015 at 07:20:24 UTC, Daniel Kozák wrote: On Thu, 04 Jun 2015 07:03:30 + tcak via Digitalmars-d-learn wrote: [code] char[] test(){ auto t = new char[5]; return t; } [/code] Is the test function ret

Re: What does program do when array is returned from function?

2015-06-04 Thread via Digitalmars-d-learn
On Thursday, 4 June 2015 at 07:20:24 UTC, Daniel Kozák wrote: On Thu, 04 Jun 2015 07:03:30 + tcak via Digitalmars-d-learn wrote: [code] char[] test(){ auto t = new char[5]; return t; } [/code] Is the test function returning just a pointer from heap or does copy operation?

Re: What does program do when array is returned from function?

2015-06-04 Thread Daniel Kozák via Digitalmars-d-learn
On Thu, 04 Jun 2015 07:03:30 + tcak via Digitalmars-d-learn wrote: > [code] > char[] test(){ > auto t = new char[5]; > > return t; > } > [/code] > > Is the test function returning just a pointer from heap or does > copy operation? > this is same as: auto t = new char[](5) it wi

What does program do when array is returned from function?

2015-06-04 Thread tcak via Digitalmars-d-learn
[code] char[] test(){ auto t = new char[5]; return t; } [/code] Is the test function returning just a pointer from heap or does copy operation? It is not obvious what it does, and I am trying to avoid doing this always.