Re: reading file byLine

2015-09-12 Thread deed via Digitalmars-d-learn
On Saturday, 12 September 2015 at 12:51:04 UTC, Namal wrote: Anyway, there is no .reverse for strings I guess, what is the way to completely reverse a string in D? What do you want to do? Do you want to keep your data in original order, but get a reversed view of it for something, or do you a

Re: Does a synchronization yield on waiting thread?

2015-09-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/12/15 10:48 PM, Prudence wrote: It would seem to be the logical thing to do? That is, suppose two threads are sharing a resource. Thread A has it locked. B is "waiting". Is B in a loop burning cycles running in the background(regardless of thread.sleep, which only alleviates the problem) or

Does a synchronization yield on waiting thread?

2015-09-12 Thread Prudence via Digitalmars-d-learn
It would seem to be the logical thing to do? That is, suppose two threads are sharing a resource. Thread A has it locked. B is "waiting". Is B in a loop burning cycles running in the background(regardless of thread.sleep, which only alleviates the problem) or does it yield completely and someh

Re: Adjacent Pairs Range

2015-09-12 Thread deed via Digitalmars-d-learn
On Saturday, 12 September 2015 at 10:17:19 UTC, Nordlöw wrote: How do I most elegantly iterate all the adjacent pairs in an `InputRange` using Phobos? Something like [1,2,3,4] => [(1,2), (2,3), (3,4)] Why not just: zip(arr[0 .. $-1], arr[1 .. $]) ?

Re: Massive linker error after upgrade to DMD 2.068.1-1

2015-09-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 12 September 2015 at 20:05:28 UTC, rcorre wrote: After upgrading from DMD 2.068.0-1 to DMD 2.068.1-1, my project began producing a large linker error (when built using dub). I was able to trace it down to a single line: target = target.adjacent(Diagonals.yes).randomSample(1).front

Re: shared array?

2015-09-12 Thread Laeeth Isharc via Digitalmars-d-learn
On Saturday, 12 September 2015 at 13:42:44 UTC, Prudence wrote: Saying that it doesn't use it most of the time is not an answer/solution. Using it at all is a problem because one doesn't know when and where. I realize there is a switch now(-vgc), and maybe that is the solution, but you say "wel

Re: shared array?

2015-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 September 2015 at 13:42:44 UTC, Prudence wrote: Using it at all is a problem because one doesn't know when and where. It is called when the collect function is called and where it was called from. D's garbage collector isn't magic, it is just a function that frees memory whe

Re: shared array?

