Re: fPIC Error

2016-11-19 Thread Picaud Vincent via Digitalmars-d-learn
On Thursday, 3 November 2016 at 05:16:11 UTC, Dlang User wrote: I am running Debian Testing and I think I have run into the recent fPIC issue. This is the source code for the test project I am using: import std.stdio; void main() { writeln("Edit source/app.d to start your

Re: Popular embedded language for scripting in D

2016-11-19 Thread MGW via Digitalmars-d-learn
On Saturday, 19 November 2016 at 22:18:39 UTC, Sai wrote: I have seen luad and Walters own JavaScript VM that can be used in D for embedded scripting purpose in an application. I was wondering which is more popular among D applications? Any suggestions? Thanks, sai Look at one more

Re: shared arrray problem

2016-11-19 Thread Charles Hixson via Digitalmars-d-learn
On 11/19/2016 05:52 PM, ag0aep6g via Digitalmars-d-learn wrote: On 11/20/2016 01:33 AM, Charles Hixson via Digitalmars-d-learn wrote: Yes. I was hoping someone would pop up with some syntax making the array, but not its contents, const or immutable, which I couldn't figure out how to do, and

Re: Array operations with multidimensional arrays

2016-11-19 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 19 November 2016 at 21:05:49 UTC, John Colvin wrote: On Saturday, 19 November 2016 at 19:36:50 UTC, Marduk wrote: Thanks a lot! Now I get what it means that array declarations are read from right to left. The way I think about it is this: int is a type. int[3] is an array of 3

Re: shared arrray problem

2016-11-19 Thread ag0aep6g via Digitalmars-d-learn
On 11/20/2016 01:33 AM, Charles Hixson via Digitalmars-d-learn wrote: Yes. I was hoping someone would pop up with some syntax making the array, but not its contents, const or immutable, which I couldn't figure out how to do, and which is what I really hoped would be the answer, but it appears

Re: fPIC Error

2016-11-19 Thread Matthias Klumpp via Digitalmars-d-learn
On Saturday, 19 November 2016 at 21:14:47 UTC, Charles Hixson wrote: [...] IIRC, LDC didn't have that problem. I don't remember testing gdc. But, yes, it is quite annoying. That's because we can maintain those compilers with the distribution and configure them appropriately to compile with

Re: Compiling and linking libraries

2016-11-19 Thread Darren via Digitalmars-d-learn
On Wednesday, 16 November 2016 at 16:05:06 UTC, Mike Parker wrote: On Wednesday, 16 November 2016 at 14:59:40 UTC, Edwin van Leeuwen wrote: Thank you for this! Great information. So dub dynamically "add" code from the dll into the source code at runtime? Also will I ever need to learn

Re: shared arrray problem

2016-11-19 Thread Charles Hixson via Digitalmars-d-learn
On 11/19/2016 01:50 PM, ag0aep6g via Digitalmars-d-learn wrote: On 11/19/2016 10:26 PM, Charles Hixson via Digitalmars-d-learn wrote: It's worse than that, if they modify the length the array may be reallocated in RAM so that the pointers held by the containing class do not point to the changed

Popular embedded language for scripting in D

2016-11-19 Thread Sai via Digitalmars-d-learn
I have seen luad and Walters own JavaScript VM that can be used in D for embedded scripting purpose in an application. I was wondering which is more popular among D applications? Any suggestions? Thanks, sai

Re: shared arrray problem

2016-11-19 Thread ag0aep6g via Digitalmars-d-learn
On 11/19/2016 10:26 PM, Charles Hixson via Digitalmars-d-learn wrote: It's worse than that, if they modify the length the array may be reallocated in RAM so that the pointers held by the containing class do not point to the changed values. (Read the header comments...it's not nice at all.)

Re: shared arrray problem

2016-11-19 Thread Charles Hixson via Digitalmars-d-learn
On 11/19/2016 11:10 AM, Nicolas Gurrola via Digitalmars-d-learn wrote: On Saturday, 19 November 2016 at 18:51:05 UTC, Charles Hixson wrote: ubyte[]header()@property {return fHead[4..$];} This method should do what you want. You are only returning a slice of the fHead

Re: the best language I have ever met(?)

2016-11-19 Thread Igor Shirkalin via Digitalmars-d-learn
On Saturday, 19 November 2016 at 20:54:32 UTC, ketmar wrote: On Saturday, 19 November 2016 at 17:12:13 UTC, Igor Shirkalin wrote: string s = "%(%s, %)".format(a); writefln(s); } Accepted. Is it really needed to call 'writefln'? I mean 'f'. no. it's a leftover from the code without

Re: fPIC Error

