Re: How are theads, Tid and spawn related?

2014-11-02 Thread Sean Kelly via Digitalmars-d-learn
Note that thread_joinAll is called automatically when main exits, so if you just want to be sure that your spawned thread completes you don't have to do anything at all. The decision to obscure the Thread object in std.concurrency was deliberate, as it allows us to use more than just kernel

Re: How are theads, Tid and spawn related?

2014-11-02 Thread Sean Kelly via Digitalmars-d-learn
Note that thread_joinAll is called automatically when main exits, so if you just want to be sure that your spawned thread completes you don't have to do anything at all. The decision to obscure the Thread object in std.concurrency was deliberate, as it allows us to use more than just kernel

Re: How are theads, Tid and spawn related?

2014-11-02 Thread Ali Çehreli via Digitalmars-d-learn
On 11/01/2014 11:13 PM, Sean Kelly wrote: Note that thread_joinAll is called automatically when main exits Has that always been the case? I remember having to inject thread_joinAll() calls at the ends of the main()s of a couple of examples because of having trouble otherwise. Can I safely

Re: how to expand tuple?

2014-11-02 Thread Suliman via Digitalmars-d-learn
Thanks! In which cases tuples can be helpful?

Representing parse tree node

2014-11-02 Thread Uranuz via Digitalmars-d-learn
Now I'm working on implementation of Jinja template engine for web development on D language. http://jinja.pocoo.org I like it's explicit but still rather short syntax inherited from Python. I find it good for writing templates for web pages and other stuff such as configs or maybe CSS

Re: Interfacing with C++

2014-11-02 Thread Kagamin via Digitalmars-d-learn
D.learn is about basics of D. Interfacing with C++ is an advanced topic, with feature set in flux, so I'd suggest to ask about it in http://forum.dlang.org/group/digitalmars.D group.

Re: pop popFront combined

2014-11-02 Thread via Digitalmars-d-learn
On Saturday, 1 November 2014 at 14:19:56 UTC, Nordlöw wrote: On Saturday, 1 November 2014 at 13:54:31 UTC, Nordlöw wrote: On Saturday, 1 November 2014 at 13:38:22 UTC, Marc Schütz wrote: If you want to avoid the temporary variable, you could write: scope(success) r.popFront; return

Re: pop popFront combined

2014-11-02 Thread via Digitalmars-d-learn
On Saturday, 1 November 2014 at 13:54:31 UTC, Nordlöw wrote: On Saturday, 1 November 2014 at 13:38:22 UTC, Marc Schütz wrote: If you want to avoid the temporary variable, you could write: scope(success) r.popFront; return r.moveFront; Does this solution cost performance? I think DMD

Re: shallow copy of const(Object)[]

2014-11-02 Thread anonymous via Digitalmars-d-learn
On Sunday, 2 November 2014 at 00:33:53 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: If you want to make sure that a dynamic array refers to new memory and is not a slice of another one, then you'd typically use dup or idup, and in almost all cases, that's exactly what you want. However,

Re: D int and C/C++ int etc not really compatible when interfacing to C/C++

2014-11-02 Thread via Digitalmars-d-learn
On Saturday, 1 November 2014 at 21:00:54 UTC, Kagamin wrote: D claims compatibility with system C compiler, which usually have 32-bit int. ... and for C/C++ long which can be 32 or 64 bit, DMD recently introduced the types c_long and c_ulong. (Not released yet.)

Re: Restrict Combination of moveFront and popFront to Suitable Element Types

2014-11-02 Thread via Digitalmars-d-learn
On Saturday, 1 November 2014 at 21:26:49 UTC, Nordlöw wrote: As a follow-up question to http://forum.dlang.org/thread/jkbhlezbcrufowxtt...@forum.dlang.org?page=3#post-zyuqclyjitbhavemmwto:40forum.dlang.org discussing the motivation for a new range primitive stealFront that combines moveFront

Templates for structures

2014-11-02 Thread novice2 via Digitalmars-d-learn
Hello. I need write some wrapper around legacy data structure. May be it should be class. May be structure with methods. The problem is writing repetitive code for underlying data. For example: - code to read length-byte-prefixed string to D string for every field in every structure; - code

