Re: Detecting value parameter of template instance in "is" expression

2013-12-05 Thread Philippe Sigaud
On Fri, Dec 6, 2013 at 5:31 AM, Uranuz wrote: > As far as I understand TemplateParamList in *is* expr should work just like > it works in usual template. So this problem is just lack of implementation. > I'll try to find workaround with * is( N == Nullable!(T), T ... ) * syntax. > > Thank you for

Re: regading detection of stdin

2013-12-05 Thread Jesse Phillips
On Friday, 6 December 2013 at 02:41:28 UTC, Hugo Florentino wrote: I see... so the "problem" simply was that function readln was expecting user input. In that case, this is not what I intended. I want the application to receive the stdout of another command as stdin, and to detect if nothing is

Re: how to compose delegate type

2013-12-05 Thread Jesse Phillips
On Friday, 6 December 2013 at 02:42:44 UTC, Ellery Newcomer wrote: how do I construct F!(T) to yield void delegate() immutable when T is void delegate() ? [its been a long day] I don't think I understand what you mean: void main() { F!(void delegate()); } immutable(T) F(T)() { ret

Re: I/O related question, and ini parsing

2013-12-05 Thread Mineko
On Friday, 6 December 2013 at 05:22:07 UTC, Ali Çehreli wrote: On 12/05/2013 08:43 PM, Mineko wrote: > I might be missing out on some D-only features The first thing I've noticed is that you are not using UFCS, perhaps because you don't like it (yet ;) ) but look how natural the syntax become

Re: I/O related question, and ini parsing

