Re: Dynamically Sized Structs

2014-04-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 April 2014 at 17:50:30 UTC, Dicebot wrote: On Thursday, 17 April 2014 at 17:45:22 UTC, Kagamin wrote: On Thursday, 17 April 2014 at 17:35:17 UTC, bearophile wrote: Kagamin: Bound checked version of variable size struct: http://dpaste.dzfl.pl/fcd91d6912d3 I think you are

Re: Dynamically Sized Structs

2014-04-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 April 2014 at 18:40:27 UTC, Kagamin wrote: And how heap indirection is different from stack indirection? It's still indirection. Locality. The stack is (within reason) readily available in cache.

Re: Partial ordering of constructors with type parameters

2014-04-23 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 23 April 2014 at 18:04:05 UTC, monarch_dodra wrote: If you can't update your compiler, an alternative is to make your non-template version an actual template: class Foo{ this(T : int)(T x){} this(T)(T x) {} } I haven't tested, but wouldn't this be more precisely

Re: Is this a bug?

2014-04-28 Thread John Colvin via Digitalmars-d-learn
On Monday, 28 April 2014 at 08:58:41 UTC, Andrey wrote: Could anyone please explain to me, why do I have error message on this piece of code? alias short Type1; alias Type1[100]* Type2; // pointer to an array struct Type3 { Type2 f } void foo() { Type3* b; Type1 d; d =

Re: Is this a bug?

2014-04-28 Thread John Colvin via Digitalmars-d-learn
On Monday, 28 April 2014 at 09:36:08 UTC, Andrey wrote: not a bug. b.f[10] is indexing the pointer to the array, not the array itself. b.f[0][10] is indexing the array (with the 10), but I would argue it is better to write *(b.f)[10] so as to be clear that f is not an array. thank you,

Re: Is this a bug?

2014-04-28 Thread John Colvin via Digitalmars-d-learn
On Monday, 28 April 2014 at 14:02:33 UTC, Steven Schveighoffer wrote: On Mon, 28 Apr 2014 06:04:53 -0400, John Colvin john.loughran.col...@gmail.com wrote: On Monday, 28 April 2014 at 09:36:08 UTC, Andrey wrote: not a bug. b.f[10] is indexing the pointer to the array, not the array itself.

Re: Is this a bug?

2014-04-29 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 29 April 2014 at 06:13:52 UTC, Andrey wrote: Ok, thanks a lot.. About dynamic arrays: I haven't found any information about internal representation of the D structures. E.g. do dynamic arrays have reference counter? Nevermind, I'm gonna use Type2[0] syntax. D dynamic arrays

private constructors and inheritance

2014-04-29 Thread John Colvin via Digitalmars-d-learn
//blah1.d class A { private this(){} } //blah2.d import blah1; class B : A {} $ dmd blah1.d blah2.d -lib Error: constructor blah1.A.this is not accessible from module blah2 Can someone explain why this can't/doesn't work? Thanks.

Re: private constructors and inheritance

2014-04-29 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 29 April 2014 at 13:59:30 UTC, John Colvin wrote: //blah1.d class A { private this(){} } //blah2.d import blah1; class B : A {} $ dmd blah1.d blah2.d -lib Error: constructor blah1.A.this is not accessible from module blah2 Can someone explain why this can't/doesn't

Re: Help plz: Using to libraries in D?

2014-04-29 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 29 April 2014 at 20:55:01 UTC, K.K. wrote: Hi! I've kinda got a few noob questions... I've been trying to learn D for the last few months, and I've got a pretty good grasp of the syntax, but I've been having trouble figuring out how to use libraries(excluding the standard lib).

Re: static if (__ctfe)

2014-05-07 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 7 May 2014 at 09:47:20 UTC, Yuriy wrote: Hello, is there any way to static if(__ctfe)? I want to declare class members which are only available in ctfe. Thanx. Sadly not as far as I know. What's the use-case? There may be a nice solution none-the-less.

Re: throws Exception in method

2014-05-08 Thread John Colvin via Digitalmars-d-learn
On Thursday, 8 May 2014 at 09:15:16 UTC, amehat wrote: Hello everyone, in java, you can have exceptions on methods. Thus we can write: public static void control (String string) throws MyException {} Is that possible in D and if so how does it work? If I write this D: public void testMe ()

Re: throws Exception in method

2014-05-08 Thread John Colvin via Digitalmars-d-learn
On Thursday, 8 May 2014 at 12:00:40 UTC, amehat wrote: On Thursday, 8 May 2014 at 10:14:27 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: On Thu, 08 May 2014 09:15:13 + amehat via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Hello everyone, in java, you can have

Re: Any chance to avoid monitor field in my class?