[SDL + TKD] Seg fault from creating DirectoryDialog

2014-11-02 Thread Jack via Digitalmars-d-learn
Well, to start, I'm trying to create a mp3 player for educational purposes. I'm using DerelictSDL(SDL_MIXER) as a library for the backend and TKD for the GUI. I have two objects to represent the two. The constructor for the sdl one contains the syntax for loading the DerelictSDL

Re: D int and C/C++ int etc not really compatible when interfacing to C/C++

2014-11-02 Thread John Colvin via Digitalmars-d-learn
On Saturday, 1 November 2014 at 15:00:57 UTC, Shriramana Sharma via Digitalmars-d-learn wrote: In the following pages: http://dlang.org/interfaceToC.html http://dlang.org/cpp_interface the Data Type Compatibility section says D int is compatible with C/C++ int. Isn't this actually false

Re: Restrict Combination of moveFront and popFront to Suitable Element Types

2014-11-02 Thread Nordlöw
On Sunday, 2 November 2014 at 11:55:41 UTC, Marc Schütz wrote: On Saturday, 1 November 2014 at 21:26:49 UTC, Nordlöw wrote: As a follow-up question to http://forum.dlang.org/thread/jkbhlezbcrufowxtt...@forum.dlang.org?page=3#post-zyuqclyjitbhavemmwto:40forum.dlang.org discussing the

Re: pop popFront combined

2014-11-02 Thread Nordlöw
On Sunday, 2 November 2014 at 11:46:19 UTC, Marc Schütz wrote: I think DMD doesn't generate good code for it; IIRC it lowers scope(success) to a strange construct with an invisible variable and a try/catch. Don't know the reasons for this, maybe it has changed by now. Theoretically it would

Re: How are theads, Tid and spawn related?

2014-11-02 Thread Russel Winder via Digitalmars-d-learn
On Sat, 2014-11-01 at 23:32 +, Neven via Digitalmars-d-learn wrote: Ok, a newbie question ahead. I want to create new thread which calls given function with some parameters. Thus, I think spawn is the right function for me. However that functions returns Tid and not a Thread object.

Re: D int and C/C++ int etc not really compatible when interfacing to C/C++

2014-11-02 Thread Mike Parker via Digitalmars-d-learn
On 11/2/2014 8:59 PM, Marc Schütz schue...@gmx.net wrote: On Saturday, 1 November 2014 at 21:00:54 UTC, Kagamin wrote: D claims compatibility with system C compiler, which usually have 32-bit int. ... and for C/C++ long which can be 32 or 64 bit, DMD recently introduced the types c_long and

Re: Multithreading in D

2014-11-02 Thread Russel Winder via Digitalmars-d-learn
On Thu, 2014-10-09 at 11:29 +, Sag Academy via Digitalmars-d-learn wrote: On Thursday, 9 October 2014 at 10:10:20 UTC, Konstantin wrote: Are you looking for parallel? http://dlang.org/library/std/parallelism/parallel.html I have seen this, but I'm not sure how to use it. Maybe:

Re: D int and C/C++ int etc not really compatible when interfacing to C/C++

2014-11-02 Thread via Digitalmars-d-learn
On Sunday, 2 November 2014 at 12:37:13 UTC, Mike Parker wrote: On 11/2/2014 8:59 PM, Marc Schütz schue...@gmx.net wrote: On Saturday, 1 November 2014 at 21:00:54 UTC, Kagamin wrote: D claims compatibility with system C compiler, which usually have 32-bit int. ... and for C/C++ long which

Re: pop popFront combined

2014-11-02 Thread via Digitalmars-d-learn
On Sunday, 2 November 2014 at 12:29:14 UTC, Nordlöw wrote: On Sunday, 2 November 2014 at 11:46:19 UTC, Marc Schütz wrote: I think DMD doesn't generate good code for it; IIRC it lowers scope(success) to a strange construct with an invisible variable and a try/catch. Don't know the reasons for

More flexible sorted ranges?

