Re: Calling Syntax (no, not UFCS)

2015-08-03 Thread John Colvin via Digitalmars-d-learn
On Monday, 3 August 2015 at 22:42:15 UTC, SirNickolas wrote: Hello! I'm new in D and it is amazing! Can you tell me please if it is discouraged or deprecated to call a function by just putting its name, without brackets? It's quite unusual for me (used C++ and Python before), but I can see

Re: Calling Syntax (no, not UFCS)

2015-08-03 Thread Justin Whear via Digitalmars-d-learn
On Mon, 03 Aug 2015 22:42:14 +, SirNickolas wrote: Hello! I'm new in D and it is amazing! Can you tell me please if it is discouraged or deprecated to call a function by just putting its name, without brackets? It's quite unusual for me (used C++ and Python before), but I can see this

Re: Array start index

2015-08-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 03, 2015 21:32:03 DLearner via Digitalmars-d-learn wrote: On Monday, 3 August 2015 at 13:45:01 UTC, bachmeier wrote: On Sunday, 2 August 2015 at 21:58:48 UTC, QAston wrote: Adding 1-indexed arrays to the language fixes nothing. Just write your 1-indexed array type and if

Re: D array to void* and back

2015-08-03 Thread Ali Çehreli via Digitalmars-d-learn
On 08/03/2015 02:33 PM, ref2401 wrote: On Monday, 3 August 2015 at 21:28:29 UTC, Ali Çehreli wrote: But you still need to communicate how many elements there are in the array. (I used literal 3). Yes I do. I hope there is a neat way to pass array's length too. Not possible in C. :( Common

DUB linking to local library

2015-08-03 Thread Craig Dillabaugh via Digitalmars-d-learn
I have been writing bindings for the GDAL library (www.gdal.org). I recently updated my bindings to the latest release of GDAL (2.0). Before adding my bindings to code.dlang.org I want to run some tests. I've built GDAL2 locally and want to link my bindings to this library. However, I

Calling Syntax (no, not UFCS)