2016-11-19 Thread Charles Hixson via Digitalmars-d-learn
On 11/18/2016 10:35 PM, deadalnix via Digitalmars-d-learn wrote: On Thursday, 3 November 2016 at 06:11:48 UTC, rikki cattermole wrote: [Environment32] DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/i386-linux-gnu -L--export-dynamic -fPIC

Re: Array operations with multidimensional arrays

2016-11-19 Thread John Colvin via Digitalmars-d-learn
On Saturday, 19 November 2016 at 19:36:50 UTC, Marduk wrote: On Saturday, 19 November 2016 at 17:37:58 UTC, John Colvin wrote: On Saturday, 19 November 2016 at 10:20:16 UTC, Marduk wrote: Additionally, I would like to assign 2D sub-arrays of a 3D array, i.e. something like the following:

Re: the best language I have ever met(?)

2016-11-19 Thread ketmar via Digitalmars-d-learn
On Saturday, 19 November 2016 at 17:12:13 UTC, Igor Shirkalin wrote: string s = "%(%s, %)".format(a); writefln(s); } Accepted. Is it really needed to call 'writefln'? I mean 'f'. no. it's a leftover from the code without format. it originally was `writefln("%(%s, %)", a);`, but i wanted

Re: Complex numbers are harder to use than in C

2016-11-19 Thread Marduk via Digitalmars-d-learn
On Saturday, 19 November 2016 at 12:55:57 UTC, Marc Schütz wrote: On Saturday, 19 November 2016 at 11:11:36 UTC, Nordlöw wrote: On Saturday, 19 November 2016 at 09:38:38 UTC, Marduk wrote: The difference is that D is more verbose. Am I missing something? Can we have C's behaviour in D?

Re: Complex numbers are harder to use than in C

2016-11-19 Thread Marduk via Digitalmars-d-learn
On Saturday, 19 November 2016 at 11:11:36 UTC, Nordlöw wrote: On Saturday, 19 November 2016 at 09:38:38 UTC, Marduk wrote: The difference is that D is more verbose. Am I missing something? Can we have C's behaviour in D? Something like auto I(T)(T im) if (isNumeric!T) { return

Re: Using mixin in array declarations

2016-11-19 Thread Marduk via Digitalmars-d-learn
On Saturday, 19 November 2016 at 13:57:26 UTC, Jonathan M Davis wrote: On Saturday, November 19, 2016 09:46:08 Marduk via Digitalmars-d-learn wrote: [...] A string mixin literally puts the code there. So, doing mixin("int n = 10"); double[n][n] m; is identical to int n = 10; double[n][n]

Re: Complex numbers are harder to use than in C

2016-11-19 Thread Marduk via Digitalmars-d-learn
On Saturday, 19 November 2016 at 16:17:08 UTC, Meta wrote: On Saturday, 19 November 2016 at 09:38:38 UTC, Marduk wrote: Dear all, I just discovered D and I am translating some numerical code I wrote in C. I was surprised to learn that there are at least two things that are easier in C than

Re: Array operations with multidimensional arrays

2016-11-19 Thread Marduk via Digitalmars-d-learn
On Saturday, 19 November 2016 at 17:37:58 UTC, John Colvin wrote: On Saturday, 19 November 2016 at 10:20:16 UTC, Marduk wrote: Additionally, I would like to assign 2D sub-arrays of a 3D array, i.e. something like the following: int[3][2][2] a; a[0] = [[2,2], [2,2]]; You have the dimensions

Re: shared arrray problem

2016-11-19 Thread Nicolas Gurrola via Digitalmars-d-learn
On Saturday, 19 November 2016 at 18:51:05 UTC, Charles Hixson wrote: ubyte[]header()@property{return fHead[4..$];} This method should do what you want. You are only returning a slice of the fHead array, so if the caller modifies the length it will only affect of the

Re: How to correct share data between threads?