2014-11-02 Thread bearophile via Digitalmars-d-learn
I have often arrays that are sorted, and sometimes I'd like to append items to them. So I'd like to write something like: SortedRange!(Foo[], q{ a.x b.x }) data; data ~= Foo(5); immutable n = data.upperBound(Foo(2)).length; This means having an array of Foos as sorted range, and appending

Re: More flexible sorted ranges?

2014-11-02 Thread via Digitalmars-d-learn
On Sunday, 2 November 2014 at 15:13:37 UTC, bearophile wrote: This means having an array of Foos as sorted range, and appending an item to it keeping the sorting invariant (so in non-release mode the append verifies the array is empty or the last two items satisfy the sorting invariant), and

Re: D int and C/C++ int etc not really compatible when interfacing to C/C++

2014-11-02 Thread Sean Kelly via Digitalmars-d-learn
On Sunday, 2 November 2014 at 11:59:27 UTC, Marc Schütz wrote: On Saturday, 1 November 2014 at 21:00:54 UTC, Kagamin wrote: D claims compatibility with system C compiler, which usually have 32-bit int. ... and for C/C++ long which can be 32 or 64 bit, DMD recently introduced the types c_long

Re: D int and C/C++ int etc not really compatible when interfacing to C/C++

2014-11-02 Thread ponce via Digitalmars-d-learn
On Sunday, 2 November 2014 at 12:37:13 UTC, Mike Parker wrote: On 11/2/2014 8:59 PM, Marc Schütz schue...@gmx.net wrote: On Saturday, 1 November 2014 at 21:00:54 UTC, Kagamin wrote: D claims compatibility with system C compiler, which usually have 32-bit int. ... and for C/C++ long which

Re: More flexible sorted ranges?

2014-11-02 Thread bearophile via Digitalmars-d-learn
Ola Fosheim Grøstad: Shouldn't sorted range maintain the invariant automatically in order to remain typesafe? Yes, of course. Bye, bearophile

Re: How are theads, Tid and spawn related?

2014-11-02 Thread Sean Kelly via Digitalmars-d-learn
On Sunday, 2 November 2014 at 06:23:38 UTC, Ali Çehreli wrote: On 11/01/2014 11:13 PM, Sean Kelly wrote: Note that thread_joinAll is called automatically when main exits Has that always been the case? I remember having to inject thread_joinAll() calls at the ends of the main()s of a couple

Re: More flexible sorted ranges?

2014-11-02 Thread via Digitalmars-d-learn
On Sunday, 2 November 2014 at 16:59:30 UTC, bearophile wrote: Ola Fosheim Grøstad: Shouldn't sorted range maintain the invariant automatically in order to remain typesafe? Yes, of course. If SortedRange is fixed, please also switch the names of upperBound and lowerBound… They are

Re: D int and C/C++ int etc not really compatible when interfacing to C/C++

2014-11-02 Thread Sean Kelly via Digitalmars-d-learn
On Sunday, 2 November 2014 at 16:53:06 UTC, ponce wrote: c_long and c_ulong get used, should c_int and c_uint too in bindings? Looks like fringe use case. On common 32 and 64-bit platforms, the only type whose size changed between 32 and 64 bits is long, so the other aliases were deemed

Re: [SDL + TKD] Seg fault from creating DirectoryDialog

2014-11-02 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 2 November 2014 at 12:11:23 UTC, Jack wrote: Whole error is: http://codepad.org/C2l4rUel That's not the true error. That's dub throwing an exception when trying to run the built executable. As shown here:

Re: More flexible sorted ranges?

2014-11-02 Thread Xinok via Digitalmars-d-learn
On Sunday, 2 November 2014 at 17:21:04 UTC, Ola Fosheim Grøstad wrote: On Sunday, 2 November 2014 at 16:59:30 UTC, bearophile wrote: Ola Fosheim Grøstad: Shouldn't sorted range maintain the invariant automatically in order to remain typesafe? Yes, of course. If SortedRange is fixed,

Re: More flexible sorted ranges?

2014-11-02 Thread Xinok via Digitalmars-d-learn
On Sunday, 2 November 2014 at 15:13:37 UTC, bearophile wrote: I have often arrays that are sorted, and sometimes I'd like to append items to them. So I'd like to write something like: SortedRange!(Foo[], q{ a.x b.x }) data; data ~= Foo(5); immutable n = data.upperBound(Foo(2)).length; This