2014-05-08 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 7 May 2014 at 14:44:57 UTC, Yuriy wrote: Hello, is there a way of reducing size of an empty class to just vtbl? I tried to declare it as extern(C++) which works, but has a nasty side effect of limited mangling. Just a general FYI: Classes are relatively heavyweight in D.

Re: dxl (the d port of jexcelapi)

2014-05-08 Thread John Colvin via Digitalmars-d-learn
On Thursday, 8 May 2014 at 21:02:05 UTC, Taylor Hillegeist wrote: By the way the weblink is: http://www.dsource.org/projects/dexcelapi That will need some work before it works with modern D.

Re: sort struct of arrays

2014-05-09 Thread John Colvin via Digitalmars-d-learn
On Friday, 9 May 2014 at 14:23:41 UTC, Luís Marques wrote: If you have an array of structs, such as... struct Foo { int x; int y; } Foo[] foos; ...and you wanted to sort the foos then you'd do something like... foos.sort!(a.x b.x), ..and, of

Re: Any chance to avoid monitor field in my class?

2014-05-09 Thread John Colvin via Digitalmars-d-learn
On Friday, 9 May 2014 at 14:56:21 UTC, flamencofantasy wrote: One thing I hate about C# (which is what I use professionally) is the sync block index in every single class instance. Why not have the developer decide when he needs a Monitor and manually use it?! I am disappointed D took the same

Re: sort struct of arrays

2014-05-09 Thread John Colvin via Digitalmars-d-learn
On Friday, 9 May 2014 at 16:26:22 UTC, Rene Zwanenburg wrote: On Friday, 9 May 2014 at 15:52:51 UTC, John Colvin wrote: On Friday, 9 May 2014 at 14:23:41 UTC, Luís Marques wrote: If you have an array of structs, such as... struct Foo { int x; int y; } Foo[] foos;

Re: why can't I call const methods on shared objects?

2014-05-11 Thread John Colvin via Digitalmars-d-learn
On Friday, 9 May 2014 at 21:37:37 UTC, Vlad Levenfeld wrote: Error: non-shared const method is not callable using a shared mutable object Why not? If the method is const, it can't modify the object anyway. Because thread-safety isn't only a problem when writing to memory, reads must also

Re: question about passing associative array to a function

2014-05-11 Thread John Colvin via Digitalmars-d-learn
On Sunday, 11 May 2014 at 14:46:35 UTC, rbutler wrote: I have searched and can not understand something about passing AAs to a function. I have reduced the gist of the question to a tiny program below. If I put ref in the function stmt it works, i.e.: ref int[int] aa My confusion is

Re: question about passing associative array to a function

2014-05-11 Thread John Colvin via Digitalmars-d-learn
On Sunday, 11 May 2014 at 16:54:18 UTC, Ali Çehreli wrote: On 05/11/2014 07:46 AM, rbutler wrote: I have searched and can not understand something about passing AAs to a function. I have reduced the gist of the question to a tiny program below. If I put ref in the function stmt it works,

Re: Why std.algorithm.sort can't be applied to char[]?

