Re: Interfacing via Java Native Interface

2013-10-24 Thread Adam D. Ruppe
On Wednesday, 16 October 2013 at 14:39:23 UTC, Andrew wrote: Concluding, I can post the could if you like, or I can first try compiling it for ARM :-) whatever's easiest for you. I have an arm cross compiler targeting the raspberry pi, not sure if that will work for the android device or not,

Re: D / GtkD for SQL Server

2013-10-24 Thread Adam D. Ruppe
On Tuesday, 22 October 2013 at 06:33:04 UTC, John Joyus wrote: That works! Thanks. cool. If you need anything more in this, let me know (feel free to email me directly too destructiona...@gmail.com ) and i'll see what I can do. The 99% of my programs demand a basic GUI. And I personally lo

Re: running a command in a directory using std.process

2013-10-24 Thread Benjamin Thaut
Am 24.10.2013 19:03, schrieb Timothee Cour: +1 this is a command use case. Further,relying on shell such as cd subdir && foo is fragile: if it fails, we're not sure whether it's because it couldn't cd to subdir or because of foo. Woudl the following be as efficient? system_in_dir(string dir, st

Re: casting issue

2013-10-24 Thread Alexandr Druzhinin
25.10.2013 02:08, Adam D. Ruppe пишет: On Thursday, 24 October 2013 at 17:59:03 UTC, Alexandr Druzhinin wrote: foo(cast(float[]) points); // is it safe? Two options would be to make the points itself be a float[] with the names just properties into the index: struct Point { float[7] data;

Re: casting issue

2013-10-24 Thread Adam D. Ruppe
On Thursday, 24 October 2013 at 17:59:03 UTC, Alexandr Druzhinin wrote: foo(cast(float[]) points); // is it safe? Two options would be to make the points itself be a float[] with the names just properties into the index: struct Point { float[7] data; ref float x() { return data[0]; } ref

Re: conv text and pure

2013-10-24 Thread H. S. Teoh
On Thu, Oct 24, 2013 at 11:36:09AM -0700, H. S. Teoh wrote: > On Thu, Oct 24, 2013 at 12:12:48AM +0200, Daniel Davidson wrote: > [...] > > Here is the self-contained code (I hope) that you can see it > > happening in: > > http://pastebin.com/hb0Dz50r > [...] > > Hmm. Somebody claimed that 2.064 be

Re: conv text and pure

2013-10-24 Thread H. S. Teoh
On Thu, Oct 24, 2013 at 12:12:48AM +0200, Daniel Davidson wrote: [...] > Here is the self-contained code (I hope) that you can see it > happening in: > http://pastebin.com/hb0Dz50r [...] Hmm. Somebody claimed that 2.064 beta has made text() pure, but that's only partially true, because it calls to

Re: casting issue

2013-10-24 Thread Dicebot
On Thursday, 24 October 2013 at 17:59:03 UTC, Alexandr Druzhinin wrote: May I cast like: struct Point { float x, y, z; float r, g, b, a; } Point[] points; void foo(float[] float_array) {}; foo(cast(float[]) points); // is it safe? May be more elegant way do express this exist

Re: proper way to find if attribute present?