Re: More flexible sorted ranges?

2014-11-02 Thread via Digitalmars-d-learn
On Sunday, 2 November 2014 at 19:54:38 UTC, Xinok wrote: D got it right. C++ returns an iterator which can be a bit confusing. D returns a slice so it's meaning is much clearer. No, according to docs D has defined the lower bound to be the negation of the lower bound…

Re: More flexible sorted ranges?

2014-11-02 Thread bearophile via Digitalmars-d-learn
Xinok: My concern is that SortedRange only accepts a range which is random-access and limits its functionality to those primitives. Concatenation is not required for random-access ranges, so should we expect SortedRange to overload this operator? I understand, that's why I am asking this

Re: More flexible sorted ranges?

2014-11-02 Thread via Digitalmars-d-learn
And while you're at it, consider fixing the name to be accurate. Call it: lowerBoundedBy(value) or something similar. A lower bound is a single element, not a set.

How to start with d lang.

2014-11-02 Thread Kornel via Digitalmars-d-learn
Hi i want to start with programming and i choice d lang for start.How to get started with this language ??How do i learn this lang?What learning materials do you recommend ??

Re: How to start with d lang.

2014-11-02 Thread MattCoder via Digitalmars-d-learn
On Sunday, 2 November 2014 at 20:49:00 UTC, Kornel wrote: What learning materials do you recommend ?? http://ddili.org/ders/d.en/ Matheus.

Re: More flexible sorted ranges?

2014-11-02 Thread Xinok via Digitalmars-d-learn
On Sunday, 2 November 2014 at 20:06:51 UTC, Ola Fosheim Grøstad wrote: On Sunday, 2 November 2014 at 19:54:38 UTC, Xinok wrote: D got it right. C++ returns an iterator which can be a bit confusing. D returns a slice so it's meaning is much clearer. No, according to docs D has defined the

Re: how to expand tuple?