2016-11-19 Thread Nicolas Gurrola via Digitalmars-d-learn
On Saturday, 19 November 2016 at 17:29:30 UTC, Konstantin Kutsevalov wrote: I need to receiving data in main thread and send its to other thread for processing. There is a simple (but wrong) code for example. What need I to change to make it correct? ``` import std.stdio, std.string,

shared arrray problem

2016-11-19 Thread Charles Hixson via Digitalmars-d-learn
I have a piece of code that looks thus: /**Returns an editable file header missing the header length and data * length portions. Those cannot be edited by a routine outside this class. * Access to them is available via the lenHead and lenRec functions. * Warning: Do NOT change the

Re: Array operations with multidimensional arrays

2016-11-19 Thread John Colvin via Digitalmars-d-learn
On Saturday, 19 November 2016 at 10:20:16 UTC, Marduk wrote: Additionally, I would like to assign 2D sub-arrays of a 3D array, i.e. something like the following: int[3][2][2] a; a[0] = [[2,2], [2,2]]; You have the dimensions the wrong way around. a is a 2 element array of 2 element arrays

How to correct share data between threads?

2016-11-19 Thread Konstantin Kutsevalov via Digitalmars-d-learn
I need to receiving data in main thread and send its to other thread for processing. There is a simple (but wrong) code for example. What need I to change to make it correct? ``` import std.stdio, std.string, std.array, core.thread, std.datetime, std.conv; int main() { Pumpurum pp

Re: the best language I have ever met(?)

2016-11-19 Thread Igor Shirkalin via Digitalmars-d-learn
On Saturday, 19 November 2016 at 00:28:36 UTC, Stefan Koch wrote: import std.stdio; import std.format; void main () { uint[$] a = [42, 69]; string s = "%(%s, %)".format(a); writefln(s); } Please don't post non-d. People might use it an then complain that it does not work. Let these

Re: the best language I have ever met(?)

2016-11-19 Thread Igor Shirkalin via Digitalmars-d-learn
On Friday, 18 November 2016 at 21:28:44 UTC, ketmar wrote: On Friday, 18 November 2016 at 20:31:57 UTC, Igor Shirkalin wrote: After 2 hours of brain breaking (as D newbie) I have come to: uint_array.map!(v=>"%x".format(v)).join(", ") Why 2 hours? Because I have started with 'joiner' function

Re: Complex numbers are harder to use than in C

2016-11-19 Thread Meta via Digitalmars-d-learn
On Saturday, 19 November 2016 at 09:38:38 UTC, Marduk wrote: Dear all, I just discovered D and I am translating some numerical code I wrote in C. I was surprised to learn that there are at least two things that are easier in C than in D: + Writing complex numbers C: complex double z = 2.0

Re: Why double not? (!!)

2016-11-19 Thread Patrick Schluter via Digitalmars-d-learn
On Saturday, 19 November 2016 at 15:50:26 UTC, Adam D. Ruppe wrote: On Saturday, 19 November 2016 at 15:40:38 UTC, Ryan wrote: Wouldn't this just be the same as auto hasConsole = cast(bool) GetConsoleCP(); ? Yes, it is in D, though the habit often comes from C where things are different. But

Re: Why double not? (!!)

2016-11-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 19 November 2016 at 15:40:38 UTC, Ryan wrote: Wouldn't this just be the same as auto hasConsole = cast(bool) GetConsoleCP(); ? Yes, it is in D, though the habit often comes from C where things are different. But people also may prefer !! for just being shorter and once you know

Re: Why double not? (!!)

2016-11-19 Thread Ryan via Digitalmars-d-learn
It's a more concise way of writing: GetConsoleCP() != 0 You can do this in C/C++ as well (and presumably some other languages). Hmmm... thinking about it, it does make perfect sense. The first ! converts it to bool, the other inverts it back to it's positive/negative state. Wouldn't

Re: Using mixin in array declarations

2016-11-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 19, 2016 09:46:08 Marduk via Digitalmars-d-learn wrote: > In C one can do the following: > > # define N 10 > > double M[N][N]; > > > In D I would like to achieve the same result. I tried with: > > mixin("int N = 10;"); > > double[N][N] M; > > > but the compiler (DMD)

Re: How to enable SIMD instructions in core.simd

2016-11-19 Thread e-y-e via Digitalmars-d-learn
On Saturday, 19 November 2016 at 13:11:18 UTC, e-y-e wrote: ... Sorry for the noise, I found an LDC issue [1] that explains where I am going wrong (in short, core.simd is not supported in LDC, instead ldc.simd should be used). [1] https://github.com/ldc-developers/ldc/issues/595

How to enable SIMD instructions in core.simd

2016-11-19 Thread e-y-e via Digitalmars-d-learn
Found that I was not able to use SIMD as import core.simd : __simd; produces the error: 'module core.simd import '__simd' not found'. Upon further inspection I found that the D_SIMD version is not defined as version (D_SIMD) { pragma(msg, "SIMD Support"); } else { pragma(msg, "No

Re: Complex numbers are harder to use than in C

2016-11-19 Thread Marc Schütz via Digitalmars-d-learn
On Saturday, 19 November 2016 at 11:11:36 UTC, Nordlöw wrote: On Saturday, 19 November 2016 at 09:38:38 UTC, Marduk wrote: The difference is that D is more verbose. Am I missing something? Can we have C's behaviour in D? Something like auto I(T)(T im) if (isNumeric!T) { return

Re: Complex numbers are harder to use than in C

2016-11-19 Thread Nordlöw via Digitalmars-d-learn
On Saturday, 19 November 2016 at 09:38:38 UTC, Marduk wrote: The difference is that D is more verbose. Am I missing something? Can we have C's behaviour in D? Something like auto I(T)(T im) if (isNumeric!T) { return complex(0, im); } unittest { auto x = 1 + 2.I; }

Array operations with multidimensional arrays

2016-11-19 Thread Marduk via Digitalmars-d-learn
In the documentation one can learn how to do array operations with 1D arrays. However, this does not scale up for 2D arrays. For example, the following does not work: int[2][2] a,b; a = [[1,1],[1,1]]; b[][] = a[][]*2; Additionally, I would like to assign 2D sub-arrays of a 3D array, i.e.

Re: Using mixin in array declarations

2016-11-19 Thread Marduk via Digitalmars-d-learn
On Saturday, 19 November 2016 at 09:49:48 UTC, rikki cattermole wrote: On 19/11/2016 10:46 PM, Marduk wrote: In C one can do the following: # define N 10 double M[N][N]; In D I would like to achieve the same result. I tried with: mixin("int N = 10;"); double[N][N] M; but the compiler

Missing features from numpy

2016-11-19 Thread Marduk via Digitalmars-d-learn
In order to make D more useful for writing numerical code I would like to suggest the following extensions for built-in functions: 1. Generate random arrays 2. Arithmetic operations with arrays 3. Mathematical functions evaluated element-wise for arrays I am aware of the existence of

Re: Using mixin in array declarations

2016-11-19 Thread rikki cattermole via Digitalmars-d-learn
On 19/11/2016 10:46 PM, Marduk wrote: In C one can do the following: # define N 10 double M[N][N]; In D I would like to achieve the same result. I tried with: mixin("int N = 10;"); double[N][N] M; but the compiler (DMD) complained with Error: variable N cannot be read at compile time.

Re: what is mean? ( Offset 78887H Record Type 00C3)

2016-11-19 Thread xky via Digitalmars-d-learn
On Saturday, 19 November 2016 at 09:35:33 UTC, Basile B. wrote: No, OPTLINK is the right linker for DMD32 (because of the object format, OMF), unless you use the -mscoff32 switch (which has for effect to produce another object format, that OPTLINK doesn't know to link). Your issue is likely

Using mixin in array declarations

2016-11-19 Thread Marduk via Digitalmars-d-learn
In C one can do the following: # define N 10 double M[N][N]; In D I would like to achieve the same result. I tried with: mixin("int N = 10;"); double[N][N] M; but the compiler (DMD) complained with Error: variable N cannot be read at compile time. What am I doing wrong?

Complex numbers are harder to use than in C

2016-11-19 Thread Marduk via Digitalmars-d-learn
Dear all, I just discovered D and I am translating some numerical code I wrote in C. I was surprised to learn that there are at least two things that are easier in C than in D: + Writing complex numbers C: complex double z = 2.0 + 3.0*I; D: auto z = complex(2.0, 3.0); + Arrays of complex

Re: what is mean? ( Offset 78887H Record Type 00C3)

2016-11-19 Thread Basile B. via Digitalmars-d-learn
On Saturday, 19 November 2016 at 08:59:36 UTC, xky wrote: On Saturday, 19 November 2016 at 07:12:49 UTC, Nicholas Wilson wrote: If you're using x64 then you should be using the microsoft linker. ok are you invoking the linker manually? no... So, I got msbuild.zip from another website and

Re: what is mean? ( Offset 78887H Record Type 00C3)

2016-11-19 Thread xky via Digitalmars-d-learn
On Saturday, 19 November 2016 at 08:29:08 UTC, Era Scarecrow wrote: On Saturday, 19 November 2016 at 07:12:49 UTC, Nicholas Wilson wrote: If you're using x64 then you should be using the microsoft linker. are you invoking the linker manually? I would guess that some files are old and

Re: what is mean? ( Offset 78887H Record Type 00C3)

2016-11-19 Thread xky via Digitalmars-d-learn
On Saturday, 19 November 2016 at 07:12:49 UTC, Nicholas Wilson wrote: If you're using x64 then you should be using the microsoft linker. ok are you invoking the linker manually? no... So, I got msbuild.zip from another website and found link.exe. Can I replace this with

Re: what is mean? ( Offset 78887H Record Type 00C3)

2016-11-19 Thread Era Scarecrow via Digitalmars-d-learn
On Saturday, 19 November 2016 at 07:12:49 UTC, Nicholas Wilson wrote: If you're using x64 then you should be using the microsoft linker. are you invoking the linker manually? I would guess that some files are old and compiled separately, and the source was changed at some point. But we

Re: Why double not? (!!)

2016-11-19 Thread Is it possible to store different generic types? via Digitalmars-d-learn
On Saturday, 19 November 2016 at 07:51:36 UTC, Is it possible to store different generic types? wrote: On Saturday, 19 November 2016 at 06:58:38 UTC, Era Scarecrow wrote: On Saturday, 19 November 2016 at 04:54:22 UTC, Xinok wrote: On Saturday, 19 November 2016 at 03:52:02 UTC, Ryan wrote: Why