2013-10-24 Thread Adam D. Ruppe
On Thursday, 24 October 2013 at 16:22:44 UTC, Daniel Davidson wrote: template hasAnnotation(alias f, Attr) { This function looks for annotations as identified by type. Instead of using a plain string, you should make them some kind of struct: struct MyAnnotation { string value; } Then y

casting issue

2013-10-24 Thread Alexandr Druzhinin
May I cast like: struct Point { float x, y, z; float r, g, b, a; } Point[] points; void foo(float[] float_array) {}; foo(cast(float[]) points); // is it safe? May be more elegant way do express this exists? Thanks

Re: proper way to find if attribute present?

2013-10-24 Thread Dicebot
I use this small helper in vibe.d: === template extractUda(UDA, alias Symbol) { import std.typetuple : TypeTuple; private alias TypeTuple!(__traits(getAttributes, Symbol)) udaTuple; private template extract(list...) { static if (!list.length)

Re: proper way to find if attribute present?

2013-10-24 Thread Adam D. Ruppe
On Thursday, 24 October 2013 at 17:36:42 UTC, Jonathan M Davis wrote: You should probably use std.traits.functionAttributes: it doesn't list UDAs though.

Re: proper way to find if attribute present?

2013-10-24 Thread Jonathan M Davis
On Thursday, October 24, 2013 18:22:43 Daniel Davidson wrote: > enum Bar = "Bar"; > @("Foo") @Bar int x; > pragma(msg, __traits(getAttributes, x)); > > This prints: tuple("Foo", "Bar") > > How do you run code only if "Bar" is associated with a symbol > like x? > I was hoping something like this:

Re: running a command in a directory using std.process

2013-10-24 Thread Timothee Cour
+1 this is a command use case. Further,relying on shell such as cd subdir && foo is fragile: if it fails, we're not sure whether it's because it couldn't cd to subdir or because of foo. Woudl the following be as efficient? system_in_dir(string dir, string action){ auto path=getcwd scope(exit) c

Re: Bug in RefCounted?

2013-10-24 Thread Ali Çehreli
On 10/24/2013 07:58 AM, Rene Zwanenburg wrote: I'm writing a D wrapper for a C library. I was planning to use RefCounted structs to control the lifetime of objects created by this library. Please check the following example: http://dpaste.dzfl.pl/b49962bf Foo would be an opaque struct. createFo

Re: "extern" template instantiation

2013-10-24 Thread Dmitry Olshansky
24-Oct-2013 20:30, Mathias LANG пишет: On Wednesday, 23 October 2013 at 11:58:17 UTC, Dicebot wrote: Using `enum` with ctRegex is discouraged because it is a dumb copy-paste upon every enum usage. I'd recommend to use global variable initialized during compile-time: ``` auto r = ctRegex!(r"^(\w

Re: Bug in RefCounted?

2013-10-24 Thread Jesse Phillips
On Thursday, 24 October 2013 at 14:58:21 UTC, Rene Zwanenburg wrote: I'm writing a D wrapper for a C library. I was planning to use RefCounted structs to control the lifetime of objects created by this library. Please check the following example: http://dpaste.dzfl.pl/b49962bf Foo would be an

Re: "extern" template instantiation

2013-10-24 Thread Mathias LANG
On Wednesday, 23 October 2013 at 11:58:17 UTC, Dicebot wrote: Using `enum` with ctRegex is discouraged because it is a dumb copy-paste upon every enum usage. I'd recommend to use global variable initialized during compile-time: ``` auto r = ctRegex!(r"^(\w+)\s+([a-zA-Z0-9/]+)\?a=(\w+)&b=(\w+)

proper way to find if attribute present?

2013-10-24 Thread Daniel Davidson
enum Bar = "Bar"; @("Foo") @Bar int x; pragma(msg, __traits(getAttributes, x)); This prints: tuple("Foo", "Bar") How do you run code only if "Bar" is associated with a symbol like x? I was hoping something like this: pragma(msg, hasAnnotation!(x, Bar)); Where getAnnotation from (http://forum

Bug in RefCounted?

2013-10-24 Thread Rene Zwanenburg
I'm writing a D wrapper for a C library. I was planning to use RefCounted structs to control the lifetime of objects created by this library. Please check the following example: http://dpaste.dzfl.pl/b49962bf Foo would be an opaque struct. createFoo() and destroyFoo() would be implemented in

Re: GhostDoc for VisualD?

2013-10-24 Thread Namespace
On Thursday, 24 October 2013 at 11:59:37 UTC, qznc wrote: On Wednesday, 23 October 2013 at 15:56:33 UTC, Namespace wrote: Is there anything like this for VisualD? As far as I understand the GhostDoc website it generates prose comments from the type information? The only reason I can think of

Re: GhostDoc for VisualD?

2013-10-24 Thread qznc
On Wednesday, 23 October 2013 at 15:56:33 UTC, Namespace wrote: Is there anything like this for VisualD? As far as I understand the GhostDoc website it generates prose comments from the type information? The only reason I can think of are weird enterprise requirements like "every method must

Re: Copying to an immutable array in a costructor

2013-10-24 Thread Maxim Fomin
On Thursday, 24 October 2013 at 10:58:30 UTC, bearophile wrote: Jonathan M Davis: It's a compiler bug. immutable data should not be initialized more than once. My point was another one, regarding this refused code: import std.algorithm: copy; immutable int[2] data; static this() { [10,

Re: Copying to an immutable array in a costructor

2013-10-24 Thread Maxim Fomin
On Thursday, 24 October 2013 at 07:02:25 UTC, bearophile wrote: This shows a limitation of the D type system: import std.algorithm: copy; immutable int[2] data; static this() { foreach (i, x; [10, 20]) data[i] = x; // OK data[] = [10, 20]; // OK [10, 20].copy(data[]); // Error. } vo

Re: matrix business in D

2013-10-24 Thread Yura
Thank you very much for your help! I think I start to understand it better. On Wednesday, 23 October 2013 at 14:48:52 UTC, John Colvin wrote: On Wednesday, 23 October 2013 at 14:00:46 UTC, Yura wrote: Dear all, Thank you for your replies! Regarding Julia - it seems to be interesting, but - i

Re: Copying to an immutable array in a costructor

2013-10-24 Thread bearophile
Jonathan M Davis: It's a compiler bug. immutable data should not be initialized more than once. My point was another one, regarding this refused code: import std.algorithm: copy; immutable int[2] data; static this() { [10, 20].copy(data[]); // Error. } void main() {} Bye, bearophile

Re: A question about std.uri

2013-10-24 Thread Danny Arends
On Thursday, 24 October 2013 at 09:46:52 UTC, Danny Arends wrote: Some people on the IRC channel said it might be a bug: http://d.puremagic.com/issues/show_bug.cgi?id=11338 Gr, Danny Arends And a pull request: https://github.com/D-Programming-Language/phobos/pull/1659 Gr, Danny Arends htt

Re: A question about std.uri

2013-10-24 Thread Danny Arends
On Thursday, 24 October 2013 at 08:35:15 UTC, Danny Arends wrote: Is there a reason why the decode/encode functions and such throw Errors ? Seems like an error (Non-recoverable) is a bit harsh, why isn't the Exception class used ? Kind regards, Danny Arends http://www.dannyarends.nl Some

Static if/else blocks and ddoc

2013-10-24 Thread Joseph Rushton Wakeling
Hello all, An interesting observation I made today: if you have a static if/else block in your code, then ddoc will ignore anything inside the else block. I've filed this as a bug report: http://d.puremagic.com/issues/show_bug.cgi?id=11337 ... but I wonder if anyone can give insight into why

A question about std.uri

2013-10-24 Thread Danny Arends
Is there a reason why the decode/encode functions and such throw Errors ? Seems like an error (Non-recoverable) is a bit harsh, why isn't the Exception class used ? Kind regards, Danny Arends http://www.dannyarends.nl

Re: Copying to an immutable array in a costructor

2013-10-24 Thread Jonathan M Davis
On Thursday, October 24, 2013 09:02:24 bearophile wrote: > This shows a limitation of the D type system: > > > import std.algorithm: copy; > immutable int[2] data; > static this() { > foreach (i, x; [10, 20]) data[i] = x; // OK > data[] = [10, 20]; // OK > [10, 20].copy(data[]); //

Re: running a command in a directory using std.process

2013-10-24 Thread Benjamin Thaut
Am 24.10.2013 09:06, schrieb simendsjo: On Thursday, 24 October 2013 at 06:25:40 UTC, Benjamin Thaut wrote: As far as I can tell std.process can only run commands in the working directory of the currently executing function. I want to execute a certain program inside a subdirectory on windows an

Re: running a command in a directory using std.process

2013-10-24 Thread simendsjo
On Thursday, 24 October 2013 at 06:25:40 UTC, Benjamin Thaut wrote: As far as I can tell std.process can only run commands in the working directory of the currently executing function. I want to execute a certain program inside a subdirectory on windows and can't get it to work: myproject |-

Copying to an immutable array in a costructor

2013-10-24 Thread bearophile
This shows a limitation of the D type system: import std.algorithm: copy; immutable int[2] data; static this() { foreach (i, x; [10, 20]) data[i] = x; // OK data[] = [10, 20]; // OK [10, 20].copy(data[]); // Error. } void main() {} Bye, bearophile