2014-11-02 Thread Philippe Sigaud via Digitalmars-d-learn
Any time you want to return or store a group of values of different types. In a way, tuples are just structs without a name (anonymous structs, if you will). Say you have function `foo' and want it to return an int and a string. In D, you cannot do: (int, string) foo() { ... return (3, abc);}

Re: More flexible sorted ranges?

2014-11-02 Thread Xinok via Digitalmars-d-learn
On Sunday, 2 November 2014 at 20:19:12 UTC, bearophile wrote: Xinok: My concern is that SortedRange only accepts a range which is random-access and limits its functionality to those primitives. Concatenation is not required for random-access ranges, so should we expect SortedRange to

Re: More flexible sorted ranges?

2014-11-02 Thread via Digitalmars-d-learn
On Sunday, 2 November 2014 at 22:14:33 UTC, Xinok wrote: In general, I don't feel that SortedRange is an ideal solution anyways. Wrapping ranges in a struct adds too much overhead and we can't extend the functionality of it. Would it be possible to replace SortedRange with a @sorted attribute

Re: More flexible sorted ranges?

2014-11-02 Thread via Digitalmars-d-learn
On Sunday, 2 November 2014 at 21:35:00 UTC, Xinok wrote: Sorry, you're right, it's not an upper bound. I read that definition a few times over and still got it wrong. O_o It is always easier to look for the examples :-). In terms of what to call it, perhaps what you're looking for is upper

Re: How are theads, Tid and spawn related?

2014-11-02 Thread Ali Çehreli via Digitalmars-d-learn
On 11/02/2014 09:04 AM, Sean Kelly wrote: On Sunday, 2 November 2014 at 06:23:38 UTC, Ali Çehreli wrote: Can I safely remove thread_joinAll()s if they are the last lines in main()? It has always been the case. In fact, I have a comment in the body of Thread.start() explaining this

Re: [SDL + TKD] Seg fault from creating DirectoryDialog

2014-11-02 Thread Jack via Digitalmars-d-learn
On Sunday, 2 November 2014 at 17:39:46 UTC, Gary Willoughby wrote: On Sunday, 2 November 2014 at 12:11:23 UTC, Jack wrote: Whole error is: http://codepad.org/C2l4rUel That's not the true error. That's dub throwing an exception when trying to run the built executable. As shown here:

Re: string, char[], overloaded functions.

2014-11-02 Thread dajones via Digitalmars-d-learn
Adam D. Ruppe destructiona...@gmail.com wrote in message news:xxnfghisussknbqzv...@forum.dlang.org... On Friday, 31 October 2014 at 23:59:54 UTC, dajones wrote: So shouldnt char[] implicity convert to string Nope, char[] casting to string is generally a bad thing that should be avoided

Re: string, char[], overloaded functions.

2014-11-02 Thread dajones via Digitalmars-d-learn
Kagamin s...@here.lot wrote in message news:lccftxangprboitrt...@forum.dlang.org... On Friday, 31 October 2014 at 23:59:54 UTC, dajones wrote: is there a better way than doing... cast(string)(buf~hoo) to get it to pick the correct overload? text(buf,hoo) Thanks! chris

Re: string, char[], overloaded functions.

2014-11-02 Thread dajones via Digitalmars-d-learn
Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote in message news:mailman.1363.1414801299.9932.digitalmars-d-le...@puremagic.com... On Friday, October 31, 2014 23:58:43 dajones via Digitalmars-d-learn wrote: Ok, void Foo(string name, string value); void

Why ByChunk is not regnize by st.range.takeOne and why Section has no value

2014-11-02 Thread bioinfornatics via Digitalmars-d-learn
Dear, Some problem to build this code: http://fpaste.org/147327/75948141/ $ ldc2 fasta_test.d /usr/include/d/std/range.d(3605): Error: template std.array.save cannot deduce function from argument types !()(ByChunk), candidates are: /usr/include/d/std/array.d(554):std.array.save(T)(T[]

Re: How are theads, Tid and spawn related?

2014-11-02 Thread Sean Kelly via Digitalmars-d-learn
For those cases you could use spawnLinked and then receive LinkTerminated as well, if you're looking for a solution within the concurrency API.

API hooking in Dlang?

2014-11-02 Thread Dirk via Digitalmars-d-learn
I am wondering if there is any libraries I have missed for API hooking? Preferably on windows, and linux, although just windows is fine. I found one named kong(http://www.dsource.org/projects/kong), although it has been abandoned and only supports xp on windows. Or if there is any detours

Re: API hooking in Dlang?

2014-11-02 Thread Dirk via Digitalmars-d-learn
On Monday, 3 November 2014 at 03:41:19 UTC, Dirk wrote: I am wondering if there is any libraries I have missed for API hooking? Preferably on windows, and linux, although just windows is fine. I found one named kong(http://www.dsource.org/projects/kong), although it has been abandoned and

Re: Why ByChunk is not regnize by st.range.takeOne and why Section has no value

2014-11-02 Thread Ali Çehreli via Digitalmars-d-learn
On 11/02/2014 04:58 PM, bioinfornatics wrote: Dear, Some problem to build this code: http://fpaste.org/147327/75948141/ $ ldc2 fasta_test.d /usr/include/d/std/range.d(3605): Error: template std.array.save cannot deduce function from argument types !()(ByChunk), candidates are: I think

Re: API hooking in Dlang?

2014-11-02 Thread Dirk via Digitalmars-d-learn
On Monday, 3 November 2014 at 04:31:40 UTC, Dirk wrote: On Monday, 3 November 2014 at 03:41:19 UTC, Dirk wrote: I am wondering if there is any libraries I have missed for API hooking? Preferably on windows, and linux, although just windows is fine. I found one named

Re: API hooking in Dlang?

2014-11-02 Thread Jack via Digitalmars-d-learn
On Monday, 3 November 2014 at 06:51:11 UTC, Dirk wrote: On Monday, 3 November 2014 at 04:31:40 UTC, Dirk wrote: On Monday, 3 November 2014 at 03:41:19 UTC, Dirk wrote: I am wondering if there is any libraries I have missed for API hooking? Preferably on windows, and linux, although just