2013-12-05 Thread Ali Çehreli
On 12/05/2013 08:43 PM, Mineko wrote: > I might be missing out on some D-only features The first thing I've noticed is that you are not using UFCS, perhaps because you don't like it (yet ;) ) but look how natural the syntax becomes: existing code (my indentation): temp = findSplitAfter(f

I/O related question, and ini parsing

2013-12-05 Thread Mineko
So, it's my first time implementing something like logging and ini parsing/creating, and it appears to work perfectly, but I'm not neccessarily a master of D yet.. So, I wanted some advice from my seniors if there's anything I should improve on such, I might be missing out on some D-only feat

Re: Detecting value parameter of template instance in "is" expression

2013-12-05 Thread Uranuz
As far as I understand TemplateParamList in *is* expr should work just like it works in usual template. So this problem is just lack of implementation. I'll try to find workaround with * is( N == Nullable!(T), T ... ) * syntax. Thank you for response.

how to compose delegate type

2013-12-05 Thread Ellery Newcomer
how do I construct F!(T) to yield void delegate() immutable when T is void delegate() ? [its been a long day]

Re: regading detection of stdin

2013-12-05 Thread Hugo Florentino
On Fri, 06 Dec 2013 01:26:28 +0100, Adam D. Ruppe wrote: On Friday, 6 December 2013 at 00:24:22 UTC, Hugo Florentino wrote: if nothing is passed from stdin and no parameter is provided, the application freezes: Does it freeze or just wait for you to press enter on the keyboard? I see... so

Re: Is this reasonable?

2013-12-05 Thread Jonathan M Davis
On Thursday, December 05, 2013 23:44:33 Brad Anderson wrote: > On Thursday, 5 December 2013 at 19:36:46 UTC, H. S. Teoh wrote: > > On Thu, Dec 05, 2013 at 03:47:27PM -0300, Ary Borenszweig wrote: > > [...] > > > >> Cough, cough, make array length be an int. > >> > >> Do you really need arrays tha

Re: Measuring ticks (or time) per threads

2013-12-05 Thread Phil Lavoie
On Thursday, 5 December 2013 at 06:22:35 UTC, Rob T wrote: Also please post a bug or enhancement issue for anything that you think ought to be included in the standard libs that isn't. https://d.puremagic.com/issues/ --rt Done

Re: Output Sound to Multiple Devices?

2013-12-05 Thread Adam D. Ruppe
Hmm, I don't really know. But what I'd do (if nobody else here knows) is to search for/ask the library help list how to do it with SFML in C, then translate that to D.

Re: Is this reasonable?

2013-12-05 Thread H. S. Teoh
On Thu, Dec 05, 2013 at 10:06:55PM +0100, Timon Gehr wrote: > On 12/05/2013 07:26 PM, Jonathan M Davis wrote: > >The best that could be done would be to warn about the comparison > >or to make it an error. > > > >http://d.puremagic.com/issues/show_bug.cgi?id=259 > >... > > The best that could be d

Re: About compiler memory consumption

2013-12-05 Thread Puming
On Thursday, 5 December 2013 at 13:49:51 UTC, Dicebot wrote: On Thursday, 5 December 2013 at 04:02:58 UTC, Puming wrote: There maybe another traditional approach, by converting the .dt diet templates directly into D source code BEFORE the actuall compilation. That is the way many other HTML tem

Re: Output Sound to Multiple Devices?

2013-12-05 Thread Malkierian
On Friday, 6 December 2013 at 00:33:07 UTC, Adam D. Ruppe wrote: What sound library/OS setup are you using? This will, initially, be Windows, as I'm only making it for myself, but if I can get it working well enough, I may want to have it cross-platform. I am currently working with the D b

Re: Output Sound to Multiple Devices?

2013-12-05 Thread Adam D. Ruppe
What sound library/OS setup are you using?

Output Sound to Multiple Devices?

2013-12-05 Thread Malkierian
So I'm looking at creating a virtual soundboard, but the whole point of making it would be moot if I can't get it to write to two output streams (a virtual cable and my headphones). Is it possible to hook into two audio output devices and send sound streams to both simultaneously?

Re: regading detection of stdin

2013-12-05 Thread Adam D. Ruppe
On Friday, 6 December 2013 at 00:24:22 UTC, Hugo Florentino wrote: if nothing is passed from stdin and no parameter is provided, the application freezes: Does it freeze or just wait for you to press enter on the keyboard?

regading detection of stdin

2013-12-05 Thread Hugo Florentino
Hi, I was trying to do something like this (using dmd.2.064.2 both from Windows and Linux), but if nothing is passed from stdin and no parameter is provided, the application freezes: import std.stdio, std.file: readText; int main(string[] args) { string s; switch (args.length) { case

Re: scoped chdir and similar patterns

2013-12-05 Thread Jonathan M Davis
On Thursday, December 05, 2013 07:24:50 qznc wrote: > On Thursday, 5 December 2013 at 01:07:19 UTC, Timothee Cour wrote: > > A1. > > > > Is there a (clever?) way to achieve the following using a > > single function > > call? > > You could (mis)use destructors. > > = > struct chdir_sc

Re: Is this reasonable?

2013-12-05 Thread Brad Anderson
On Thursday, 5 December 2013 at 19:36:46 UTC, H. S. Teoh wrote: On Thu, Dec 05, 2013 at 03:47:27PM -0300, Ary Borenszweig wrote: [...] Cough, cough, make array length be an int. Do you really need arrays that big? :-S (I'm talking to Mr. D Compiler here) A negative length array makes no sens

Re: Checking Compiler version in code?

2013-12-05 Thread Jeremy DeHaan
On Thursday, 5 December 2013 at 19:43:09 UTC, H. S. Teoh wrote: On Thu, Dec 05, 2013 at 07:40:51PM +0100, Jeremy DeHaan wrote: Hey all, I was wondering if there was a way to check the compiler version when running code. My project uses 2.064 and other people that go to use it will get errors

Re: Checking Compiler version in code?

2013-12-05 Thread Jeremy DeHaan
On Thursday, 5 December 2013 at 18:45:08 UTC, Dicebot wrote: On Thursday, 5 December 2013 at 18:40:53 UTC, Jeremy DeHaan wrote: Hey all, I was wondering if there was a way to check the compiler version when running code. My project uses 2.064 and other people that go to use it will get errors

Re: Is this reasonable?

2013-12-05 Thread eles
On Thursday, 5 December 2013 at 19:36:46 UTC, H. S. Teoh wrote: On Thu, Dec 05, 2013 at 03:47:27PM -0300, Ary Borenszweig wrote: [...] Cough, cough, make array length be an int. Do you really need arrays that big? :-S (I'm talking to Mr. D Compiler here) A negative length array makes no sens

Re: Detecting value parameter of template instance in "is" expression

2013-12-05 Thread Ali Çehreli
On 12/05/2013 01:00 PM, Philippe Sigaud wrote: > On Thu, Dec 5, 2013 at 9:17 PM, anonymous wrote: >> On Thursday, 5 December 2013 at 20:07:51 UTC, Uranuz wrote: > >>> How should I define value parameters inside "is" expression to make code >>> like this working? >> >> >> is( N == Nullable!(T),

Re: Is this reasonable?

2013-12-05 Thread eles
On Thursday, 5 December 2013 at 19:51:52 UTC, Ary Borenszweig wrote: On 12/5/13 4:35 PM, H. S. Teoh wrote: On Thu, Dec 05, 2013 at 03:47:27PM -0300, Ary Borenszweig wrote: [...] Cough, cough, make array length be an int. Do you really need arrays that big? :-S (I'm talking to Mr. D Compiler

Re: Is this reasonable?

2013-12-05 Thread eles
On Thursday, 5 December 2013 at 17:44:18 UTC, H. S. Teoh wrote: On Thu, Dec 05, 2013 at 06:15:37PM +0100, Steve Teale wrote: Here I feel like a beginner, but it seems very unfriendly: import std.stdio; struct ABC { double a; int b; bool c; } ABC[20] aabc; void foo(int n) { writef

Re: Is this reasonable?

2013-12-05 Thread eles
On Thursday, 5 December 2013 at 18:26:48 UTC, Jonathan M Davis wrote: On Thursday, December 05, 2013 19:16:29 Maxim Fomin wrote: On Thursday, 5 December 2013 at 17:15:39 UTC, Steve Teale wrote: the values. The best that could be done would be to warn about the comparison or to make it an err

Re: Is this reasonable?

2013-12-05 Thread Timon Gehr
On 12/05/2013 07:26 PM, Jonathan M Davis wrote: The best that could be done would be to warn about the comparison or to make it an error. http://d.puremagic.com/issues/show_bug.cgi?id=259 ... The best that could be done would arguably be to simply do the comparison the 'right' way. E.g. stati

Re: Detecting value parameter of template instance in "is" expression

2013-12-05 Thread Philippe Sigaud
On Thu, Dec 5, 2013 at 9:17 PM, anonymous wrote: > On Thursday, 5 December 2013 at 20:07:51 UTC, Uranuz wrote: >> How should I define value parameters inside "is" expression to make code >> like this working? > > > is( N == Nullable!(T), T ... ) Or is( N == Nullable!(T, nV), T, alias nV )

Re: Is this reasonable?

2013-12-05 Thread Ary Borenszweig
On 12/5/13 4:59 PM, Maxim Fomin wrote: t and have these surprises all of the time just because "a negative length doesn't make sense"... I don't know, I feel it's not the right way to do it. ulong, it's the same thing.

Re: Detecting value parameter of template instance in "is" expression

2013-12-05 Thread anonymous
On Thursday, 5 December 2013 at 20:07:51 UTC, Uranuz wrote: //--- import std.stdio, std.typecons; template isStdNullable(N) { static if( is( N == Nullable!(T), T ) || is( N == NullableRef!(T), T ) || is( N == Nullable!(T, nV

Detecting value parameter of template instance in "is" expression

2013-12-05 Thread Uranuz
I'm trying to detect values that were instantiated from std.typecons.Nullable (and NullableRef). And I will net to get base types of these Nullable values. For simplicity I write the following code to test for Nullable. //--- import std.stdio, std.typecons; template isStdNulla

Re: Is this reasonable?

2013-12-05 Thread Maxim Fomin
On Thursday, 5 December 2013 at 19:51:52 UTC, Ary Borenszweig wrote: But to make array.length uint by default and have these surprises all of the time just because "a negative length doesn't make sense"... I don't know, I feel it's not the right way to do it. Length of array type is not uin

Re: Is this reasonable?

2013-12-05 Thread Maxim Fomin
On Thursday, 5 December 2013 at 18:26:48 UTC, Jonathan M Davis wrote: On Thursday, December 05, 2013 19:16:29 Maxim Fomin wrote: On Thursday, 5 December 2013 at 17:15:39 UTC, Steve Teale wrote: > Is this unavoidable, or could the compiler safely make the > conversion implicitly? It is example

Re: Is this reasonable?

2013-12-05 Thread Ary Borenszweig
On 12/5/13 4:35 PM, H. S. Teoh wrote: On Thu, Dec 05, 2013 at 03:47:27PM -0300, Ary Borenszweig wrote: [...] Cough, cough, make array length be an int. Do you really need arrays that big? :-S (I'm talking to Mr. D Compiler here) A negative length array makes no sense. Of course not. And it

Re: how to build doc from source?

2013-12-05 Thread Timothee Cour
On Thu, Dec 5, 2013 at 11:40 AM, H. S. Teoh wrote: > On Thu, Dec 05, 2013 at 10:09:59AM -0800, Timothee Cour wrote: > > The instructions in http://wiki.dlang.org/Building_DMD are full of bugs > > (noone bothered to run those apparently), and running make -f posix.mak > > from dlang.org has issues

Re: Checking Compiler version in code?

2013-12-05 Thread H. S. Teoh
On Thu, Dec 05, 2013 at 07:40:51PM +0100, Jeremy DeHaan wrote: > Hey all, > > I was wondering if there was a way to check the compiler version > when running code. My project uses 2.064 and other people that go to > use it will get errors if they haven't upgraded yet, and I'd like to > make a chec

Re: how to build doc from source?

2013-12-05 Thread H. S. Teoh
On Thu, Dec 05, 2013 at 10:09:59AM -0800, Timothee Cour wrote: > The instructions in http://wiki.dlang.org/Building_DMD are full of bugs > (noone bothered to run those apparently), and running make -f posix.mak > from dlang.org has issues, eg dependency on kindlegen. The original instructions on t

Re: Is this reasonable?

2013-12-05 Thread H. S. Teoh
On Thu, Dec 05, 2013 at 03:47:27PM -0300, Ary Borenszweig wrote: [...] > Cough, cough, make array length be an int. > > Do you really need arrays that big? :-S > > (I'm talking to Mr. D Compiler here) A negative length array makes no sense. Plus, being a systems language, D should be able to re

Unresolvable references to dlopen, dlclose etc

2013-12-05 Thread Mafi
I am on fresh install of Linux Mint 16 64bit and I tried to compile some D code I have writen and I have problems ("Hello World" works btw). I uses Derelict (v2) and I have successfully compiled/linked/rurn my program on Windows 7 64bit. But on Linux I get errors about unresolved references to

Re: scoped chdir and similar patterns

2013-12-05 Thread anonymous
On Thursday, 5 December 2013 at 06:24:52 UTC, qznc wrote: = struct chdir_scoped { string olddir; this(string newdir) { olddir = "bar"; writeln("chdir to "~newdir); } ~this() { writeln("chdir back to "~olddir); } } int main() { auto x = chdir_scoped("foo"); w

Re: Is this reasonable?

2013-12-05 Thread Ary Borenszweig
On 12/5/13 2:15 PM, Steve Teale wrote: Here I feel like a beginner, but it seems very unfriendly: import std.stdio; struct ABC { double a; int b; bool c; } ABC[20] aabc; void foo(int n) { writefln("n: %d, aabc.length: %d", n, aabc.length); if (n < aabc.length) write

Checking Compiler version in code?

2013-12-05 Thread Jeremy DeHaan
Hey all, I was wondering if there was a way to check the compiler version when running code. My project uses 2.064 and other people that go to use it will get errors if they haven't upgraded yet, and I'd like to make a check before hand so that if need be I can have a "Please upgrade to the m

Re: Checking Compiler version in code?

2013-12-05 Thread Dicebot
On Thursday, 5 December 2013 at 18:40:53 UTC, Jeremy DeHaan wrote: Hey all, I was wondering if there was a way to check the compiler version when running code. My project uses 2.064 and other people that go to use it will get errors if they haven't upgraded yet, and I'd like to make a check b

Re: Is this reasonable?

2013-12-05 Thread Jonathan M Davis
On Thursday, December 05, 2013 19:16:29 Maxim Fomin wrote: > On Thursday, 5 December 2013 at 17:15:39 UTC, Steve Teale wrote: > > Is this unavoidable, or could the compiler safely make the > > conversion implicitly? > > It is example of notorious phenomemena called "integer > promotions" and "usua

Re: Is this reasonable?

2013-12-05 Thread Maxim Fomin
On Thursday, 5 December 2013 at 17:15:39 UTC, Steve Teale wrote: Is this unavoidable, or could the compiler safely make the conversion implicitly? It is example of notorious phenomemena called "integer promotions" and "usual arithmetic conversions". It is unavoidable given Walter's decision

how to build doc from source?

2013-12-05 Thread Timothee Cour
The instructions in http://wiki.dlang.org/Building_DMD are full of bugs (noone bothered to run those apparently), and running make -f posix.mak from dlang.org has issues, eg dependency on kindlegen. Furthermore, dlang.org's posix.mak requires a git clone, and clones an entire copy of phobos under

Re: Remove function?

2013-12-05 Thread Chris Cain
On Thursday, 5 December 2013 at 16:59:50 UTC, seany wrote: I dont think i have other problems other than perhaps a bug in 2.061 dmd? I'd definitely recommend upgrading to the latest release (2.064.2) since it has lots of bug fixes since 2.061. But if your code is still saying this (your origi

Re: Is this reasonable?

2013-12-05 Thread H. S. Teoh
On Thu, Dec 05, 2013 at 06:15:37PM +0100, Steve Teale wrote: > Here I feel like a beginner, but it seems very unfriendly: > > import std.stdio; > > struct ABC > { >double a; >int b; >bool c; > } > > ABC[20] aabc; > > void foo(int n) > { >writefln("n: %d, aabc.length: %d", n, aab

Is this reasonable?

2013-12-05 Thread Steve Teale
Here I feel like a beginner, but it seems very unfriendly: import std.stdio; struct ABC { double a; int b; bool c; } ABC[20] aabc; void foo(int n) { writefln("n: %d, aabc.length: %d", n, aabc.length); if (n < aabc.length) writeln("A"); else writeln("B"); } void m

Re: Remove function?

2013-12-05 Thread seany
On Thursday, 5 December 2013 at 16:38:11 UTC, Chris Cain wrote: On Thursday, 5 December 2013 at 15:46:41 UTC, seany wrote: First thank you s much for clarification of the operation. You're welcome. however, i tried your solution too. this failed with the same errors as mentioned in the f

Re: Remove function?

2013-12-05 Thread Chris Cain
On Thursday, 5 December 2013 at 15:46:41 UTC, seany wrote: First thank you s much for clarification of the operation. You're welcome. however, i tried your solution too. this failed with the same errors as mentioned in the first post of the thread.. You sure that you don't have some oth

Re: Remove function?

2013-12-05 Thread seany
On Wednesday, 4 December 2013 at 23:03:10 UTC, Chris Cain wrote: Here's a version that does what (I think) you want: -- string stripPar(string S) { while(S[0] == '(' && S[S.length-1] == ')') { S = S[1 .. $ - 1]; } return S; }

Re: selective import

2013-12-05 Thread Alexandr Druzhinin
05.12.2013 20:43, Dicebot пишет: It does not matter what third module uses, it is purely about relation between foo and bar. If foo symbols are not necessary part of public bar API, third module will import both. If they are, bar will import foo publicly. Pretty simple. I realized.

Re: About compiler memory consumption

2013-12-05 Thread Dicebot
On Thursday, 5 December 2013 at 04:02:58 UTC, Puming wrote: There maybe another traditional approach, by converting the .dt diet templates directly into D source code BEFORE the actuall compilation. That is the way many other HTML template systems use, and the performance is fairly good. It i

Re: selective import

2013-12-05 Thread Dicebot
On Thursday, 5 December 2013 at 13:39:09 UTC, Alexandr Druzhinin wrote: 05.12.2013 20:34, Dicebot пишет: On Thursday, 5 December 2013 at 11:17:18 UTC, Alexandr Druzhinin wrote: I don't see difference, but it doesn't mean it doesn't exist. What do you think about it? It depends on how bar use

Re: selective import

2013-12-05 Thread Alexandr Druzhinin
05.12.2013 20:34, Dicebot пишет: On Thursday, 5 December 2013 at 11:17:18 UTC, Alexandr Druzhinin wrote: I don't see difference, but it doesn't mean it doesn't exist. What do you think about it? It depends on how bar uses foo. You should do public import of symbols from foo if they are require

Re: selective import

2013-12-05 Thread Dicebot
On Thursday, 5 December 2013 at 11:17:18 UTC, Alexandr Druzhinin wrote: I don't see difference, but it doesn't mean it doesn't exist. What do you think about it? It depends on how bar uses foo. You should do public import of symbols from foo if they are required to interact with bar public AP

selective import

2013-12-05 Thread Alexandr Druzhinin
Hi all. How to use use selective imports more effectively? I have two modules foo and bar: module foo; class Foo {} module bar; import foo: Foo; class Bar { private Foo foo_; this(Foo foo) { foo_ = foo; } } Now I add module baz that use both