2014-05-12 Thread John Colvin via Digitalmars-d-learn
On Monday, 12 May 2014 at 14:49:53 UTC, hane wrote: and is there any way to sort char array with algorithm.sort? --- import std.algorithm; import std.range; void main() { int[] arr = [5, 3, 7]; sort(arr); // OK char[] arr2 = ['z', 'g', 'c']; sort(arr2); // error sort!q{ a[0] b[0]

Re: Why std.algorithm.sort can't be applied to char[]?

2014-05-12 Thread John Colvin via Digitalmars-d-learn
On Monday, 12 May 2014 at 14:56:46 UTC, John Colvin wrote: On Monday, 12 May 2014 at 14:49:53 UTC, hane wrote: and is there any way to sort char array with algorithm.sort? --- import std.algorithm; import std.range; void main() { int[] arr = [5, 3, 7]; sort(arr); // OK char[] arr2 = ['z',

Re: Why std.algorithm.sort can't be applied to char[]?

2014-05-14 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 14 May 2014 at 08:27:46 UTC, monarch_dodra wrote: On Monday, 12 May 2014 at 18:44:22 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: Sure, you can cast char[] to ubyte[] and sort that if you know that the array only holds pure ASCII. In fact, you can use

Re: Cost of assoc array?

2014-05-14 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 14 May 2014 at 09:38:10 UTC, Chris wrote: I have code that uses the following: string[][size_t] myArray; 1. myArray = [0:[t, o, m], 1:[s, m, i, th]]; However, I've found out that I never need an assoc array and a linear array would be just fine, as in 2. myArray = [[t, o, m],

Re: Cost of assoc array?

2014-05-14 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 14 May 2014 at 13:20:40 UTC, Chris wrote: On Wednesday, 14 May 2014 at 11:13:10 UTC, John Colvin wrote: On Wednesday, 14 May 2014 at 09:38:10 UTC, Chris wrote: I have code that uses the following: string[][size_t] myArray; 1. myArray = [0:[t, o, m], 1:[s, m, i, th]]; However,

Re: Cost of assoc array?

2014-05-14 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 14 May 2014 at 13:49:22 UTC, bearophile wrote: Chris: foreach (size_t i; 0..myArray.length) { // do something with myArray[i]; } There are various better ways to use a foreach on an array: foreach (immutable x; myArray) { foreach (ref const x; myArray) { foreach (ref x;

Re: D Newbie Trying to Use D with Major C Libraries

2014-05-16 Thread John Colvin via Digitalmars-d-learn
On Friday, 16 May 2014 at 06:17:47 UTC, Jacob Carlborg wrote: On 15/05/14 23:27, Tom Browder via Digitalmars-d-learn wrote: I am a volunteer developer with the well-known 3D CAD FOSS project BRL-CAD: http://brlcad.org I have wanted to use D for a long time but I hadn't taken the plunge.

Re: std.concurrency thread communication problem

2014-05-17 Thread John Colvin via Digitalmars-d-learn
On Saturday, 17 May 2014 at 18:43:25 UTC, Charles Hixson via Digitalmars-d-learn wrote: I'm building a program which I intend to have many threads that can each send messages to (and receive messages from) each other. The obvious way to do this would be to have a shared array of Tids, but this

Re: Question about @nogc

2014-05-20 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 20 May 2014 at 12:25:11 UTC, Dominikus Dittes Scherkl wrote: Did I understand correct that a function can only be @nogc if also all functions that it calls are @nogc too (and of course it doesn't use the GC itself)? If so, should this be possible: string foo() { // use GC to

byCodePoint for a range of chars

2014-05-20 Thread John Colvin via Digitalmars-d-learn
Given a range with element type char, what's the best way of iterating over it by code-point, without filling an array first? Related to this: What's the status of std.utf and std.encoding? The comments in std.encoding say that some functions supersede their std.utf counterparts.

Re: byCodePoint for a range of chars

2014-05-20 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 20 May 2014 at 19:58:17 UTC, monarch_dodra wrote: On Tuesday, 20 May 2014 at 17:59:09 UTC, John Colvin wrote: Given a range with element type char, what's the best way of iterating over it by code-point, without filling an array first? Related to this: What's the status of

Re: Scalar + array operations

2014-05-21 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 21 May 2014 at 11:45:57 UTC, Stefan Frijters wrote: When working on my current project (writing a numerical simulation code) I ran into the following issue when trying to multiply a vector (represented by a fixed-length array) by a scalar: import std.stdio; void main() { int

Re: Programming a Game in D? :D

2014-05-22 Thread John Colvin via Digitalmars-d-learn
On Thursday, 22 May 2014 at 15:39:36 UTC, David wrote: Hey, I'm really new to D, and pretty new to programming overall too, But I want to make a 3d Game, (just sth. small). I really like D and want to do it in D, but in the Internet there is no shit about programming a game in D ^^ Is there

Re: Bounds check

2014-05-23 Thread John Colvin via Digitalmars-d-learn
On Friday, 23 May 2014 at 15:14:47 UTC, Chris wrote: The following: import std.stdio; void main() { int[5] arg; arg[10] = 3; // Compiler says (of course): Error: array index 10 is out of bounds arg[0 .. 5] } import std.stdio; void main() { int[5] arg; foreach (i;

Re: foreach over string

2014-05-24 Thread John Colvin via Digitalmars-d-learn
On Saturday, 24 May 2014 at 16:46:42 UTC, Kagamin wrote: foreach over string apparently iterates over chars by default instead of dchars. Didn't it prefer dchars? string s=weiß; int i; foreach(c;s)i++; assert(i==5); Nope. if you use foreach(dchar c; s) you will get the iteration by

Re: installing Mango with DMD instead of ldc

2014-05-25 Thread John Colvin via Digitalmars-d-learn
On Sunday, 25 May 2014 at 18:11:56 UTC, JJDuck wrote: Hello all, I tried to install Mango and I found that it requires ldc. the makefile for Mango is from http://svn.dsource.org/projects/mango/trunk/mango/build/ldc/makefile I tried to install ldc on Windows but it doesn't go very smooth for

Re: installing Mango with DMD instead of ldc

2014-05-26 Thread John Colvin via Digitalmars-d-learn
On Monday, 26 May 2014 at 07:07:47 UTC, JJDuck wrote: On Sunday, 25 May 2014 at 18:39:18 UTC, John Colvin wrote: That project hasn't been touched in 4 years. It will likely require a non-trivial amount of work to port it to modern D. It might be worth it, it might not, I don't know. If you

Re: for, foreach identifier allowed in c throws error in d

2014-06-02 Thread John Colvin via Digitalmars-d-learn
On Monday, 2 June 2014 at 19:21:07 UTC, Logesh Pillay wrote: It is common in a recursive function to amend a global array using the function parameter to refer to the element eg int[10]; void foo (int i) { foreach (x; 0 .. 9) { t[i] = x; foo (); C in a for loop allows use of t[i]

Re: for, foreach identifier allowed in c throws error in d

2014-06-02 Thread John Colvin via Digitalmars-d-learn
On Monday, 2 June 2014 at 20:23:12 UTC, Steven Schveighoffer wrote: On Mon, 02 Jun 2014 15:58:01 -0400, Steven Schveighoffer schvei...@yahoo.com wrote: I'm trying to think of a way to do this without loops, but not sure. I'm surprised, I looked for some kind of apply function like map,

Re: passing predicates to lowerBound, or alternatively, how lazy is map?

2014-06-11 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 11:22:08 UTC, Andrew Brown wrote: Hi there, The problem this question is about is now solved, by writing my own binary search algorithm, but I'd like to ask it anyway as I think I could learn a lot from the answers. The problem was, given an array of numbers,

Re: passing predicates to lowerBound, or alternatively, how lazy is map?

2014-06-11 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 11:50:36 UTC, Andrew Brown wrote: map is fully lazy. However, if you've already got the sorted indices in `order`, I would do this: auto numLessThanN = numbers.indexed(order).countUntil!((x) = x = N)(); That indexed command is perfect though, does the trick,

Re: passing predicates to lowerBound, or alternatively, how lazy is map?

2014-06-11 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 11:38:07 UTC, Andrew Brown wrote: My question about this is how lazy is map? Will it work on every value of order and then pass it to lowerBound, or could it work to evaluate only those values asked by lowerBound? I guess probably not, but could a function be

Re: passing predicates to lowerBound, or alternatively, how lazy is map?

2014-06-11 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 13:20:37 UTC, Andrew Brown wrote: You are correct. assumeSorted and lowerBound will provide better time complexity than countUntil I'm sorry, one final question because I think I'm close to understanding. Map produces a forward range (lazily) but not a random

Re: Basics of calling C from D

2014-06-11 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 13:52:09 UTC, belkin wrote: Example: I have this C function that is compiled into a library //File: factorial.h int factorial(int n); //File: factorial.c #include factorial.h int factorial(int n) { if(n!=1) return n*factorial(n-1); } Question: How do I

Re: Basics of calling C from D

2014-06-11 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 14:28:49 UTC, belkin wrote: On Wednesday, 11 June 2014 at 14:02:08 UTC, John Colvin wrote: On Wednesday, 11 June 2014 at 13:52:09 UTC, belkin wrote: Example: I have this C function that is compiled into a library //File: factorial.h int factorial(int n);

Re: Formatted read of tokens?

2014-06-17 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 17 June 2014 at 13:16:38 UTC, Jerry wrote: bearophile bearophileh...@lycos.com writes: Jerry: If I do f.readf(%s %s, l, i); it fails if the whitespace is a tab. In you can use byLine, followed by a split, and then assignment of the pieces, followed by to!int where

Re: Contributing to D language

2014-06-23 Thread John Colvin via Digitalmars-d-learn
On Monday, 23 June 2014 at 16:43:31 UTC, Mike wrote: I wish I could help with the development of D (either the compiler or std library). Is there a TODO list kept somewhere? Neither Phobos nor DMD have an `issues` page on Github.. I found this http://wiki.dlang.org/Review_Queue but it's

new and GC.malloc fail, core.stdc.malloc works

2014-06-24 Thread John Colvin via Digitalmars-d-learn
I'm getting OutOfMemoryErrors on some machines when calling GC.malloc (or new) for anything large (more than about 1GB), where core.stdc.malloc works fine. Anyone ever come accross this before? I suspect it's related to some system memory monitor/management as it's only happening to me on

Re: new and GC.malloc fail, core.stdc.malloc works

2014-06-24 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 24 June 2014 at 10:06:10 UTC, John Colvin wrote: I'm getting OutOfMemoryErrors on some machines when calling GC.malloc (or new) for anything large (more than about 1GB), where core.stdc.malloc works fine. Anyone ever come accross this before? I suspect it's related to some system

Re: Returning fixed size arrays

2014-06-25 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 25 June 2014 at 20:59:29 UTC, bearophile wrote: Is it possible and a good idea to change the D ABI to make code like this avoid an array copy in 100% of the cases (without inlining)? I meant, letting the compiler rewrite that code like this: void foo(ref ubyte[1000] __data)

Re: new and GC.malloc fail, core.stdc.malloc works

2014-06-26 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 25 June 2014 at 14:44:22 UTC, John Colvin wrote: On Tuesday, 24 June 2014 at 10:16:38 UTC, bearophile wrote: John Colvin: I'm getting OutOfMemoryErrors on some machines when calling GC.malloc (or new) for anything large (more than about 1GB), where core.stdc.malloc works fine.

Re: close program by code

2014-06-26 Thread John Colvin via Digitalmars-d-learn
On Thursday, 26 June 2014 at 09:58:50 UTC, FreeSlave wrote: On Thursday, 26 June 2014 at 09:05:23 UTC, pgtkda wrote: How can i close my application by code? Do you mean exit status? Just call exit function from C library. import std.c.stdlib; void main() { exit(0); } Will destructors

Re: Returning fixed size arrays

2014-06-26 Thread John Colvin via Digitalmars-d-learn
On Thursday, 26 June 2014 at 12:06:34 UTC, bearophile wrote: John Colvin: isn't this exactly what the System V ABI specifies anyway? Large aggregate returns are allocated on the calling stack, passed by hidden pointer. So do you know why D is not using that design? Bye, bearophile It is,

Re: What is best way to communicate between computer in local network ?

2014-06-27 Thread John Colvin via Digitalmars-d-learn
On Friday, 27 June 2014 at 12:51:45 UTC, bioinfornatics wrote: Hi, I have a linux network and i would like to know if they are a D library to communicate between computer efficiently. I do not know if that is better to use websocket and if they exists into dlang: -

Re: What is best way to communicate between computer in local network ?

2014-06-28 Thread John Colvin via Digitalmars-d-learn
On Saturday, 28 June 2014 at 16:08:18 UTC, Sean Kelly wrote: On Friday, 27 June 2014 at 13:03:20 UTC, John Colvin wrote: It's an application and network dependant decision, but I would suggest http://code.dlang.org/packages/zmqd as suitable for most situations. Yeah, this would be my first

Re: What is best way to communicate between computer in local network ?

2014-06-28 Thread John Colvin via Digitalmars-d-learn
On Saturday, 28 June 2014 at 16:20:31 UTC, John Colvin wrote: On Saturday, 28 June 2014 at 16:08:18 UTC, Sean Kelly wrote: On Friday, 27 June 2014 at 13:03:20 UTC, John Colvin wrote: It's an application and network dependant decision, but I would suggest http://code.dlang.org/packages/zmqd

Re: Small part of a program : d and c versions performances diff.

2014-07-09 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 9 July 2014 at 13:18:00 UTC, Larry wrote: On Wednesday, 9 July 2014 at 12:25:40 UTC, bearophile wrote: Larry: Now the performance : D : 12 µs C : 1µs Where does the diff comes from ? Is there a way to optimize the d version ? Again, I am absolutely new to D and those are my

Re: Small part of a program : d and c versions performances diff.

2014-07-09 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 9 July 2014 at 13:46:59 UTC, Larry wrote: The rest of the code is numerical so it will not change by much the fact that d cannot get back the huge launching time. At the microsecond level(even nano) it counts because of electrical consumption, size of hardware, heat and so on.

Re: Small part of a program : d and c versions performances diff.

2014-07-09 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 9 July 2014 at 15:09:09 UTC, Larry wrote: On Wednesday, 9 July 2014 at 14:30:41 UTC, John Colvin wrote: On Wednesday, 9 July 2014 at 13:46:59 UTC, Larry wrote: The rest of the code is numerical so it will not change by much the fact that d cannot get back the huge launching time.

Re: Insert a char in string

2014-07-10 Thread John Colvin via Digitalmars-d-learn
On Thursday, 10 July 2014 at 16:05:51 UTC, Alexandre wrote: I have a string X and I need to insert a char in that string... auto X = 100; And I need to inser a ',' in position 3 of this string..., I try to use the array.insertInPlace, but, not work... I try this: auto X =

Re: SImple C++ code to D

2014-07-13 Thread John Colvin via Digitalmars-d-learn
On Sunday, 13 July 2014 at 18:48:01 UTC, Alexandre wrote: dosh.e_magic = cast(WORD*)(MZ); should be: dosh.e_magic = cast(WORD*)(MZ.ptr);

Re: Extended math library

2014-07-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 July 2014 at 00:28:19 UTC, ponce wrote: On Wednesday, 16 July 2014 at 21:12:00 UTC, bachmeier wrote: Have you tried them? Do they work? I couldn't get scid to work last year. I've never heard of dstats before, but it hasn't seen any activity in two years. I'd be surprised if it

Re: Extended math library

2014-07-17 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 15 July 2014 at 20:46:32 UTC, Martijn Pot wrote: To make a long story short: Is there any math library with e.g. mean, std, polynomial fitting, ...? http://forum.dlang.org/post/nscscdomihmvqplxf...@forum.dlang.org

Re: Extended math library

2014-07-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 July 2014 at 18:21:12 UTC, Martijn Pot wrote: On Thursday, 17 July 2014 at 15:21:40 UTC, John Colvin wrote: On Tuesday, 15 July 2014 at 20:46:32 UTC, Martijn Pot wrote: To make a long story short: Is there any math library with e.g. mean, std, polynomial fitting, ...?

Re: mysterious performance gain

2014-07-18 Thread John Colvin via Digitalmars-d-learn
On Friday, 18 July 2014 at 13:21:09 UTC, Archibald wrote: Hello, So I have this big, performance critical function that takes about 9 seconds to execute. If I add : double[] direct = new double[2]; ... at the beggining of the function, with no further reference to this array, suddenly it

Re: Calling dynamically bound functions from weakly pure function

2014-07-18 Thread John Colvin via Digitalmars-d-learn
On Friday, 18 July 2014 at 14:15:46 UTC, Rene Zwanenburg wrote: For all intents and purposes, the following code can be weakly pure: struct VAO { } urrmm. Did you mean to post more than that?

Re: Learning to use ranges instead of arrays

2014-07-21 Thread John Colvin via Digitalmars-d-learn
On Sunday, 20 July 2014 at 16:02:05 UTC, Bob Tolbert wrote: I find myself writing this code too much and i'm curious what D idiom I am missing. given a list of files (or any strings) and then maybe I want to sort them and maybe I don't. string [] fileList; ... fill list if

Re: Really nooB question - @property

2014-07-21 Thread John Colvin via Digitalmars-d-learn
On Sunday, 20 July 2014 at 16:35:52 UTC, Eric wrote: There are a lot of discussions in the forums about how @property should or could be implemented. But I can't seem to find anything that explains why or when I should use @property with the current compiler. Can anyone explain why and when

Re: Really nooB question - @property

2014-07-21 Thread John Colvin via Digitalmars-d-learn
On Sunday, 20 July 2014 at 17:59:07 UTC, John Colvin wrote: On Sunday, 20 July 2014 at 16:35:52 UTC, Eric wrote: There are a lot of discussions in the forums about how @property should or could be implemented. But I can't seem to find anything that explains why or when I should use

Re: Really nooB question - @property

2014-07-21 Thread John Colvin via Digitalmars-d-learn
On Sunday, 20 July 2014 at 18:14:29 UTC, Eric wrote: Use @property when you want a pseudo-variable or something that might be conceptually considered a property of the object, i.e. to do this: auto blah = thing.someProperty; thing.someProperty = blahblah; This is basically what I

Re: Map one tuple to another Tuple of different type

2014-07-21 Thread John Colvin via Digitalmars-d-learn
On Monday, 21 July 2014 at 18:10:14 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Mon, Jul 21, 2014 at 12:55:34AM +0200, Daniel Gibson via Digitalmars-d-learn wrote: Hi, I have a variadic templated function and want to call a C varargs function. I want to be able to pass static arrays,

Re: Grabing C(++) stdout

2014-07-23 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 23 July 2014 at 14:53:35 UTC, Chris wrote: Short question: how can I grab the stdout written to by C(++), i.e. C code: fwrite(...); std.cstream will be replaced sooner or later. I don't think I understand the question. stdout is the same file handle, doesn't matter whether

Re: Deploying Vibe.d applications to OpenShift

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 02:48:45 UTC, Rutger wrote: On Thursday, 24 July 2014 at 01:47:43 UTC, Rikki Cattermole wrote: On 24/07/2014 1:28 p.m., Rutger wrote: Hello! Really enjoying D so far and have started to toy around with Vibe.d. I was just wondering if someone here has had any

Re: Segfault games with factorials

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 14:59:16 UTC, Darren wrote: On Thursday, 24 July 2014 at 14:39:12 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Thu, Jul 24, 2014 at 01:14:40PM +, Darren via Digitalmars-d-learn wrote: I have the following code in fac.d (modified from the factorial

Re: D JSON (WAT?!)

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote: Ok, let me start with the sample code: import std.stdio; import std.json; void main() { scope(failure) writeln(FaILED!!); string jsonStr = `{ name: 1, type: r }`; auto parsed = parseJSON(jsonStr); string s = parsed[fail].str;

Re: D JSON (WAT?!)

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:32:29 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote: Ok, let me start with the sample code: import std.stdio; import std.json; void main() { scope(failure) writeln(FaILED!!); string jsonStr = `{ name: 1, type: r }`; auto

Re: D JSON (WAT?!)

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 15:54:21 UTC, Pavel wrote: On Thursday, 24 July 2014 at 15:48:32 UTC, Edwin van Leeuwen wrote: On Thursday, 24 July 2014 at 15:42:58 UTC, Pavel wrote: On Thursday, 24 July 2014 at 15:38:06 UTC, John Colvin wrote: On Thursday, 24 July 2014 at 15:32:29 UTC, John

Re: Passing an array by reference?

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 16:06:00 UTC, Rishub Nagpal wrote: 1 class Test 2 { 3 int[][] array; 4 this(ref int[][] d) 5 { 6 array = d; 7 } 8 9 } 10 11 void main() 12 { 13 Test t = new Test([[1,1],[1,1]]); //does not compile 14 } 15 what

Re: How to copy an object to separate allocated memory?

2014-07-24 Thread John Colvin via Digitalmars-d-learn
On Thursday, 24 July 2014 at 17:05:18 UTC, Gary Willoughby wrote: I was reading Ali's book (http://ddili.org/ders/d.en/index.html) and saw this piece of code on how to get the true size of an object: MyClass* buffer = cast(MyClass*)GC.calloc(__traits(classInstanceSize, MyClass) * 10);

Re: Associative array to Struct at compile time

2014-07-25 Thread John Colvin via Digitalmars-d-learn
On Friday, 25 July 2014 at 15:25:43 UTC, BlackEdder wrote: Is it possible to automatically convert an associative array to a struct? Basically I want to do the following (for any struct). struct A { double x = 1; } double[string] aa = [x:1]; auto a = toStruct!A( aa ); I've been trying

Re: using pipeprocess on non-applications

2014-07-27 Thread John Colvin via Digitalmars-d-learn
On Saturday, 26 July 2014 at 15:24:01 UTC, Sean Campbell wrote: is there any way to detect if a file is a binary executable that is cross platform or a way to detect whether pipeprocss failed to execute a file if it wasn't executable. pipeProcess will throw a ProcessException if it can't

Re: Preferred program config file format and parsing library?

2014-08-03 Thread John Colvin via Digitalmars-d-learn
On Sunday, 3 August 2014 at 10:54:10 UTC, Gary Willoughby wrote: On Sunday, 3 August 2014 at 09:31:20 UTC, Marc Schütz wrote: On Saturday, 2 August 2014 at 12:42:00 UTC, Gary Willoughby wrote: What is the preferred format people here use for program config files? Json, Xml, ini, etc? JSON is

multidimensional indexing/slicing docs?

2014-08-06 Thread John Colvin via Digitalmars-d-learn
Is there anywhere that describes what Kenji (it was Kenji wasn't it?) recently implemented for this?

overloads and parents. __traits confusion

2014-08-11 Thread John Colvin via Digitalmars-d-learn
can someone talk me through the reasoning behind this: import std.typetuple; void foo(T)(T v){} void foo(){} version(ThisCompiles) { alias Parent = TypeTuple!(__traits(parent, foo))[0]; pragma(msg, __traits(getOverloads, Parent, foo)); // tuple() } else { alias Parent =

Re: overloads and parents. __traits confusion

2014-08-12 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 12 August 2014 at 05:23:53 UTC, Dicebot wrote: On Monday, 11 August 2014 at 13:00:27 UTC, John Colvin wrote: alias Parent = TypeTuple!(__traits(parent, foo!float))[0]; Say hello to optional parens - you are trying to call foo!float() here and apply result to trait. I thought

Re: Destroy two assumptions: interface implementation generated by TMP

2014-08-12 Thread John Colvin via Digitalmars-d-learn
On Monday, 11 August 2014 at 18:21:04 UTC, Baz wrote: Hi, I try to get why the last way of generating an interface implementation fails. I've put assumptions: is it right ? --- module itfgen; import std.stdio; interface itf{ void a_int(int p); void

Re: Destroy two assumptions: interface implementation generated by TMP

2014-08-12 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 12 August 2014 at 11:34:01 UTC, anonymous wrote: On Monday, 11 August 2014 at 18:21:04 UTC, Baz wrote: interface itf{ void a_int(int p); void a_uint(uint p); } [...] // FAILS because: alias are probably generated after the itf check class impl3: itf{ void tmp(T)(T p){};

Re: Appender is ... slow

2014-08-15 Thread John Colvin via Digitalmars-d-learn
On Thursday, 14 August 2014 at 17:16:42 UTC, Philippe Sigaud wrote: From time to time, I try to speed up some array-heavy code by using std.array.Appender, reserving some capacity and so on. It never works. Never. It gives me executables that are maybe 30-50% slower than bog-standard array

Re: how to tell if a thing is a template

2014-08-25 Thread John Colvin via Digitalmars-d-learn
On Sunday, 24 August 2014 at 00:41:36 UTC, Ellery Newcomer wrote: Can't think off the top of my head how you do this template IsTemplate(alias t) { ?? } static assert(IsTemplate!IsTemplate) __traits(compiles, is(t!X, X...)) should do it, or something similar.

Re: Learning D

2014-08-25 Thread John Colvin via Digitalmars-d-learn
On Monday, 25 August 2014 at 16:46:11 UTC, Ryan wrote: Me: Software developer for 30 years. So perhaps this is old fashion, but I wanted to start using D by whipping together nice little personal utilities. I tried installing MonoDevelop and Mono-D. I can't even figure out the basics, such

Re: Strange segfault (Derelict/OpenGL)

2014-08-29 Thread John Colvin via Digitalmars-d-learn
On Friday, 29 August 2014 at 11:23:34 UTC, Robin Schroer wrote: I'm not entirely sure where to post, so I will put it here. I'm playing around with D and Derelict 3 to make something with OpenGL (don't really know what yet). I managed to open a window, add an OpenGL context, clear the screen

Re: commercial application with D

2014-09-15 Thread John Colvin via Digitalmars-d-learn
On Monday, 15 September 2014 at 20:02:39 UTC, Andrey wrote: Can I develop commercial application with D programming language? Short answer: Yes, you can, you don't need to even think about it. Long answer: Yes, as long as you conform to the Boost v1.0 license, meaning that if you distribute

Re: How to pass a member function/delegate into a mixin template?

2014-09-15 Thread John Colvin via Digitalmars-d-learn
On Monday, 15 September 2014 at 13:50:22 UTC, 岩倉 澪 wrote: Hi all, I've been reading D Cookbook, in which the author recommends the use of mixin templates to essentially hold boilerplate code for classes (page 28). Referencing TDPL reaffirms this strategy. With this design choice in mind, I

Re: liblzma bindings in dub

2014-09-17 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 17 September 2014 at 21:05:07 UTC, Freddy wrote: How do you include liblzma bindings(https://github.com/D-Programming-Deimos/liblzma) in a dub project? as it's not on code.dlang.org, you will have to do it locally: cd yourChoiceofDirectory git clone

Re: Fail to compile phobos

2014-09-25 Thread John Colvin via Digitalmars-d-learn
On Thursday, 25 September 2014 at 17:20:42 UTC, JJDuck wrote: I tried to compile phobos according to the last paragraph in this page: http://dlang.org/dmd-linux.html but this is the error I have fatal: Not a git repository (or any of the parent directories): .git I dont know what happened,

Re: Dynamically loading a D dynamic library from a c++ program

2014-09-26 Thread John Colvin via Digitalmars-d-learn
On Friday, 26 September 2014 at 16:43:30 UTC, Olivier Leduc wrote: Hello, I need to use a C++ SDK to create a plugin an existing closed source c++ application and I would like to know if its possible to use D for that task. Would is be possible to port the SDK header files and call the

Re: Dynamically loading a D dynamic library from a c++ program

2014-09-27 Thread John Colvin via Digitalmars-d-learn
On Saturday, 27 September 2014 at 09:19:57 UTC, Jacob Carlborg wrote: On 2014-09-26 21:52, John Colvin wrote: Yes, but it depends on the complexity of the headers. C++ templates aren't supported for example. Templates are supported, if they're already instantiated. Sorry, yes, I should

Re: How do you get T from shared(T) ?

2014-09-30 Thread John Colvin via Digitalmars-d-learn
On Sunday, 28 September 2014 at 09:11:07 UTC, Marco Leise wrote: For head-unshared there is `static if (is(T U : shared U))`. But how do you get the unshared type for anything from `shared void*` to `shared uint` ? template UnShared(T, bool removeAll = false) { static if(is(T : shared U,

Re: Code fails with linker error. Why?

2014-10-03 Thread John Colvin via Digitalmars-d-learn
On Friday, 3 October 2014 at 15:44:16 UTC, eles wrote: class ShapeSurface(T) { public: int formula(); that means you have a definition of formula elsewhere (which the linker tries to find, but obviously fails. What you want is class ShapeSurface(T) { public: abstract int

  1   2   3   4   5   6   >