2015-08-03 Thread SirNickolas via Digitalmars-d-learn
Hello! I'm new in D and it is amazing! Can you tell me please if it is discouraged or deprecated to call a function by just putting its name, without brackets? It's quite unusual for me (used C++ and Python before), but I can see this practice even in the official Phobos documentation: ```

Re: D array to void* and back

2015-08-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/3/15 5:23 PM, ref2401 wrote: Hello everyone, I pass a D array as void* into a function. When I'm trying to cast a void* parameter to a D array I get 'Access Violation' error. However if I define ArrayLike struct which looks like D array then casting will succeed. What should I do? Should

Re: Calling Syntax (no, not UFCS)

2015-08-03 Thread sigod via Digitalmars-d-learn
On Monday, 3 August 2015 at 22:42:15 UTC, SirNickolas wrote: Hello! I'm new in D and it is amazing! Can you tell me please if it is discouraged or deprecated to call a function by just putting its name, without brackets? It's quite unusual for me (used C++ and Python before), but I can see

Re: DUB linking to local library

2015-08-03 Thread via Digitalmars-d-learn
On Tuesday, 4 August 2015 at 02:26:17 UTC, Craig Dillabaugh wrote: So how can I force my application to link to my local copy of GDAL2 at /home/craig2/code/gdal-2.0.0/lib64. Any help is appreciated. Hi, I recently ran into similare problems, different lib. Try changing: lflags :

Re: DUB linking to local library

2015-08-03 Thread via Digitalmars-d-learn
On Tuesday, 4 August 2015 at 03:20:38 UTC, Craig Dillabaugh wrote: ldd gdaltest linux-vdso.so.1 (0x7ffe63381000) libgdal.so.20 = not found I can now run it with: LD_LIBRARY_PATH=/home/craig2/code/gdal-2.0.0/lib64 ./gdaltest But it appears the LD_LIBRARY_PATH hack is

Re: DUB linking to local library

2015-08-03 Thread Craig Dillabaugh via Digitalmars-d-learn
On Tuesday, 4 August 2015 at 02:45:21 UTC, Joakim Brännström wrote: On Tuesday, 4 August 2015 at 02:26:17 UTC, Craig Dillabaugh wrote: So how can I force my application to link to my local copy of GDAL2 at /home/craig2/code/gdal-2.0.0/lib64. Any help is appreciated. Hi, I recently ran into

Re: D array to void* and back

2015-08-03 Thread Ali Çehreli via Digitalmars-d-learn
On 08/03/2015 02:23 PM, ref2401 wrote: void funcLibC_Array(void* data) { int[] arr = *cast(int[]*)data; You are still in D, so int[] has a different meaning from a C array. (D's arrays are array-like. ;) ) Since arr.ptr is the pointer to the first element, and since that is exactly

D array to void* and back

2015-08-03 Thread ref2401 via Digitalmars-d-learn
Hello everyone, I pass a D array as void* into a function. When I'm trying to cast a void* parameter to a D array I get 'Access Violation' error. However if I define ArrayLike struct which looks like D array then casting will succeed. What should I do? Should I stick to ArrayLike wrapper and

Re: D array to void* and back

2015-08-03 Thread ref2401 via Digitalmars-d-learn
On Monday, 3 August 2015 at 21:28:29 UTC, Ali Çehreli wrote: But you still need to communicate how many elements there are in the array. (I used literal 3). Yes I do. I hope there is a neat way to pass array's length too.

Re: Array start index

2015-08-03 Thread DLearner via Digitalmars-d-learn
On Monday, 3 August 2015 at 13:45:01 UTC, bachmeier wrote: On Sunday, 2 August 2015 at 21:58:48 UTC, QAston wrote: Adding 1-indexed arrays to the language fixes nothing. Just write your 1-indexed array type and if you enjoy using it, publish it as a library. Who knows, if demand is high it

Re: !in operator

2015-08-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 02, 2015 21:51:48 Ali Çehreli via Digitalmars-d-learn wrote: Is my understanding below correct? Does any documentation need updating? Operator precedence table lists !in as an operator: http://wiki.dlang.org/Operator_precedence Operator overloading documentation does

Re: Struct that destroys its original handle on copy-by-value

2015-08-03 Thread Dicebot via Digitalmars-d-learn
On Monday, 3 August 2015 at 08:54:32 UTC, Kagamin wrote: On Saturday, 1 August 2015 at 11:47:29 UTC, Joseph Rushton Wakeling wrote: Yea, but that's not what I'm trying to achieve. I know how I can pass something to `take` so as to e.g. obtain reference semantics or whatever; what I'm trying

Re: Struct that destroys its original handle on copy-by-value

2015-08-03 Thread Kagamin via Digitalmars-d-learn
On Saturday, 1 August 2015 at 11:47:29 UTC, Joseph Rushton Wakeling wrote: Yea, but that's not what I'm trying to achieve. I know how I can pass something to `take` so as to e.g. obtain reference semantics or whatever; what I'm trying to achieve is a range that _doesn't rely on the user

Re: Struct that destroys its original handle on copy-by-value

2015-08-03 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On Monday, 3 August 2015 at 09:01:51 UTC, Dicebot wrote: It is now verified as safe by `return ref`. Yes, until you pointed this out to me I'd been convinced that classes were the way forward for RNGs. I think that `return ref` is going to be a _very_ powerful tool for facilitating

Re: Array start index

2015-08-03 Thread jmh530 via Digitalmars-d-learn
On Saturday, 1 August 2015 at 09:35:53 UTC, DLearner wrote: Does the D language set in stone that the first element of an array _has_ to be index zero? Wouldn't starting array elements at one avoid the common 'off-by-one' logic error, it does seem more natural to begin a count at 1. Actually,

Re: Array start index

2015-08-03 Thread bachmeier via Digitalmars-d-learn
On Sunday, 2 August 2015 at 21:58:48 UTC, QAston wrote: Adding 1-indexed arrays to the language fixes nothing. Just write your 1-indexed array type and if you enjoy using it, publish it as a library. Who knows, if demand is high it may even end up in phobos. Oh, I don't think that's a good

Re: Array start index

2015-08-03 Thread Observer via Digitalmars-d-learn
On Saturday, 1 August 2015 at 09:35:53 UTC, DLearner wrote: Does the D language set in stone that the first element of an array _has_ to be index zero? Wouldn't starting array elements at one avoid the common 'off-by-one' logic error, it does seem more natural to begin a count at 1. Actually,