Re: extern __gshared const(char)* symbol fails

2018-08-31 Thread James Blachly via Digitalmars-d-learn
On Friday, 31 August 2018 at 17:50:17 UTC, Steven Schveighoffer wrote: What the C compiler is doing is storing it as data, and then storing the symbol to point at the first element in the data. When you use const char* in D, it's expecting a *pointer* to be stored at that address, not the

Re: extern __gshared const(char)* symbol fails

2018-08-31 Thread James Blachly via Digitalmars-d-learn
On Friday, 31 August 2018 at 17:18:58 UTC, Neia Neutuladh wrote: On Friday, 31 August 2018 at 06:20:09 UTC, James Blachly wrote: Hi all, ... When linking to this library from D, I have declared it as: extern __gshared const(char)* seq_nt16_str; ***But this segfaults when I treat it like an

Re: extern __gshared const(char)* symbol fails

2018-08-31 Thread nkm1 via Digitalmars-d-learn
On Friday, 31 August 2018 at 06:20:09 UTC, James Blachly wrote: Hi all, I am linking to a C library which defines a symbol, const char seq_nt16_str[] = "=ACMGRSVTWYHKDBN"; In the C sources, this is an array of 16 bytes (17 I guess, because it is written as a string). In the C headers, it

Re: How to use listener.d example?

2018-08-31 Thread Neia Neutuladh via Digitalmars-d-learn
On Friday, 31 August 2018 at 07:38:54 UTC, Marcin wrote: https://github.com/dlang/dmd/blob/master/samples/listener.d Can some one add more comment to that example? I need to make code that connects to local application, very similar to this. Assumptions: 1. Create an application that

Re: extern __gshared const(char)* symbol fails

2018-08-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/31/18 2:20 AM, James Blachly wrote: Hi all, I am linking to a C library which defines a symbol, const char seq_nt16_str[] = "=ACMGRSVTWYHKDBN"; In the C sources, this is an array of 16 bytes (17 I guess, because it is written as a string). In the C headers, it is listed as extern

Re: extern __gshared const(char)* symbol fails

2018-08-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/31/18 1:18 PM, Neia Neutuladh wrote: On Friday, 31 August 2018 at 06:20:09 UTC, James Blachly wrote: Hi all, I am linking to a C library which defines a symbol, const char seq_nt16_str[] = "=ACMGRSVTWYHKDBN"; In the C sources, this is an array of 16 bytes (17 I guess, because it is

Re: Is there any reason to use non-ref foreach?

2018-08-31 Thread Dukc via Digitalmars-d-learn
On Friday, 31 August 2018 at 12:52:17 UTC, bauss wrote: In reality you're micro-optimizing something that doesn't require it. I think you misunderstood. I wasn't trying to optimize, I was looking for a general way to iterate. I can't see the benefit other than added complexity. I just

Re: extern __gshared const(char)* symbol fails

2018-08-31 Thread Neia Neutuladh via Digitalmars-d-learn
On Friday, 31 August 2018 at 06:20:09 UTC, James Blachly wrote: Hi all, I am linking to a C library which defines a symbol, const char seq_nt16_str[] = "=ACMGRSVTWYHKDBN"; In the C sources, this is an array of 16 bytes (17 I guess, because it is written as a string). In the C headers, it

Re: Is there any reason to use non-ref foreach?

2018-08-31 Thread James Blachly via Digitalmars-d-learn
On Friday, 31 August 2018 at 12:52:17 UTC, bauss wrote: So basically ... Instead of copying the value, you're just copying the address. I can't see the benefit other than added complexity. I assume a benefit could be observed if you are copying a large struct instead of an int.

Re: How to use math functions in dcompute?

2018-08-31 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 30 August 2018 at 10:34:33 UTC, Sobaya wrote: On Monday, 27 August 2018 at 12:47:45 UTC, Nicholas Wilson wrote: On Monday, 27 August 2018 at 09:57:18 UTC, Sobaya wrote: On Monday, 27 August 2018 at 09:41:34 UTC, 9il wrote: On Monday, 27 August 2018 at 08:25:14 UTC, Sobaya wrote:

Re: Is there any reason to use non-ref foreach?

2018-08-31 Thread bauss via Digitalmars-d-learn
On Friday, 31 August 2018 at 09:59:20 UTC, Dukc wrote: For me, it seems that for generality you should always add ref into foreach loop variable. The reason is this: import std.experimental.all; struct NoCopies { @disable this(this); int payload; } void main() { auto range = new

Re: Can't print enum values

2018-08-31 Thread Andrey via Digitalmars-d-learn
On Friday, 31 August 2018 at 12:21:48 UTC, aliak wrote: auto ToUnderlyingType(alias a)() { return cast(OriginalType!(typeof(a)))a; } void print(T...)(T args) { writeln(staticMap!(ToUnderlyingType, args)); } Oohhh. So easy! Killed 2 days - and templates and mixins tried... And the

Re: Can't print enum values

2018-08-31 Thread aliak via Digitalmars-d-learn
On Friday, 31 August 2018 at 10:51:51 UTC, Andrey wrote: On Thursday, 30 August 2018 at 12:04:26 UTC, vit wrote: On Thursday, 30 August 2018 at 11:34:36 UTC, Andrey wrote: On Thursday, 30 August 2018 at 11:09:40 UTC, vit wrote: [...] I want to create a reusable template for this purpose.

Re: Can't print enum values

2018-08-31 Thread Andrey via Digitalmars-d-learn
On Thursday, 30 August 2018 at 12:04:26 UTC, vit wrote: On Thursday, 30 August 2018 at 11:34:36 UTC, Andrey wrote: On Thursday, 30 August 2018 at 11:09:40 UTC, vit wrote: [...] I want to create a reusable template for this purpose. Why I can't use "staticMap" so that compiler it self would

Re: Solving the impossible?

2018-08-31 Thread aliak via Digitalmars-d-learn
On Thursday, 30 August 2018 at 21:40:40 UTC, Everlast wrote: On Thursday, 30 August 2018 at 00:10:42 UTC, Paul Backus wrote: [...] This is not true! You claim that I'm making a blanket statement about what mathematicians would view then you do the same. [...] If ... implies "an arbitrary

Is there any reason to use non-ref foreach?

2018-08-31 Thread Dukc via Digitalmars-d-learn
For me, it seems that for generality you should always add ref into foreach loop variable. The reason is this: import std.experimental.all; struct NoCopies { @disable this(this); int payload; } void main() { auto range = new NoCopies[20]; foreach(const ref el; range)

How to use listener.d example?

2018-08-31 Thread Marcin via Digitalmars-d-learn
https://github.com/dlang/dmd/blob/master/samples/listener.d Can some one add more comment to that example? I need to make code that connects to local application, very similar to this. Assumptions: 1. Create an application that listens to arguments. 2. Create an application that will send

extern __gshared const(char)* symbol fails

2018-08-31 Thread James Blachly via Digitalmars-d-learn
Hi all, I am linking to a C library which defines a symbol, const char seq_nt16_str[] = "=ACMGRSVTWYHKDBN"; In the C sources, this is an array of 16 bytes (17 I guess, because it is written as a string). In the C headers, it is listed as extern const char seq_nt16_str[]; When linking to