2015-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 September 2015 at 22:36:00 UTC, Laeeth Isharc wrote: Thank you for this. How large is the allocation for closure for a delegate? Just a pair of pointers? It depends on what the delegate needs to capture. It makes a copy of the local variables the function is referencing. (Usu

Re: shared array?

2015-09-12 Thread Laeeth Isharc via Digitalmars-d-learn
On Saturday, 12 September 2015 at 06:23:12 UTC, Jonathan M Davis wrote: Aside from the few classes in Phobos, its GC usage is almost entirely restricted to when it allocates arrays or when it has to allocate a closure for a delegate, which can happen in some cases when passing predicates to ran

Re: Why does reverse also flips my other dynamic array?

2015-09-12 Thread Ali Çehreli via Digitalmars-d-learn
On 09/12/2015 02:29 PM, Marco Leise wrote: > Note that often the original dynamic array has additional > capacity beyond its length. This can be used to ~= additional > items without causing a reallocation, but is lost when you > do the assignment "b = a". Actually, the capacity is still there,

Re: Hello World Example with Glade?

2015-09-12 Thread Mike McKee via Digitalmars-d-learn
On Saturday, 12 September 2015 at 09:03:53 UTC, Russel Winder wrote: Once you get to a GtkD application bigger than "Hello World" create a project and use Dub. Oh yes, Dub. That's the ticket. Thanks, mate.

Massive linker error after upgrade to DMD 2.068.1-1

2015-09-12 Thread rcorre via Digitalmars-d-learn
After upgrading from DMD 2.068.0-1 to DMD 2.068.1-1, my project began producing a large linker error (when built using dub). I was able to trace it down to a single line: target = target.adjacent(Diagonals.yes).randomSample(1).front; target is of type RowCol (https://github.com/rcorre/dtiled/

Re: Why does reverse also flips my other dynamic array?

2015-09-12 Thread Marco Leise via Digitalmars-d-learn
Am Sat, 12 Sep 2015 10:55:50 + schrieb "Namal" : > > Why is also b flipped here? This doesn't happen if I use static > > arrays. > > nvm. I need to .dup that. Correct, static arrays are value types and copied on assignment. Dynamic arrays on the other hand are generally slices of memory on

Re: I guess this is a bug?

2015-09-12 Thread anonymous via Digitalmars-d-learn
On Saturday 12 September 2015 20:28, Random D user wrote: > prints (with option B): > bar: 0.00, 0.00 // BUG?? > baz: 1.00, 2.00 Looks like a bug to me. Please file an issue at https://issues.dlang.org/

Re: I guess this is a bug?

2015-09-12 Thread Random D user via Digitalmars-d-learn
On Saturday, 12 September 2015 at 18:28:02 UTC, Random D user wrote: or is it some obscure feature conflict? [...] Oh... and I'm using win 64-bit and dmd 2.068.1, but this behavior was present earlier than that...

I guess this is a bug?

2015-09-12 Thread Random D user via Digitalmars-d-learn
or is it some obscure feature conflict? struct Foo { this( float x_, float y_ ) { // option A //x = x_; //y = y_; // option B v[0] = x_; v[1] = y_; } union { struct { float x = 0; float y

Re: Calling D from C, C++, Python…

2015-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 September 2015 at 18:20:37 UTC, Brad Roberts wrote: You can get away with it in some circumstances, but it's at your own risk. Yeah, I agree.

Re: Mixin templates accessing mixed out scope

2015-09-12 Thread anonymous via Digitalmars-d-learn
On Saturday 12 September 2015 19:36, Prudence wrote: > On Saturday, 12 September 2015 at 17:11:04 UTC, anonymous wrote: [...] >> class MyStore >> { >> class SingleStore >> { >> static void New() // Removing 'static' compiles >> { >> new SingleStore(); >>

Re: Calling D from C, C++, Python…

2015-09-12 Thread Brad Roberts via Digitalmars-d-learn
On 9/12/15 9:20 AM, Adam D. Ruppe via Digitalmars-d-learn wrote: On Saturday, 12 September 2015 at 09:47:55 UTC, Jacob Carlborg wrote: Well, if your D function doesn't use anything of the runtime I guess it's not necessary. Right. If you don't call into the threading system in the druntime, y

Re: Mixin templates accessing mixed out scope

2015-09-12 Thread Prudence via Digitalmars-d-learn
On Saturday, 12 September 2015 at 17:11:04 UTC, anonymous wrote: On Saturday 12 September 2015 16:30, Ali Çehreli wrote: Reduced: [...] Error: type SingleStore is not an expression Reduced further: class MyStore { class SingleStore { static void New() // Removing 'stat

Re: Mixin templates accessing mixed out scope

2015-09-12 Thread anonymous via Digitalmars-d-learn
On Saturday 12 September 2015 16:30, Ali Çehreli wrote: > Reduced: [...] > Error: type SingleStore is not an expression Reduced further: class MyStore { class SingleStore { static void New() // Removing 'static' compiles { new SingleStore(); }

Re: Mixin templates accessing mixed out scope

2015-09-12 Thread Prudence via Digitalmars-d-learn
On Saturday, 12 September 2015 at 14:30:16 UTC, Ali Çehreli wrote: On 09/12/2015 06:37 AM, Prudence wrote: Says the creating new SingleStore is not an expression Reduced: mixin template ObjectStore(TKey) { class SingleStore { static void New()// Removing 'static' compiles

Re: version and configuration

2015-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 September 2015 at 14:41:45 UTC, Spacen Jasset It appears that I can't put this in a module and import it elsewhere to test the version specifications as they are all in their own namespaces. Is this then a dead end for having a feature configuration file? Correct, version does

Re: Calling D from C, C++, Python…

2015-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 September 2015 at 09:47:55 UTC, Jacob Carlborg wrote: Well, if your D function doesn't use anything of the runtime I guess it's not necessary. Right. If you don't call into the threading system in the druntime, you should be ok. Keep in mind though that the GC uses the threads

Re: version and configuration

2015-09-12 Thread tcak via Digitalmars-d-learn
On Saturday, 12 September 2015 at 14:41:45 UTC, Spacen Jasset wrote: If I say this in one module: version = current version (Current) { version = featurea; version = featureb; version = featurec; } It appears that I can't put this in a module and import it elsewhere to test the versi

version and configuration

2015-09-12 Thread Spacen Jasset via Digitalmars-d-learn
If I say this in one module: version = current version (Current) { version = featurea; version = featureb; version = featurec; } It appears that I can't put this in a module and import it elsewhere to test the version specifications as they are all in their own namespaces. Is this th

Re: Mixin templates accessing mixed out scope

2015-09-12 Thread Ali Çehreli via Digitalmars-d-learn
On 09/12/2015 06:37 AM, Prudence wrote: Says the creating new SingleStore is not an expression Reduced: mixin template ObjectStore(TKey) { class SingleStore { static void New()// Removing 'static' compiles { new SingleStore(); } } } class M

Re: shared array?

2015-09-12 Thread Prudence via Digitalmars-d-learn
On Saturday, 12 September 2015 at 06:23:12 UTC, Jonathan M Davis wrote: On Friday, September 11, 2015 23:29:05 Laeeth Isharc via Digitalmars-d-learn wrote: On Friday, 11 September 2015 at 21:58:28 UTC, Adam D. Ruppe wrote: > [...] Seems to be quite a lot of FUD wrt use of standard library and

Mixin templates accessing mixed out scope

2015-09-12 Thread Prudence via Digitalmars-d-learn
The following code simply does not work, it might be buggy now after fiddling with it but basically remove and the SingleStore.New are not working(Says the creating new SingleStore is not an expression, which makes no sense to me). Essentially I'm creating a mixin template so I can have dif

Re: reading file byLine

2015-09-12 Thread Namal via Digitalmars-d-learn
On Monday, 7 September 2015 at 10:28:20 UTC, deed wrote: On Monday, 7 September 2015 at 10:25:09 UTC, deed wrote: writeln(x);// or you can pass it to a function. I meant `writeln(x + 5)` If I have just red your post before I started using reverse on dynamic arrays... Anyway, there is no

Re: Difference between back (`) and double (") quoted strings

2015-09-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 12 September 2015 at 08:22:03 UTC, NX wrote: What if I told you, you should search the official reference before asking such things in the forum? Searching is kinda hard, so I encourage people to ask if something doesn't come up quickly. And then we need to be sure to always answ

Re: Adjacent Pairs Range

2015-09-12 Thread Nordlöw
On Saturday, 12 September 2015 at 11:46:55 UTC, Nordlöw wrote: I wrote my own as adjacentTuples and adjacentPairs: https://github.com/nordlow/justd/blob/master/range_ex.d#L702 Note: No yet extended to N > 2. An alternative naming would be overlappingTuples/Pairs. Should this go into Phobos?

Re: Adjacent Pairs Range

2015-09-12 Thread Nordlöw
On Saturday, 12 September 2015 at 11:34:03 UTC, Bahman Movaqar wrote: On 09/12/2015 03:09 PM, "Nordlöw" wrote: InputRange please, not RandomAccessRanges ;) Oops! Here's one using only `InputRange` interface: I wrote my own as adjacentTuples and adjacentPairs: https://github.com/nordlow/jus

Re: Adjacent Pairs Range

2015-09-12 Thread Bahman Movaqar via Digitalmars-d-learn
On 09/12/2015 04:04 PM, Bahman Movaqar wrote: > Oops! Here's one using only `InputRange` interface: I believe I need to warn you that I'm just learning D; so take my solution at your own risk :-) -- Bahman Movaqar

Re: Adjacent Pairs Range

2015-09-12 Thread Bahman Movaqar via Digitalmars-d-learn
On 09/12/2015 03:09 PM, "Nordlöw" wrote: > InputRange please, not RandomAccessRanges ;) Oops! Here's one using only `InputRange` interface: T[][] collate(T)(T[] a) { alias CollateResult = Tuple!(T[][], "result", T, "tlHd"); CollateResult _collate(CollateResult collres)

Re: Why does reverse also flips my other dynamic array?

2015-09-12 Thread Namal via Digitalmars-d-learn
Why is also b flipped here? This doesn't happen if I use static arrays. nvm. I need to .dup that.

Re: Adjacent Pairs Range

2015-09-12 Thread Nordlöw
On Saturday, 12 September 2015 at 10:35:41 UTC, Bahman Movaqar wrote: On 09/12/2015 02:47 PM, "Nordlöw" wrote: How do I most elegantly iterate all the adjacent pairs in an `InputRange` using Phobos? Something like [1,2,3,4] => [(1,2), (2,3), (3,4)] That's call `collate`ing IIRC. A quick

Re: Adjacent Pairs Range

2015-09-12 Thread Bahman Movaqar via Digitalmars-d-learn
On 09/12/2015 02:47 PM, "Nordlöw" wrote: > How do I most elegantly iterate all the adjacent pairs in an > `InputRange` using Phobos? > > Something like > > [1,2,3,4] => [(1,2), (2,3), (3,4)] That's call `collate`ing IIRC. A quick solution would be using `std.range.transposed`: auto a = [1,2

Why does reverse also flips my other dynamic array?

2015-09-12 Thread Namal via Digitalmars-d-learn
import std.stdio; void main(){ int [] a = [1,2,3,4,5]; int [] b = a; writeln(b, " ", a); a.reverse; writeln(b, " ", a); } I get: [1, 2, 3, 4, 5] [1, 2, 3, 4, 5] [5, 4, 3, 2, 1] [5, 4, 3, 2, 1] Why is also b flipped here? This doesn't happen if I use static array

Adjacent Pairs Range

2015-09-12 Thread Nordlöw
How do I most elegantly iterate all the adjacent pairs in an `InputRange` using Phobos? Something like [1,2,3,4] => [(1,2), (2,3), (3,4)]

Re: Calling D from C, C++, Python…

2015-09-12 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-09-12 10:56, Russel Winder via Digitalmars-d-learn wrote: I have a small D function (C linkage) compiled to a shared object that I am calling from Python via CFFI that works fine with no D runtime initialization. Thus I have experimental evidence "always" is not entirely the case! I real

Re: Difference between back (`) and double (") quoted strings

2015-09-12 Thread Bahman Movaqar via Digitalmars-d-learn
On 09/12/2015 12:52 PM, NX wrote: > What if I told you, you should search the official reference before > asking such things in the forum? I did search the net for terms such as "d lang back quoted string" or "d lang multi line string" or "d lang string interpolation" before asking here. However t

Re: Hello World Example with Glade?

2015-09-12 Thread Russel Winder via Digitalmars-d-learn
On Sat, 2015-09-12 at 06:58 +, Mike McKee via Digitalmars-d-learn wrote: […] > I just tested and you are correct. Now, is there a way that I can > edit /etc/dmd.conf and make it so that I don't need to do this > pkg-config stuff all the time? I think editing /etc/dmd.conf would be the wrong

Re: Calling D from C, C++, Python…

2015-09-12 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2015-09-11 at 21:50 +0200, Jacob Carlborg via Digitalmars-d -learn wrote: > On 2015-09-10 20:01, Russel Winder via Digitalmars-d-learn wrote: > > Is there an easy way of knowing when you do not have to initialize > > the > > D runtime system to call D code from, in this case, Python via a C

Re: Difference between back (`) and double (") quoted strings

2015-09-12 Thread NX via Digitalmars-d-learn
On Saturday, 12 September 2015 at 08:13:33 UTC, Bahman Movaqar wrote: Is there any or they are just simply syntactically equivalent? Are there any official docs on this? What if I told you, you should search the official reference before asking such things in the forum? http://dlang.org/lex.

Difference between back (`) and double (") quoted strings

2015-09-12 Thread Bahman Movaqar via Digitalmars-d-learn
Is there any or they are just simply syntactically equivalent? Are there any official docs on this? -- Bahman Movaqar http://BahmanM.com - https://twitter.com/bahman__m https://github.com/bahmanm - https://gist.github.com/bahmanm PGP Key ID: 0x6AB5BD68 (keyserver2.pgp.com) signature.asc Descr

Re: How To: Passing curried functions around

2015-09-12 Thread Bahman Movaqar via Digitalmars-d-learn
On Friday, 11 September 2015 at 21:06:32 UTC, Ali Çehreli wrote: On 09/11/2015 02:04 PM, Ali Çehreli wrote: The same keyword has a different use with templates: And the official documentation: http://dlang.org/template.html#TemplateAliasParameter Thanks again!

Re: Hello World Example with Glade?

2015-09-12 Thread Mike McKee via Digitalmars-d-learn
On Friday, 11 September 2015 at 20:29:05 UTC, Mike Wey wrote: You should be able to drop the -L-ldl and -I/usr/ flags, as they are included in the pkg-config output. I just tested and you are correct. Now, is there a way that I can edit /etc/dmd.conf and make it so that I don't need to do