Template detection

2015-09-13 Thread Alexandru Ermicioi via Digitalmars-d-learn
Hello, Given: class SomeClass { public { void someSimpleMethod() {} template setOfTemplatedMethods(Type) { void templatedMethodOne() {} void templatedMethodTwo() {} } } } Is there a way to detect at compile time if a member of

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

2015-09-13 Thread Jakob Ovrum via Digitalmars-d-learn
On Thursday, 10 September 2015 at 18:01:10 UTC, Russel Winder 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 adapter? I naïvely transformed some C++ to D, without consideration of D runtime

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

2015-09-13 Thread Jakob Ovrum via Digitalmars-d-learn
On Sunday, 13 September 2015 at 10:10:32 UTC, Jakob Ovrum wrote: On Thursday, 10 September 2015 at 18:01:10 UTC, Russel Winder 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 adapter? I naïvely

Re: Template detection

2015-09-13 Thread Enamex via Digitalmars-d-learn
On Sunday, 13 September 2015 at 08:26:55 UTC, Alexandru Ermicioi wrote: Hello, Given: class SomeClass { public { void someSimpleMethod() {} template setOfTemplatedMethods(Type) { void templatedMethodOne() {} void templatedMethodTwo() {} }

D + Dub + Sublime +... build/run in terminal?

2015-09-13 Thread SuperLuigi via Digitalmars-d-learn
Just wondering if anyone here might know how I can accomplish this... basically I'm editing my D code in Sublime using the Dkit plugin to access DCD which so far is more reliable than monodevelop's autocomplete but I do need to reset the server pretty often... but that's neither here nor

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

2015-09-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-09-13 12:10, Jakob Ovrum wrote: On Linux and other ELF-using platforms, initialization and deinitialization functions could be placed in the .init and .deinit special sections, but I don't know if druntime has any convenient provisions for this. With GDC and LDC you can probably use a

Re: reading file byLine

2015-09-13 Thread deed via Digitalmars-d-learn
On Sunday, 13 September 2015 at 03:20:31 UTC, deed wrote: string s = "Some text"; s.retro.find("e"); // `Some te` (Surprising to me. Error? 2.067.1) Sorry, the above is wrong, .retro.find does indeed return what's expected. string s = "Some text"; s.retro.find("e").writeln; //

Combining Unique type with concurrency module

2015-09-13 Thread Alex via Digitalmars-d-learn
Hi everybody! I'm new to this forum so, please excuse me in advance for asking silly questions. I think I'm not the first person which wondering about this topic, but I'm trying to combine Unique type and concurrency module, getting the compiler error struct std.typecons.Unique!(S).Unique is

Re: shared array?

2015-09-13 Thread ponce via Digitalmars-d-learn
On Sunday, 13 September 2015 at 15:35:07 UTC, Jonathan M Davis wrote: But the idea that your average D program is going to run into problems with the GC while using Phobos is just plain wrong. The folks who need to care are the rare folks who need extreme enough performance that they can't

Re: reading file byLine

2015-09-13 Thread deed via Digitalmars-d-learn
On Sunday, 13 September 2015 at 03:20:31 UTC, deed wrote: ... and since `string` is an alias for `const(char)[]`, it's not ... string is an alias for immutable(char)[], not const(char)[]. http://dlang.org/arrays.html#strings Sorry about the noise.

how do I check if a member of a T has a member ?

2015-09-13 Thread Laeeth Isharc via Digitalmars-d-learn
can I check if a member of a T has a member without using a mixin? hid_t createDataType(T)() if (__traits(isSame, TemplateOf!(T), PriceBar)) { auto tid=H5T.create(H5TClass.Compound,T.sizeof); enum offsetof(alias type, string field) = mixin(type.stringof ~"."~field~".offsetof");

Re: [D Cookbook]about "Communicating with external processes" part.

2015-09-13 Thread anonymous via Digitalmars-d-learn
On Sunday 13 September 2015 15:32, xky wrote: > [ pipe.d ]: > == > import std.process; > import std.stdio; > > void main(){ > auto info = pipeProcess("child.exe"); > scope(exit) wait(info.pid); > >

Re: [D Cookbook]about "Communicating with external processes" part.

2015-09-13 Thread xky via Digitalmars-d-learn
On Sunday, 13 September 2015 at 13:34:18 UTC, Adam D. Ruppe wrote: I'm in a super rush, running late to something else, but try using readln in the child before writing and see what happens. You sent data to it but the child never read it. oh my... you're right. lol so, i fix "pipe.d" this:

Re: D + Dub + Sublime +... build/run in terminal?

2015-09-13 Thread SuperLuigi via Digitalmars-d-learn
On Sunday, 13 September 2015 at 12:45:02 UTC, Gary Willoughby wrote: On Sunday, 13 September 2015 at 10:00:13 UTC, SuperLuigi wrote: but whatever I put in messes up and I just get errors... So what are the errors? Depends what I put in, but they're just basically saying what I'm putting in

Re: shared array?

2015-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, September 12, 2015 13:42:42 Prudence via Digitalmars-d-learn wrote: > 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

Re: shared array?

2015-09-13 Thread Kagamin via Digitalmars-d-learn
On Friday, 11 September 2015 at 17:29:47 UTC, Prudence wrote: I don't care about "maybe" working. Since the array is hidden inside a class I can control who and how it is used and deal with the race conditions. Looks like destruction slipped out of your control. That is solved by making

Re: D + Dub + Sublime +... build/run in terminal?

2015-09-13 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 13 September 2015 at 10:00:13 UTC, SuperLuigi wrote: but whatever I put in messes up and I just get errors... So what are the errors?

Re: [D Cookbook]about "Communicating with external processes" part.

2015-09-13 Thread Adam D. Ruppe via Digitalmars-d-learn
I'm in a super rush, running late to something else, but try using readln in the child before writing and see what happens. You sent data to it but the child never read it.

[D Cookbook]about "Communicating with external processes" part.

2015-09-13 Thread xky via Digitalmars-d-learn
Hello. :) I just got a this problem when i read "D Cookbook". [ pipe.d ]: == import std.process; import std.stdio; void main(){ auto info = pipeProcess("child.exe"); scope(exit) wait(info.pid);

Re: shared array?

2015-09-13 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Sunday, 13 September 2015 at 16:53:20 UTC, ponce wrote: GC is basically ok for anything soft-realtime, where you already spend a lot of time to go fast enough. And if you want hard-realtime, well you wouldn't want malloc either. It's a non-problem. If this was true then Go would not have

Re: shared array?

2015-09-13 Thread Prudence via Digitalmars-d-learn
On Sunday, 13 September 2015 at 16:58:22 UTC, Ola Fosheim Grøstad wrote: On Sunday, 13 September 2015 at 15:35:07 UTC, Jonathan M Davis wrote: the GC heavily. And the reality of the matter is that the vast majority of programs will have _no_ problems with using the GC so long as they don't use

Re: how do I check if a member of a T has a member ?

2015-09-13 Thread BBasile via Digitalmars-d-learn
On Sunday, 13 September 2015 at 17:24:20 UTC, Laeeth Isharc wrote: On Sunday, 13 September 2015 at 17:09:57 UTC, wobbles wrote: Use __traits(compiles, date.second)? Thanks. This works: static if (__traits(compiles, { T bar; bar.date.hour;})) pragma(msg,"hour"); else

Re: shared array?

2015-09-13 Thread Ola Fosheim Grostad via Digitalmars-d-learn
On Sunday, 13 September 2015 at 17:16:02 UTC, ponce wrote: On Sunday, 13 September 2015 at 17:00:30 UTC, Ola Fosheim If this was true then Go would not have a concurrent collector. I was speaking of the D language. Go only added concurrent GC now at version 1.5 and keep improving it to

alias for regular expressions

2015-09-13 Thread Thunderbird via Digitalmars-d-learn
Some special interest thingamabob: I've tried to redefine "else if" as "elif" using "alias elif = else if;". No matter what to no avail. I know this is probably useless fancy stuff, but is there any way to get this done without much ado?

Re: how do I check if a member of a T has a member ?

2015-09-13 Thread wobbles via Digitalmars-d-learn
On Sunday, 13 September 2015 at 16:46:54 UTC, Laeeth Isharc wrote: can I check if a member of a T has a member without using a mixin? hid_t createDataType(T)() if (__traits(isSame, TemplateOf!(T), PriceBar)) { auto tid=H5T.create(H5TClass.Compound,T.sizeof); enum offsetof(alias type,

Re: how do I check if a member of a T has a member ?

2015-09-13 Thread Laeeth Isharc via Digitalmars-d-learn
On Sunday, 13 September 2015 at 17:09:57 UTC, wobbles wrote: Use __traits(compiles, date.second)? Thanks. This works: static if (__traits(compiles, { T bar; bar.date.hour;})) pragma(msg,"hour"); else pragma(msg,"nohour");

Re: shared array?

2015-09-13 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Sunday, 13 September 2015 at 15:35:07 UTC, Jonathan M Davis wrote: the GC heavily. And the reality of the matter is that the vast majority of programs will have _no_ problems with using the GC so long as they don't use it heavily. Programming like you're in Java and allocating everything on

Re: shared array?

2015-09-13 Thread ponce via Digitalmars-d-learn
On Sunday, 13 September 2015 at 17:00:30 UTC, Ola Fosheim Grøstad wrote: On Sunday, 13 September 2015 at 16:53:20 UTC, ponce wrote: GC is basically ok for anything soft-realtime, where you already spend a lot of time to go fast enough. And if you want hard-realtime, well you wouldn't want

Re: shared array?

2015-09-13 Thread Prudence via Digitalmars-d-learn
On Sunday, 13 September 2015 at 17:16:02 UTC, ponce wrote: On Sunday, 13 September 2015 at 17:00:30 UTC, Ola Fosheim Grøstad wrote: On Sunday, 13 September 2015 at 16:53:20 UTC, ponce wrote: GC is basically ok for anything soft-realtime, where you already spend a lot of time to go fast enough.

Re: alias for regular expressions

2015-09-13 Thread Thunderbird via Digitalmars-d-learn
On Sunday, 13 September 2015 at 19:51:38 UTC, anonymous wrote: On Sunday 13 September 2015 21:47, Thunderbird wrote: Some special interest thingamabob: I've tried to redefine "else if" as "elif" using "alias elif = else if;". No matter what to no avail. I know this is probably useless

Re: alias for regular expressions

2015-09-13 Thread anonymous via Digitalmars-d-learn
On Sunday 13 September 2015 21:47, Thunderbird wrote: > Some special interest thingamabob: > > I've tried to redefine "else if" as "elif" using "alias elif = > else if;". No matter what to no avail. > > I know this is probably useless fancy stuff, but is there any way > to get this done

Re: shared array?

2015-09-13 Thread ponce via Digitalmars-d-learn
On Sunday, 13 September 2015 at 19:39:20 UTC, Ola Fosheim Grostad wrote: The theoretical limit for 10ms mark sweep collection on current desktop cpus is 60 megabytes at peak performance. That means you'll have to stay below 30 MiB in total memory use with pointers. 30 MiB of scannable

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

2015-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 13, 2015 17:17:01 Ali Çehreli via Digitalmars-d-learn wrote: > On 09/13/2015 08:21 AM, Jonathan M Davis via Digitalmars-d-learn wrote: > > On Saturday, September 12, 2015 14:59:23 Ali Çehreli via > Digitalmars-d-learn wrote: > >> On 09/12/2015 02:29 PM, Marco Leise wrote: >

Re: Combining Unique type with concurrency module

2015-09-13 Thread Ali Çehreli via Digitalmars-d-learn
On 09/13/2015 09:09 AM, Alex wrote: > I'm new to this forum so, please excuse me in advance for > asking silly questions. Before somebody else says it: There are no silly questions. :) > struct std.typecons.Unique!(S).Unique is not copyable because it is > annotated with @disable I have made

Re: shared array?

2015-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 13, 2015 16:53:18 ponce via Digitalmars-d-learn wrote: > On Sunday, 13 September 2015 at 15:35:07 UTC, Jonathan M Davis > wrote: > > But the idea that your average D program is going to run into > > problems with the GC while using Phobos is just plain wrong. > > The folks who

Re: shared array?

2015-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 13, 2015 16:58:21 Ola Fosheim Grøstad via Digitalmars-d-learn wrote: > On Sunday, 13 September 2015 at 15:35:07 UTC, Jonathan M Davis > wrote: > > the GC heavily. And the reality of the matter is that the vast > > majority of programs will have _no_ problems with using the GC

Re: shared array?

2015-09-13 Thread Ola Fosheim Grostad via Digitalmars-d-learn
On Monday, 14 September 2015 at 00:41:28 UTC, Jonathan M Davis wrote: stop-the-world GC. For instance, this has come up in discussions on games where a certain framerate needs to be maintained. Even a 100 ms stop would be way too much for them. In fact, it came up with the concurrent GC that

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

2015-09-13 Thread Ali Çehreli via Digitalmars-d-learn
On 09/13/2015 08:21 AM, Jonathan M Davis via Digitalmars-d-learn wrote: > On Saturday, September 12, 2015 14:59:23 Ali Çehreli via Digitalmars-d-learn wrote: >> On 09/12/2015 02:29 PM, Marco Leise wrote: >> >> > Note that often the original dynamic array has additional >> > capacity beyond

Re: shared array?

2015-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 13, 2015 17:14:05 Prudence via Digitalmars-d-learn wrote: > On Sunday, 13 September 2015 at 16:58:22 UTC, Ola Fosheim Grøstad > wrote: > > On Sunday, 13 September 2015 at 15:35:07 UTC, Jonathan M Davis > > wrote: > >> the GC heavily. And the reality of the matter is that the

Re: Adjacent Pairs Range

2015-09-13 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 13 September 2015 at 01:49:56 UTC, deed wrote: zip(arr[0 .. $-1], arr[1 .. $]) ? Assumes arrays. Better is zip(arr.dropOne, arr)

Passing Elements of A Static Array as Function Parameters

2015-09-13 Thread Nordlöw via Digitalmars-d-learn
If I have a static array `x` defined as enum N = 3; int[N] x; how do I pass it's elements into a variadic function f(T...)(T xs) if (T.length >= 3) ?

Re: Adjacent Pairs Range

2015-09-13 Thread Sebastiaan Koppe 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)] What about using zip and a slice? ``` void main() { auto a = [1,2,3,4];