Question about compile-time functions.
If a function is only called during compile-time will it be available at runtime?
Re: Dynamic arrays with static initialization and maybe a bug with sizeof
Le 13/12/2016 23:44, Johan Engelen a écrit : On Tuesday, 13 December 2016 at 21:27:57 UTC, Xavier Bigand wrote: Hi, I have the following code snippet : voidset() { GLfloat[]data = [ -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f,
Re: DRY version of `static if(__traits(compiles, expr)) fun(expr)`
On 14.12.2016 00:00, Timothee Cour via Digitalmars-d-learn wrote: what's the best (and DRY) way to achieve: ``` static if(__traits(compiles, expr)) fun(expr); ``` ie, without repeating the expression inside expr? eg: ``` static if(__traits(compiles, foo.bar[2])){ counter++; writeln("
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
On 12/13/2016 01:36 PM, Ali wrote: Now about that second part of my problem I'm not entirely sure whether this should work but I think the problem is with mutating the 'frequencies' member of an immutable element of 'rooms'. The error message means that those non-const expressions
DRY version of `static if(__traits(compiles, expr)) fun(expr)`
what's the best (and DRY) way to achieve: ``` static if(__traits(compiles, expr)) fun(expr); ``` ie, without repeating the expression inside expr? eg: ``` static if(__traits(compiles, foo.bar[2])){ counter++; writeln(" expr = ", foo.bar[2]); } ```
Re: arsd.cgi - maximum length of form post
On Tuesday, 13 December 2016 at 00:54:43 UTC, Adam D. Ruppe wrote: On Tuesday, 13 December 2016 at 00:48:44 UTC, bachmeier wrote: a range violation error core.exception.RangeError@test.d(109): Range violation What's that line of your code too? Here is a minimal program that can replicate
Re: Dynamic arrays with static initialization and maybe a bug with sizeof
On Tuesday, 13 December 2016 at 21:27:57 UTC, Xavier Bigand wrote: Hi, I have the following code snippet : voidset() { GLfloat[] data = [ -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f,
Using Nsight with VisualD
Hi, I am trying to use Nsight with VisualD by it tell me that it can not start the program "". It seems that it does not use the right property of the project to retrieve the path of my generated binary. I do not know if it is an issue of VisualD directly or DUB that don't correctly
Re: Dynamic arrays with static initialization and maybe a bug with sizeof
Le 13/12/2016 22:39, ag0aep6g a écrit : On 12/13/2016 10:27 PM, Xavier Bigand wrote: voidset() { GLfloat[]data = [ -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, ]; glBindVertexArray(mVAO);
Re: Dynamic arrays with static initialization and maybe a bug with sizeof
On 12/13/2016 10:27 PM, Xavier Bigand wrote: voidset() { GLfloat[]data = [ -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, ]; glBindVertexArray(mVAO); glBufferData(GL_ARRAY_BUFFER, data.sizeof,
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
On Tuesday, 13 December 2016 at 21:33:11 UTC, Ali Çehreli wrote: On 12/13/2016 12:30 PM, Ali wrote: > foreach (i, room; rooms) { > data[i].room = That is the address of the local variable room. You need to use 'ref' there: foreach (i, ref room; rooms) { > - Ali Ahh
Re: Alias variable from another class
I guess it's because you're accessing a member of _1 from inside a scope of _2 where nothing has been constructed yet? Someone more familiar with D would probably have a better answer on this part. I'm quite new :) But a work around would be class _2 { _1 instance;
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
On 12/13/2016 12:30 PM, Ali wrote: > foreach (i, room; rooms) { > data[i].room = That is the address of the local variable room. You need to use 'ref' there: foreach (i, ref room; rooms) { > - Ali Ali "the real one :o)"
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
2016-12-13
Thread
bauss (wtf happend to my name took some old cached title LOL??) via Digitalmars-d-learn
On Tuesday, 13 December 2016 at 21:21:34 UTC, Ali wrote: On Tuesday, 13 December 2016 at 21:08:31 UTC, drug007 wrote: (*d.room).name Oh yeah, tried that too. That at least compiles but gives a runtime exception (bad address). Try (*cast(Room*)(d.room)).name
Dynamic arrays with static initialization and maybe a bug with sizeof
Hi, I have the following code snippet : voidset() { GLfloat[] data = [ -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, ];
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
On Tuesday, 13 December 2016 at 21:08:31 UTC, drug007 wrote: (*d.room).name Oh yeah, tried that too. That at least compiles but gives a runtime exception (bad address).
Re: reading from file
On Tuesday, 13 December 2016 at 16:59:17 UTC, Namal wrote: On Tuesday, 13 December 2016 at 16:57:40 UTC, Namal wrote: Sorry if I wasn't clear. The array should be two demensional and each line in text line should be a row in that 2x2 array. Also, it should be saved as an integer. And
Re: Accessing members through pointers to structs (also, CTFE associative arrays)
On 13.12.2016 23:30, Ali wrote: Hi, Long time watcher and recently started playing with D a bit more. Ran in to a couple of snags that I'll combine in one post. It involves a data set that contains a list of strings. Each string represents a Room name. What I'm trying to do is pluck out the room
Accessing members through pointers to structs (also, CTFE associative arrays)
Hi, Long time watcher and recently started playing with D a bit more. Ran in to a couple of snags that I'll combine in one post. It involves a data set that contains a list of strings. Each string represents a Room name. What I'm trying to do is pluck out the room names and also calculate the
Re: reading from file
On 12/13/2016 08:59 AM, Namal wrote: On Tuesday, 13 December 2016 at 16:57:40 UTC, Namal wrote: Sorry if I wasn't clear. The array should be two demensional and each line in text line should be a row in that 2x2 array. Also, it should be saved as an integer. Here is another one: import
Alias variable from another class
I made a little program to illustrate my confusion : import std.stdio; class _1 { int i; this(int n) { i = n; } } class _2 { _1 instance; alias twelve = instance.i; this() {
Re: this is not an lvalue
On Tuesday, 13 December 2016 at 17:52:21 UTC, Adam D. Ruppe wrote: On Tuesday, 13 December 2016 at 17:26:28 UTC, kink wrote: Assuming `Parameter` is a class and not a struct, yes. Even if it is a struct, ref wouldn't make a difference here because the variable is assigned to a member, which
Re: this is not an lvalue
On Tuesday, 13 December 2016 at 17:26:28 UTC, kink wrote: Assuming `Parameter` is a class and not a struct, yes. Even if it is a struct, ref wouldn't make a difference here because the variable is assigned to a member, which means ref would get lost.
Re: this is not an lvalue
On Tuesday, 13 December 2016 at 16:23:16 UTC, Adam D. Ruppe wrote: On Tuesday, 13 December 2016 at 15:09:10 UTC, Andrey wrote: void moveTo(ref Parameter parent) { You probably don't want the `ref` there, nor likely on any other method definitions (especially check removeValue). Assuming
Re: reading from file
Sorry if I wasn't clear. The array should be two demensional and each line in text line should be a row in that 2x2 array.
Re: reading from file
On Tuesday, 13 December 2016 at 16:57:40 UTC, Namal wrote: Sorry if I wasn't clear. The array should be two demensional and each line in text line should be a row in that 2x2 array. Also, it should be saved as an integer.
Re: this is not an lvalue
On Tuesday, 13 December 2016 at 15:09:10 UTC, Andrey wrote: void moveTo(ref Parameter parent) { You probably don't want the `ref` there, nor likely on any other method definitions (especially check removeValue).
Re: reading from file
On Tuesday, 13 December 2016 at 15:42:16 UTC, Namal wrote: Hello, comming from C++, I find it hard to remember and understand how reading from file should be done in D. Especially since I am not very good in functional programming. So I have a file which looks like this: 1,2,3,4 5,6,7,8
Re: reading from file
On 14/12/2016 4:42 AM, Namal wrote: Hello, comming from C++, I find it hard to remember and understand how reading from file should be done in D. Especially since I am not very good in functional programming. So I have a file which looks like this: 1,2,3,4 5,6,7,8 9,11,11,12 and so on How
reading from file
Hello, comming from C++, I find it hard to remember and understand how reading from file should be done in D. Especially since I am not very good in functional programming. So I have a file which looks like this: 1,2,3,4 5,6,7,8 9,11,11,12 and so on How could I read it row by row and create
this is not an lvalue
Hello, I'm newbie in D. I'm trying to rewrite my project from C++ and now I get strange warning: src/e2ml/node.d(23,22): Deprecation: this is not an lvalue As I write the following code void moveTo(ref Parameter parent) { this.p_parent.removeValue(this); this.p_parent = parent;