Re: Struct literals and AA literals

2016-05-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-05-23 21:51, Lodovico Giaretta wrote: Hi, Today I stumbled upon this weird error: struct ConfigContainer { Config[string] configs; } struct Config { string foo; string bar; } enum ConfigContainer cc = { configs: [

Re: Speed up `dub`.

2016-05-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-03-07 10:18, ciechowoj wrote: I'm using `dub` to build project. And every time I run `dub` it seems to check if dependencies are up to date, which takes some time. Is there a way to switch of that checking? Or any other way to speed up building process? It really slows down my modify-comp

Re: Problem with .debug info in program

2016-05-24 Thread chmike via Digitalmars-d-learn
Here you have the object lines from app with the addresses. ./app.d:[++] app.d 30x43aae8 app.d 50x43aaf0 app.d 70x43aaf7 app.d

Problem with .debug info in program

2016-05-24 Thread chmike via Digitalmars-d-learn
Hello, I've notice that gdb was improperly displaying source lines with disassembled code. I looked at the assembly to check what is inlined and what not and the difference between the use of is and == in the machine code. I then tested with objdump with a simple program and saw the same pr

Re: std.conv.parse not accepting ByCodeUnitImpl

2016-05-24 Thread Jack Stouffer via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 05:01:39 UTC, ag0aep6g wrote: You're missing that `parse`'s parameter is `ref`. `splitValue.front` is not an lvalue, so it can't be passed in a ref parameter. This works: auto f = splitValue.front; parse!int(f); Thanks. DMD desperately needs bette

Re: Problem with .debug info in program

2016-05-24 Thread chmike via Digitalmars-d-learn
After closer examination it seam that the second line with 9 is a bogus insertion. Removing it should fix the code line table. app.d 90x43aafb app.d 110x43aafe app.d

Re: Problem with .debug info in program

2016-05-24 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 13:17:22 UTC, chmike wrote: After closer examination it seam that the second line with 9 is a bogus insertion. Removing it should fix the code line table. app.d 9 0x43aafb app.d 11

Re: Problem with .debug info in program

2016-05-24 Thread Kagamin via Digitalmars-d-learn
Probably normal, see this discussion: https://forum.dlang.org/post/mailman.400.1389749305.15871.digitalmar...@puremagic.com Anyway dmd is not known to have a quality backend, try ldc or gdc.

Re: Is there a way to make a class variable visible but constant to outsiders, but changeable (mutable) to the class itself?

2016-05-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/21/16 1:32 PM, dan wrote: Is it possible to have a class which has a variable which can be seen from the outside, but which can only be modified from the inside? Something like: class C { int my_var = 3; // semi_const?? void do_something() { my_var = 4; } } And then in another f

full copies on assignment

2016-05-24 Thread John Nixon via Digitalmars-d-learn
1 import std.stdio; 2 3 struct CS{ 4 char[] t; 5 CS opAssign(const CS rhs){ 6 writeln("CS.opAssign called"); 7 this.t = rhs.t.dup; 8 return this;} 9 }; 10 void test_fun(const ref CS rhs){ 11 CS cs = rhs;//error cannot implicitly convert expression (rhs) of typ

Trying to get type and name at compile time

2016-05-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
Hi all, I am trying to get the type and name of a field at compile time, but can't get the following to work. Anyone any idea of why test is not of the type AliasSeq!(double, "x")? ``` import std.meta : AliasSeq; struct Point { double x; double y; } alias test = AliasSeq!( typeof(__tra

Re: Is there a way to make a class variable visible but constant to outsiders, but changeable (mutable) to the class itself?

2016-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 24, 2016 10:10:16 Steven Schveighoffer via Digitalmars-d-learn wrote: > A while ago, I discovered that this works. > > class C { > union > { >private int _my_var; >public const int my_var; > } > void do_something() { _my_var = 4; } > } Yeah. That's

Re: Trying to get type and name at compile time

2016-05-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 15:01:33 UTC, Edwin van Leeuwen wrote: // I expected AliasSeq!(double,"x")??? pragma(msg,test); // tuple((double), "x") What Phobos calls AliasSeq is called tuple inside the compiler. They are the same thing, just different names. static assert(is(test == AliasSeq

Re: full copies on assignment

2016-05-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 14:29:53 UTC, John Nixon wrote: This naively doesn’t seem right because the RHS of an assignment should not be altered by it. It's because the char[] being shallow copied still leads to mutable stuff. What I typically do here is just add a method `dup` to the struc

Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-24 Thread llaine via Digitalmars-d-learn
Hi everybody, As written in the description I'm really new to D, I discovered it a few weeks ago thanks to the D Conf in Berlin. After playing around for couple of days with it, I wanted to share my journey with you guys on several points. 1 - Installation (DMD and DUB) I'm running Fedor

Re: binary expression...

2016-05-24 Thread captain_fid via Digitalmars-d-learn
On Saturday, 21 May 2016 at 23:06:10 UTC, Ali Çehreli wrote: On 05/21/2016 12:56 PM, captain_fid wrote: >>> [...] fail me >>> [...] value); } >>> [...] have a >> [...] something. > [...] missing/forgetting/misunderstanding here. opCast is for explicit type conversions. However, you seem to

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-24 Thread Daniel Kozak via Digitalmars-d-learn
Dne 24.5.2016 v 17:27 llaine via Digitalmars-d-learn napsal(a): Hi everybody, As written in the description I'm really new to D, I discovered it a few weeks ago thanks to the D Conf in Berlin. After playing around for couple of days with it, I wanted to share my journey with you guys on sev

Re: Trying to get type and name at compile time

2016-05-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 15:09:43 UTC, Adam D. Ruppe wrote: On Tuesday, 24 May 2016 at 15:01:33 UTC, Edwin van Leeuwen wrote: // I expected AliasSeq!(double,"x")??? pragma(msg,test); // tuple((double), "x") What Phobos calls AliasSeq is called tuple inside the compiler. They are the same th

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-24 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 15:27:45 UTC, llaine wrote: Hi everybody, [...] 5 - Tools I've seen your comment on the DCD issue related to DUB (#198). It mays be the plugin (and not DCD ) that doesn't register well vibe-d. Also it's possible that it didn't work because vibe-d was not yet fetch

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-24 Thread cy via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 15:27:45 UTC, llaine wrote: I'm running Fedora 23 on a daily basis and the installation was OK. Not as easy as on mac but still. Yeah, rpm based distributions like Fedora/Redhat/etc have historically been a real pain when it comes to installing stuff. Depending on i

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-24 Thread Ali Çehreli via Digitalmars-d-learn
On 05/24/2016 10:05 AM, cy wrote: > On Tuesday, 24 May 2016 at 15:27:45 UTC, llaine wrote: >> Of course I went to the getstarted.html page but > >> as a newbie with no system programming background I feel there are too >> many choices for me. > > Oh, I don't think system programming is the issue

Re: Struct literals and AA literals

2016-05-24 Thread Lodovico Giaretta via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 06:59:18 UTC, Jacob Carlborg wrote: What we need is something like this [1]: auto c = Config{ foo: "foo", bar: "bar }; The compiler will know for sure that "c" is of type Config because the right side includes the type. [1] https://issues.dlang.org/show_bug.cgi?id=

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-24 Thread cy via Digitalmars-d-learn
https://p0nce.github.io/d-idioms/ I wanted to mention as well, if you like idioms. That guy has some good ideas. On Tuesday, 24 May 2016 at 17:36:45 UTC, Ali Çehreli wrote: Yes, a link from that page points to a book that *can* be bought but it's available online as well: It's worth buying, b

Can no longer build OSX druntime unittest for master

2016-05-24 Thread Steven Schveighoffer via Digitalmars-d-learn
I get these errors: Undefined symbols for architecture x86_64: "dyld_enumerate_tlv_storage(void (dyld_tlv_states, dyld_tlv_info const*) block_pointer)", referenced from: _d_dyld_getTLSRange(void*, void**, unsigned long*) in osx_tls.o "__d_dyld_getTLSRange", referenced from: _D2r

Re: Can no longer build OSX druntime unittest for master

2016-05-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/24/16 2:11 PM, Steven Schveighoffer wrote: I get these errors: Undefined symbols for architecture x86_64: "dyld_enumerate_tlv_storage(void (dyld_tlv_states, dyld_tlv_info const*) block_pointer)", referenced from: _d_dyld_getTLSRange(void*, void**, unsigned long*) in osx_tls.o "

Re: Is there a way to make a class variable visible but constant to outsiders, but changeable (mutable) to the class itself?

2016-05-24 Thread Meta via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 15:07:55 UTC, Jonathan M Davis wrote: On Tuesday, May 24, 2016 10:10:16 Steven Schveighoffer via Digitalmars-d-learn wrote: A while ago, I discovered that this works. class C { union { private int _my_var; public const int my_var; } void

Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-24 Thread Gary Willoughby via Digitalmars-d-learn
I have a T* pointer to the start of a malloc'd chunk of memory, the type T and the number of T's stored in the chunk. Is there an efficient way of converting this information to a D array of type T[] or even T[n]?

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 18:42:41 UTC, Gary Willoughby wrote: I have a T* pointer to the start of a malloc'd chunk of memory, the type T and the number of T's stored in the chunk. Is there an efficient way of converting this information to a D array of type T[] or even T[n]? Slice it: T[]

Re: Trying to get type and name at compile time

2016-05-24 Thread ag0aep6g via Digitalmars-d-learn
On 05/24/2016 06:22 PM, Edwin van Leeuwen wrote: That's what I assumed at first.. So why does the following fail with: cannot interpret double at compile time? I assumed staticMap would automatically flatten the resulting AliasSeqs. ``` import std.meta : AliasSeq, ApplyLeft, staticMap; struct P

Re: Can no longer build OSX druntime unittest for master

2016-05-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/24/16 2:11 PM, Steven Schveighoffer wrote: I get these errors: Undefined symbols for architecture x86_64: "dyld_enumerate_tlv_storage(void (dyld_tlv_states, dyld_tlv_info const*) block_pointer)", referenced from: _d_dyld_getTLSRange(void*, void**, unsigned long*) in osx_tls.o "

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-24 Thread Seb via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 18:03:17 UTC, cy wrote: https://p0nce.github.io/d-idioms/ I wanted to mention as well, if you like idioms. That guy has some good ideas. On Tuesday, 24 May 2016 at 17:36:45 UTC, Ali Çehreli wrote: Yes, a link from that page points to a book that *can* be bought but i

Re: Trying to get type and name at compile time

2016-05-24 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 18:44:45 UTC, ag0aep6g wrote: Seems to be a problem in ApplyLeft: import std.meta: AliasSeq, ApplyLeft; alias addType(T, string name) = AliasSeq!(T, name); alias addTypeInt = ApplyLeft!(addType, int); alias FullyInstantiated = addTypeInt!"foo"; Fails with:

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-24 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 18:43:22 UTC, Adam D. Ruppe wrote: On Tuesday, 24 May 2016 at 18:42:41 UTC, Gary Willoughby wrote: I have a T* pointer to the start of a malloc'd chunk of memory, the type T and the number of T's stored in the chunk. Is there an efficient way of converting this infor

What's wrong with my usage of std.algorithm.map in this code example?

2016-05-24 Thread pineapple via Digitalmars-d-learn
I would've expected this to work, but instead I get a compile error. Is my syntax wrong? Is this just not a case that map can handle, and I should be doing something else? import std.algorithm : map; import std.conv : to; import std.stdio : writeln; import std.string : join;

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/24/16 4:03 PM, pineapple wrote: I would've expected this to work, but instead I get a compile error. Is my syntax wrong? Is this just not a case that map can handle, and I should be doing something else? import std.algorithm : map; import std.conv : to; import std.stdio : wri

Re: Newbie to D, first impressions and feedback on the 5 (and more) first minutes.

2016-05-24 Thread qznc via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 15:27:45 UTC, llaine wrote: As written in the description I'm really new to D, I discovered it a few weeks ago thanks to the D Conf in Berlin. After playing around for couple of days with it, I wanted to share my journey with you guys on several points. Thanks for

Re: full copies on assignment

2016-05-24 Thread John Nixon via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 15:17:37 UTC, Adam D. Ruppe wrote: On Tuesday, 24 May 2016 at 14:29:53 UTC, John Nixon wrote: This naively doesn’t seem right because the RHS of an assignment should not be altered by it. It's because the char[] being shallow copied still leads to mutable stuff. W

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-24 Thread Gary Willoughby via Digitalmars-d-learn
On Tuesday, 24 May 2016 at 18:43:22 UTC, Adam D. Ruppe wrote: On Tuesday, 24 May 2016 at 18:42:41 UTC, Gary Willoughby wrote: I have a T* pointer to the start of a malloc'd chunk of memory, the type T and the number of T's stored in the chunk. Is there an efficient way of converting this infor

Re: What is up with building DMD (et al.) on Windows?

2016-05-24 Thread Jeremy DeHaan via Digitalmars-d-learn
On Wednesday, 11 May 2016 at 14:30:44 UTC, Vladimir Panteleev wrote: On Tuesday, 10 May 2016 at 04:48:23 UTC, Jeremy DeHaan wrote: After DMD is built, other things keep getting built by DMC. I get more than a few errors due to having an eof character on the first line of some .h files, or somet

Re: What is up with building DMD (et al.) on Windows?

2016-05-24 Thread Jeremy DeHaan via Digitalmars-d-learn
On Wednesday, 11 May 2016 at 14:30:44 UTC, Vladimir Panteleev wrote: On Tuesday, 10 May 2016 at 04:48:23 UTC, Jeremy DeHaan wrote: Building DMD, Phobos, and druntime on Linux is so easy and straight forward. It all works as expected. What's up with building DMD on Windows? For historical reas

Re: Is there a way to make a class variable visible but constant to outsiders, but changeable (mutable) to the class itself?

2016-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 24, 2016 18:28:44 Meta via Digitalmars-d-learn wrote: > On Tuesday, 24 May 2016 at 15:07:55 UTC, Jonathan M Davis wrote: > > On Tuesday, May 24, 2016 10:10:16 Steven Schveighoffer via > > > > Digitalmars-d-learn wrote: > >> A while ago, I discovered that this works. > >> > >> class

Re: Is there an easy way to convert a pointer to malloc'd memory to an array?

2016-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 24, 2016 19:52:17 Era Scarecrow via Digitalmars-d-learn wrote: > On Tuesday, 24 May 2016 at 18:43:22 UTC, Adam D. Ruppe wrote: > > On Tuesday, 24 May 2016 at 18:42:41 UTC, Gary Willoughby wrote: > >> I have a T* pointer to the start of a malloc'd chunk of > >> memory, the type T and

Re: Operator overloading through UFCS doesn't work

2016-05-24 Thread Elie Morisse via Digitalmars-d-learn
On Saturday, 13 October 2012 at 22:58:56 UTC, Timon Gehr wrote: Afaik free-function operator overloads (but not in the context of UFCS) were considered and turned down because D did not want to get amidst discussions about adding Koenig lookup. UFCS does not do Koenig lookup. I don't get it,

Re: Operator overloading through UFCS doesn't work

2016-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 24, 2016 23:19:32 Elie Morisse via Digitalmars-d-learn wrote: > On Saturday, 13 October 2012 at 22:58:56 UTC, Timon Gehr wrote: > > Afaik free-function operator overloads (but not in the context > > of UFCS) were considered and turned down because D did not want > > to get amidst di

Re: OpenGL with D tutorials

2016-05-24 Thread dvrein via Digitalmars-d-learn
On Sunday, 22 May 2016 at 21:21:33 UTC, Rishub Nagpal wrote: On Sunday, 22 May 2016 at 12:13:07 UTC, ixid wrote: What is the best OpenGL tutorial with D to use? I've tried to use d-gamedev-intro and opengl-tutorials and seem to get errors, files that are no longer included are needed (dgl)? an