Re: How to avoid multiple spelling `import`

2015-06-16 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 16 Jun 2015 11:45:22 + Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Maybe not everyone needs these features. But, unfortunately, I often use a lot of imported modules. And use every time the word `import` very bad. version (none) { import

Re: Calling a cpp function from d

2015-06-16 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 16 Jun 2015 13:01:09 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Tuesday, 16 June 2015 at 12:42:16 UTC, C2D wrote: On Tuesday, 16 June 2015 at 12:31:23 UTC, John Chapman wrote: On Tuesday, 16 June 2015 at 12:26:45 UTC, C2D wrote: BOOL result =

Re: Casting MapResult

2015-06-16 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 13:06:58 UTC, jmh530 wrote: On Monday, 15 June 2015 at 22:40:31 UTC, Baz wrote: Right, my bad. This one whould work: --- float[] test(float[] x) { auto result = x.dup; result.each!((ref a) = (a = exp(a))); return result; } --- That works. Thanks. I

Re: Calling a cpp function from d

2015-06-16 Thread via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 12:42:16 UTC, C2D wrote: On Tuesday, 16 June 2015 at 12:31:23 UTC, John Chapman wrote: On Tuesday, 16 June 2015 at 12:26:45 UTC, C2D wrote: BOOL result = SHGetFolderPath(null, 0x23, null, 0, cache.ptr); That should be: BOOL result = SHGetFolderPath(null, 0x23,

Re: Casting MapResult

2015-06-16 Thread jmh530 via Digitalmars-d-learn
On Monday, 15 June 2015 at 22:40:31 UTC, Baz wrote: Right, my bad. This one whould work: --- float[] test(float[] x) { auto result = x.dup; result.each!((ref a) = (a = exp(a))); return result; } --- That works. Thanks. I did some benchmarking and found that map tended to be

Re: Calling a cpp function from d

2015-06-16 Thread John Chapman via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 12:26:45 UTC, C2D wrote: BOOL result = SHGetFolderPath(null, 0x23, null, 0, cache.ptr); That should be: BOOL result = SHGetFolderPath(null, 0x23, null, 0, buf.ptr);

Re: Calling a cpp function from d

2015-06-16 Thread FreeSlave via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 12:26:45 UTC, C2D wrote: Hi, I encountered the following error: Error: function files.SHGetFolderPath (void* hwndOwner, int nFolder, void* hToken, uint dwFlags, char* pszPath) is not callable using argument types (typeof(null), int, typeof(null), int,

Re: Calling a cpp function from d

2015-06-16 Thread Daniel Kozák via Digitalmars-d-learn
On Tue, 16 Jun 2015 12:26:45 + C2D via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hi, I encountered the following error: Error: function files.SHGetFolderPath (void* hwndOwner, int nFolder, void* hToken, uint dwFlags, char* pszPath) is not callable using argument

Re: Calling a cpp function from d

2015-06-16 Thread C2D via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 12:31:23 UTC, John Chapman wrote: On Tuesday, 16 June 2015 at 12:26:45 UTC, C2D wrote: BOOL result = SHGetFolderPath(null, 0x23, null, 0, cache.ptr); That should be: BOOL result = SHGetFolderPath(null, 0x23, null, 0, buf.ptr); Thanks, but I'm still getting the

Re: Calling a cpp function from d

2015-06-16 Thread FreeSlave via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 13:31:47 UTC, FreeSlave wrote: Also you may want to take a look at my library [1] where I use SHGetSpecialFolderPath (I know, it's deprecated, but it still works, so why not. I don't really need to bother with access tokens here). Note that I load shell32

Calling a cpp function from d

2015-06-16 Thread C2D via Digitalmars-d-learn
Hi, I encountered the following error: Error: function files.SHGetFolderPath (void* hwndOwner, int nFolder, void* hToken, uint dwFlags, char* pszPath) is not callable using argument types (typeof(null), int, typeof(null), int, immutable(char)*) When I'm try to run this code: ... { import

Re: Casting MapResult

2015-06-16 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 13:15:05 UTC, John Colvin wrote: *consistent as in different implementations performing very similarly instead of seeing big differences like you have here. That's a good point. I tried numpy's exp (which uses C at a low level, I think) and found it takes about

Re: How to avoid multiple spelling `import`

2015-06-16 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 12:41:14 UTC, Daniel Kozák wrote: On Tue, 16 Jun 2015 11:45:22 + Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I just want to import individual features of these modules. mixin template include(w...) { mixin

Re: Embedding dll in a D project

2015-06-16 Thread CallToDuty via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 16:57:52 UTC, John Colvin wrote: On Tuesday, 16 June 2015 at 16:42:31 UTC, CallToDuty wrote: Is it possible to embed a dll file within dub project? and if yes, how? Have you tried just putting it in the root directory of the project and adding the relevant name to

Embedding dll in a D project

2015-06-16 Thread CallToDuty via Digitalmars-d-learn
Is it possible to embed a dll file within dub project? and if yes, how?

Re: How to avoid multiple spelling `import`

2015-06-16 Thread tired_eyes via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 15:42:02 UTC, Dennis Ritchie wrote: On Tuesday, 16 June 2015 at 12:41:14 UTC, Daniel Kozák wrote: On Tue, 16 Jun 2015 11:45:22 + Dennis Ritchie via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I just want to import individual features of these

Re: Casting MapResult

2015-06-16 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 14:43:17 UTC, jmh530 wrote: On Tuesday, 16 June 2015 at 13:15:05 UTC, John Colvin wrote: *consistent as in different implementations performing very similarly instead of seeing big differences like you have here. That's a good point. I tried numpy's exp (which

Re: Casting MapResult

2015-06-16 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 14:43:17 UTC, jmh530 wrote: On Tuesday, 16 June 2015 at 13:15:05 UTC, John Colvin wrote: *consistent as in different implementations performing very similarly instead of seeing big differences like you have here. That's a good point. I tried numpy's exp (which

Re: CPU cores threads fibers

2015-06-16 Thread Rob T via Digitalmars-d-learn
On Sunday, 14 June 2015 at 15:54:30 UTC, Etienne Cimon wrote: On 2015-06-14 08:35, Robert M. Münch wrote: Hi, just to x-check if I have the correct understanding: fibers = look parallel, are sequential = use 1 CPU core threads = look parallel, are parallel = use several CPU

Re: Embedding dll in a D project

2015-06-16 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 16:42:31 UTC, CallToDuty wrote: Is it possible to embed a dll file within dub project? and if yes, how? Do you want to write the DLL in D or another language?

Re: Embedding dll in a D project

2015-06-16 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 16:42:31 UTC, CallToDuty wrote: Is it possible to embed a dll file within dub project? and if yes, how? Have you tried just putting it in the root directory of the project and adding the relevant name to the libs setting in your dub.json ?

Defining constant values in struct

2015-06-16 Thread tcak via Digitalmars-d-learn
As far as I known, when I define a string with enum and it is used at different parts of code, that string is repeated again and again in executable file instead of passing a pointer to string. So, using enum with string doesn't seem like a good idea. Hence, I defined string as const to make

Re: Defining constant values in struct

2015-06-16 Thread jklp via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 21:17:37 UTC, tcak wrote: As far as I known, when I define a string with enum and it is used at different parts of code, that string is repeated again and again in executable file instead of passing a pointer to string. So, using enum with string doesn't seem like a

Re: Defining constant values in struct

2015-06-16 Thread anonymous via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 21:17:37 UTC, tcak wrote: As far as I known, when I define a string with enum and it is used at different parts of code, that string is repeated again and again in executable file instead of passing a pointer to string. So, using enum with string doesn't seem like a

Re: Defining constant values in struct

2015-06-16 Thread tcak via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 21:38:22 UTC, jklp wrote: On Tuesday, 16 June 2015 at 21:17:37 UTC, tcak wrote: [...] Do i miss a detail in your requirement ? --- struct TableSchema{ const string TABLE = users; struct FieldTypes{ static const string ID = BIGINT;

Re: Casting MapResult

2015-06-16 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 16:38:55 UTC, John Colvin wrote: What OS are you on? See http://wiki.dlang.org/Compilers I'm on Windows 7 at work, and I have both Win7 and linux at home. I figure I can try it on linux at home. Sometimes the work computer is a bit funky with installing things,

Adding Lua libraries to LuaD?

2015-06-16 Thread lzed via Digitalmars-d-learn
Did somebody managed to do this or something similar?

Re: Casting MapResult

2015-06-16 Thread jmh530 via Digitalmars-d-learn
Err...vectors not matrices.

Calling DLL coded in D from Java

2015-06-16 Thread DlangLearner via Digitalmars-d-learn
I'd like to know if it is possible to call an DLL coded in D from Java? I don't have any knowledge on DLL calling mechanism, so I am wondering if this is possible or any special procedure should be followed. I indeed tried a small example but didn't succeed. First I created an DLL from the

Re: Defining constant values in struct

2015-06-16 Thread Alex Parrill via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 21:17:37 UTC, tcak wrote: As far as I known, when I define a string with enum and it is used at different parts of code, that string is repeated again and again in executable file instead of passing a pointer to string. So, using enum with string doesn't seem like a

Re: Defining constant values in struct

2015-06-16 Thread Mike Parker via Digitalmars-d-learn
On 6/17/2015 6:17 AM, tcak wrote: As far as I known, when I define a string with enum and it is used at different parts of code, that string is repeated again and again in executable file instead of passing a pointer to string. So, using enum with string doesn't seem like a good idea. The

Re: Calling DLL coded in D from Java

2015-06-16 Thread Rikki Cattermole via Digitalmars-d-learn
On 17/06/2015 2:18 p.m., bitwise wrote: On Tue, 16 Jun 2015 18:47:03 -0400, DlangLearner bystan...@gmail.com wrote: I'd like to know if it is possible to call an DLL coded in D from Java? What you're looking for is JNI (Java Native Interface). If you export your D functions correctly, as

Re: How to avoid multiple spelling `import`

2015-06-16 Thread tired_eyes via Digitalmars-d-learn
On Wednesday, 17 June 2015 at 01:56:45 UTC, flamencofantasy wrote: On Tuesday, 16 June 2015 at 16:40:39 UTC, tired_eyes wrote: On Tuesday, 16 June 2015 at 15:42:02 UTC, Dennis Ritchie wrote: On Tuesday, 16 June 2015 at 12:41:14 UTC, Daniel Kozák wrote: [...] Thanks. Maybe I'll use this code

Re: Adding Lua libraries to LuaD?

2015-06-16 Thread Rikki Cattermole via Digitalmars-d-learn
On 17/06/2015 7:49 a.m., lzed wrote: Did somebody managed to do this or something similar? Like this? https://github.com/rikkimax/skeleton/blob/master/source/skeleton/syntax/luasyn.d

Re: How to avoid multiple spelling `import`

2015-06-16 Thread flamencofantasy via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 16:40:39 UTC, tired_eyes wrote: On Tuesday, 16 June 2015 at 15:42:02 UTC, Dennis Ritchie wrote: On Tuesday, 16 June 2015 at 12:41:14 UTC, Daniel Kozák wrote: [...] Thanks. Maybe I'll use this code in your own programs. I still believe that this design deserves

Re: Calling DLL coded in D from Java

2015-06-16 Thread bitwise via Digitalmars-d-learn
On Tue, 16 Jun 2015 18:47:03 -0400, DlangLearner bystan...@gmail.com wrote: I'd like to know if it is possible to call an DLL coded in D from Java? What you're looking for is JNI (Java Native Interface). If you export your D functions correctly, as you have done(extern(C) export) then

Re: More type-flexible arrays?

2015-06-16 Thread thedeemon via Digitalmars-d-learn
On Sunday, 14 June 2015 at 06:12:30 UTC, Ozan wrote: Is it possible to create arrays which has more then one type, f. ex. array[0] = 1; array[1] = z; array[2] = new clazz(), Probably tuples are what you really need here. http://dlang.org/phobos/std_typecons.html#.Tuple

Re: dmd/druntime/phobos HEAD: can't link binaries on Arch Linux

2015-06-16 Thread Atila Neves via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 01:18:29 UTC, Vladimir Panteleev wrote: Not using Arch Linux, but just from your post it looks like it's not finding the libphobos.a from HEAD and using the system one instead. You may want to check the dmd.conf file for your HEAD D install: make sure DMD is using

How to avoid multiple spelling `import`

2015-06-16 Thread Dennis Ritchie via Digitalmars-d-learn
Hi, I can write this: import std.range : chain, split; But I can not write this: import std.range : chain, split, std.algorithm : map, each; We have several times to write the word `import`: import std.range : chain, split; import std.algorithm : map, each; Does D something to solve this

Re: How to avoid multiple spelling `import`

2015-06-16 Thread Idan Arye via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 09:33:22 UTC, Dennis Ritchie wrote: Hi, I can write this: import std.range : chain, split; But I can not write this: import std.range : chain, split, std.algorithm : map, each; We have several times to write the word `import`: import std.range : chain, split;

Re: How to avoid multiple spelling `import`

2015-06-16 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 16 June 2015 at 11:16:32 UTC, Idan Arye wrote: There is no problem to be solved here. Having to type `import` for each imported module is not big enough a burden to justify this additional syntax. No, I think it is a holdover from C++-times — to write `import` for each

Re: How to avoid multiple spelling `import`

2015-06-16 Thread Dennis Ritchie via Digitalmars-d-learn
Maybe not everyone needs these features. But, unfortunately, I often use a lot of imported modules. And use every time the word `import` very bad. version (none) { import std.math, std.conv, std.stdio, std.ascii, std.range, std.array, std.regex,