Re: Intended to be able to RefCount an interface?

2015-02-10 Thread Jakob Ovrum via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 06:26:39 UTC, weaselcat wrote: Is there currently an enhancement request open for this on the bug tracker? I cannot find anything. I couldn't find it either, so I filed it: https://issues.dlang.org/show_bug.cgi?id=14168

Re: To write such an expressive code D

2015-02-10 Thread FG via Digitalmars-d-learn
On 2015-02-11 at 01:56, bearophile wrote: Alternative solution closer to the F# code: import std.stdio, std.algorithm, std.typecons; int f(T)(T t) if (isTuple!T) { return t.predSwitch( tuple(0, 0, 0), 0, tuple(0, 1, 1), 0, tuple(1, 0, 1), 0, tuple(1, 1,

Re: Compilation with dub + dmd: out of memory

2015-02-10 Thread ddos via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 12:18:15 UTC, Vlasov Roman wrote: On Tuesday, 10 February 2015 at 11:55:43 UTC, Daniel Kozák wrote: V Tue, 10 Feb 2015 11:44:09 + Vlasov Roman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: On Tuesday, 10 February 2015 at 11:32:32 UTC,

Re: Classes and @disable this()

2015-02-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 10, 2015 11:16:21 via Digitalmars-d-learn wrote: On Monday, 9 February 2015 at 20:15:28 UTC, Jonathan M Davis Why would it we even allow it? What benefit is there? It's meaningless. @disable this(); is for disabling the init property on structs. Classes themselves

Re: Classes and @disable this()

2015-02-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/10/15 12:15 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, February 10, 2015 11:16:21 via Digitalmars-d-learn wrote: On Monday, 9 February 2015 at 20:15:28 UTC, Jonathan M Davis Why would it we even allow it? What benefit is there? It's meaningless. @disable this(); is

Re: To write such an expressive code D

2015-02-10 Thread Vladimir Panteleev via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 04:17:48 UTC, Dennis Ritchie wrote: I just need that code was only used features of the language without using library functions. You may only use the function sin(). Why is that? Although D has a lot of language features, D tries to push functionality into

cannot deduce function from argument types issue.

2015-02-10 Thread ted via Digitalmars-d-learn
Hi! I get the following compile error (linux, dmd2.066.1): test.d(13): Error: template test.testFunc cannot deduce function from argument types !()(double[], double), candidates are: test.d(3):test.testFunc(R)(R range, ElementType!R foo) For the following test file: import std.range:

Re: cannot deduce function from argument types issue.

2015-02-10 Thread ted via Digitalmars-d-learn
Ali Çehreli wrote: On 02/10/2015 12:31 AM, ted wrote: ElementType!R testFunc(R)( R range, ElementType!R foo) // compiles with double foo If think it is a little too much to ask from the template system of D. A proper way of doing the same thing is to use a template constraint:

Re: How to write similar code D?

2015-02-10 Thread bearophile via Digitalmars-d-learn
FG: auto query = iota(2, 2 + 10) .map!(c = [Length: 2 * c, Height: c * c - 1, Hypotenuse: c * c + 1]) .map!(x = format(%4d%4d%4d, x[Height], Unlike other languages like JavaScript, the D front-end is very weak in optimizing well such kind of code... I think D compilers handle

Re: To write such an expressive code D

2015-02-10 Thread Dicebot via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 08:40:38 UTC, Dennis Ritchie wrote: Because I was arguing with one quiet a stubborn person who does not like D, on this forum: http://www.cyberforum.ru/holywars/thread1367892-page13.html He asked me to write such a program using only the language features and

Re: cannot deduce function from argument types issue.

2015-02-10 Thread Ali Çehreli via Digitalmars-d-learn
On 02/10/2015 12:31 AM, ted wrote: ElementType!R testFunc(R)( R range, ElementType!R foo) // compiles with double foo If think it is a little too much to ask from the template system of D. A proper way of doing the same thing is to use a template constraint: ElementType!R testFunc(R,

Re: cannot deduce function from argument types issue.

2015-02-10 Thread bearophile via Digitalmars-d-learn
ted: Could someone enlighten me ? This works: import std.range: ElementType, isInputRange; ElementType!R testFunc(R, T)(R range, T foo) if (is(ElementType!R == T)) { static assert(isInputRange!R); typeof(return) retVal = foo ^^ 2; // More DRY. return retVal; } void main() {

Re: cannot deduce function from argument types issue.

2015-02-10 Thread bearophile via Digitalmars-d-learn
Ali Çehreli: If think it is a little too much to ask from the template system of D. I remember hitting a similar problem with code like this bar() function: // OK void foo(size_t N1, size_t N2)(int[N1] a, int[N2] b) if (N2 == N1 ^^ 2) {} // Not OK void bar(size_t N)(int[N] a, int[N ^ 2]

Re: To write such an expressive code D

2015-02-10 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 08:12:00 UTC, Vladimir Panteleev wrote: Why is that? Потому что я спорил с одним упёртым человеком, которому не нравится D, на этом форуме: http://www.cyberforum.ru/holywars/thread1367892-page13.html Он просил меня написать такую программу с использованием

Re: To write such an expressive code D

2015-02-10 Thread Tobias Pankrath via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 08:40:38 UTC, Dennis Ritchie wrote: On Tuesday, 10 February 2015 at 08:12:00 UTC, Vladimir Panteleev wrote: Why is that? Потому что я спорил с одним упёртым человеком, которому не нравится D, на этом форуме:

Re: cannot deduce function from argument types issue.

2015-02-10 Thread bearophile via Digitalmars-d-learn
void bar(size_t N)(int[N] a, int[N ^ 2] b) {} I meant: void bar(size_t N)(int[N] a, int[N ^^ 2] b) {}

Re: cannot deduce function from argument types issue.

2015-02-10 Thread ted via Digitalmars-d-learn
bearophile wrote: ted: Could someone enlighten me ? This works: import std.range: ElementType, isInputRange; ElementType!R testFunc(R, T)(R range, T foo) if (is(ElementType!R == T)) { static assert(isInputRange!R); typeof(return) retVal = foo ^^ 2; // More DRY.

Re: cannot deduce function from argument types issue.

2015-02-10 Thread ted via Digitalmars-d-learn
bearophile wrote: ted: ... where you say 'More DRY' above, are you referring to I was referring to both, but mostly to the typeof. It's more DRY (http://en.wikipedia.org/wiki/Don%27t_repeat_yourself ). You are stating only once the type of the return variable. This is less bug-prone.

Re: Classes and @disable this()

2015-02-10 Thread bearophile via Digitalmars-d-learn
I think this can be filed in Bugzilla as diagnostic enhancement: class Foo { @disable this(); this(int i) {} } void main() {} https://issues.dlang.org/show_bug.cgi?id=14163 Bye, bearophile

Re: cannot deduce function from argument types issue.

2015-02-10 Thread bearophile via Digitalmars-d-learn
ted: ... where you say 'More DRY' above, are you referring to I was referring to both, but mostly to the typeof. It's more DRY (http://en.wikipedia.org/wiki/Don%27t_repeat_yourself ). You are stating only once the type of the return variable. This is less bug-prone. Bye, bearophile

Re: cannot deduce function from argument types issue.

2015-02-10 Thread Ali Çehreli via Digitalmars-d-learn
On 02/10/2015 01:08 AM, bearophile wrote: // Not OK void bar(size_t N)(int[N] a, int[N ^^ 2] b) {} So perhaps my suggestion to file an enhancement request is not a good idea... I am not sure. Although the template system already does pretty clever deductions, I think they are all based on

Re: To write such an expressive code D

2015-02-10 Thread ketmar via Digitalmars-d-learn
On Tue, 10 Feb 2015 08:40:36 +, Dennis Ritchie wrote: On Tuesday, 10 February 2015 at 08:12:00 UTC, Vladimir Panteleev wrote: Why is that? Потому что я спорил с одним упёртым человеком, которому не нравится D, на этом

Re: Classes and @disable this()

2015-02-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, February 09, 2015 15:25:14 Steven Schveighoffer via Digitalmars-d-learn wrote: Well, if I do this: class C {} I can do this: new C(); Mechanisms to disable this are kind of awkward. I can define this() as private, but that doesn't help for intra-module calls. static class C

How to Write Raw Bytes to Disk

2015-02-10 Thread via Digitalmars-d-learn
How do I write a byte[] in raw (unformatted) format to disk? File(f.raw, wb).write(x) doesn't seem to do it. Why isn't the wb interpreted as raw bytes?

Re: How to Write Raw Bytes to Disk

2015-02-10 Thread via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 11:03:06 UTC, Per Nordlöw wrote: How do I write a byte[] in raw (unformatted) format to disk? File(f.raw, wb).write(x) doesn't seem to do it. Why isn't the wb interpreted as raw bytes? Oops, I just discovered File(f.raw, wb).rawWrite(x) .

Re: To write such an expressive code D

2015-02-10 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 11:33:54 UTC, bearophile wrote: Dennis Ritchie: Please help. This starts to look like homework :-) Bye, bearophile This is not homework - this is a war of code on C#/F# and D. I've been programming in D, my opponent on F#/C#.

Re: To write such an expressive code D

2015-02-10 Thread ketmar via Digitalmars-d-learn
On Tue, 10 Feb 2015 11:33:54 +, bearophile wrote: Dennis Ritchie: Please help. This starts to look like homework :-) it's much worse: meaningless pseudocomparison of different languages for nothing. signature.asc Description: PGP signature

Re: Classes and @disable this()

2015-02-10 Thread via Digitalmars-d-learn
On Monday, 9 February 2015 at 20:15:28 UTC, Jonathan M Davis wrote: On Monday, February 09, 2015 13:29:22 Steven Schveighoffer via Digitalmars-d-learn wrote: On 2/8/15 2:57 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Sunday, February 08, 2015 17:51:09 bearophile via

Compilation with dub + dmd: out of memory

2015-02-10 Thread Vlasov Roman via Digitalmars-d-learn
I have the quite computer with 2 GB RAM. At compilation with dub and dmd of small project this pair eating about 1.4~1.5 GB RAM. I solve this probleb by connecting swap partition, but it calls some freezes + it take ~10% of swap, and after compilation swap not released. At switching off swap

Re: To write such an expressive code D

2015-02-10 Thread Dennis Ritchie via Digitalmars-d-learn
Please help. import std.stdio; import std.stdio; void main() { /* return (a xor b xor c) */ int nobitxor(int a, int b, int c) { return (a + b + c == 2 || a + b + c == 0) ? 0 : 1; } int a, b, c; a = b = c = 0;

Re: To write such an expressive code D

2015-02-10 Thread bearophile via Digitalmars-d-learn
Dennis Ritchie: Please help. This starts to look like homework :-) Bye, bearophile

Re: Compilation with dub + dmd: out of memory

2015-02-10 Thread bearophile via Digitalmars-d-learn
Vlasov Roman: I have the quite computer with 2 GB RAM. At compilation with dub and dmd of small project this pair eating about 1.4~1.5 GB RAM. I solve this probleb by connecting swap partition, but it calls some freezes + it take ~10% of swap, and after compilation swap not released. At

Re: To write such an expressive code D

2015-02-10 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 11:41:20 UTC, ketmar wrote: On Tue, 10 Feb 2015 11:33:54 +, bearophile wrote: Dennis Ritchie: Please help. This starts to look like homework :-) it's much worse: meaningless pseudocomparison of different languages for nothing. This task

Re: Compilation with dub + dmd: out of memory

2015-02-10 Thread Daniel Kozák via Digitalmars-d-learn
V Tue, 10 Feb 2015 11:44:09 + Vlasov Roman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: On Tuesday, 10 February 2015 at 11:32:32 UTC, bearophile wrote: Vlasov Roman: I have the quite computer with 2 GB RAM. At compilation with dub and dmd of small project this

Re: Compilation with dub + dmd: out of memory

2015-02-10 Thread ketmar via Digitalmars-d-learn
On Tue, 10 Feb 2015 13:03:14 +, Vlasov Roman wrote: Whether correctly I understand that the problem is that my dependences have other dependences which are compiled with my project? dub tries to build the libraries your project depends on, and some of that libraries are very big. but once

Re: Ncurses deprecated ~master issue

2015-02-10 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Feb 10, 2015 at 09:05:06PM +, Meta via Digitalmars-d-learn wrote: On Tuesday, 10 February 2015 at 20:50:28 UTC, Paul wrote: [...] test.o: In function `_Dmain': test.d:(.text._Dmain+0x13): undefined reference to `_D8terminal8Terminal6__initZ' test.d:(.text._Dmain+0x3c): undefined

Re: Ncurses deprecated ~master issue

2015-02-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 20:50:28 UTC, Paul wrote: test.o: In function `_Dmain': test.d:(.text._Dmain+0x13): undefined reference to `_D8terminal8Terminal6__initZ' If you see 'undefined reference' it means some library wasn't passed to the compiler. Easiest fix is usually to add the .d

Re: Ncurses deprecated ~master issue

2015-02-10 Thread Meta via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 20:50:28 UTC, Paul wrote: On Tuesday, 10 February 2015 at 19:49:26 UTC, ketmar wrote: On Tue, 10 Feb 2015 19:37:59 +, Meta wrote: I can't answer your question, but if you're just prototyping you could use Adam Ruppe's terminal.d until you get ncurses

Re: Ncurses deprecated ~master issue

2015-02-10 Thread Paul via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 20:57:43 UTC, Adam D. Ruppe wrote: On Tuesday, 10 February 2015 at 20:50:28 UTC, Paul wrote: test.o: In function `_Dmain': test.d:(.text._Dmain+0x13): undefined reference to `_D8terminal8Terminal6__initZ' If you see 'undefined reference' it means some library

Re: Ncurses deprecated ~master issue

2015-02-10 Thread Paul via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 21:05:08 UTC, Meta wrote: On Tuesday, 10 February 2015 at 20:50:28 UTC, Paul wrote: On Tuesday, 10 February 2015 at 19:49:26 UTC, ketmar wrote: On Tue, 10 Feb 2015 19:37:59 +, Meta wrote: I can't answer your question, but if you're just prototyping you

Re: Ncurses deprecated ~master issue

2015-02-10 Thread ketmar via Digitalmars-d-learn
On Tue, 10 Feb 2015 19:37:59 +, Meta wrote: I can't answer your question, but if you're just prototyping you could use Adam Ruppe's terminal.d until you get ncurses working. https://github.com/adamdruppe/arsd/blob/master/terminal.d and i daresay that with 'terminal.d' there is no need in

Re: Ncurses deprecated ~master issue

2015-02-10 Thread Meta via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 13:18:34 UTC, Paul wrote: On Wednesday, 3 December 2014 at 19:37:03 UTC, Paul wrote: On Wednesday, 3 December 2014 at 17:37:18 UTC, Matt Soucy wrote: On 12/03/2014 07:07 AM, Paul wrote: Sorry if this is a little off-topic, I posted this in the Dub forum on

Why is one d file compiled into two files object file executable.

2015-02-10 Thread Venkat Akkineni via Digitalmars-d-learn
Hi I am coming from Java. What is the purpose of an object file why is it generated at compile time in addition to an executable. I know C generates an object file too, but I don't know what the use is. Please point me to any detailed documentation u may have regarding object files.

Re: Why is one d file compiled into two files object file executable.

2015-02-10 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 11 February 2015 at 05:08:16 UTC, Venkat Akkineni wrote: I am coming from Java. What is the purpose of an object file why is it generated at compile time in addition to an executable. I know C generates an object file too, but I don't know what the use is. Java uses a similar

Re: primitive type variables not nullable ?

2015-02-10 Thread Venkat Akkineni via Digitalmars-d-learn
Thanks Gentlemen. That helped. On Monday, 9 February 2015 at 00:00:00 UTC, bearophile wrote: Tobias Pankrath: Check for null with (x is null) not via printing to stdout. In most cases instead of checking dynamic arrays for null, it's better to use std.array.empty. Bye, bearophile

Re: Why is one d file compiled into two files object file executable.

2015-02-10 Thread Andre Artus via Digitalmars-d-learn
On Wednesday, 11 February 2015 at 05:08:16 UTC, Venkat Akkineni wrote: Hi I am coming from Java. What is the purpose of an object file why is it generated at compile time in addition to an executable. I know C generates an object file too, but I don't know what the use is. Hi Venkat,

Re: dub.json dependencies per configuration?

2015-02-10 Thread Arjan via Digitalmars-d-learn
On Wednesday, 11 February 2015 at 01:06:02 UTC, Mike Parker wrote: On 2/11/2015 8:38 AM, Arjan wrote: Snippet from: https://github.com/buggins/ddbc/blob/master/dub.json#L7 ddbc has a dependencies on mysql-native: =0.0.12. But this is only true for configurations: MySQL. Is it allowed to put

Re: Compilation with dub + dmd: out of memory

2015-02-10 Thread Vlasov Roman via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 12:42:07 UTC, ketmar wrote: On Tue, 10 Feb 2015 11:44:09 +, Vlasov Roman wrote: On Tuesday, 10 February 2015 at 11:32:32 UTC, bearophile wrote: Vlasov Roman: I have the quite computer with 2 GB RAM. At compilation with dub and dmd of small project this

Re: Ncurses deprecated ~master issue

2015-02-10 Thread Paul via Digitalmars-d-learn
On Wednesday, 3 December 2014 at 19:37:03 UTC, Paul wrote: On Wednesday, 3 December 2014 at 17:37:18 UTC, Matt Soucy wrote: On 12/03/2014 07:07 AM, Paul wrote: Sorry if this is a little off-topic, I posted this in the Dub forum on 23/11/14 but have had no reply yet: --- I read that the use

Re: Compilation with dub + dmd: out of memory

2015-02-10 Thread ketmar via Digitalmars-d-learn
On Tue, 10 Feb 2015 11:44:09 +, Vlasov Roman wrote: On Tuesday, 10 February 2015 at 11:32:32 UTC, bearophile wrote: Vlasov Roman: I have the quite computer with 2 GB RAM. At compilation with dub and dmd of small project this pair eating about 1.4~1.5 GB RAM. I solve this probleb by

Re: Compilation with dub + dmd: out of memory

2015-02-10 Thread Vlasov Roman via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 11:55:43 UTC, Daniel Kozák wrote: V Tue, 10 Feb 2015 11:44:09 + Vlasov Roman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: On Tuesday, 10 February 2015 at 11:32:32 UTC, bearophile wrote: Vlasov Roman: I have the quite computer with 2

Re: Ncurses deprecated ~master issue

2015-02-10 Thread Meta via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 21:14:36 UTC, H. S. Teoh wrote: Judging by the name of the object file (test.o) and the name of the code section (.text), I'd say this is definitely Posix. :-) So the question is why that ctor isn't defined in spite of it being Posix. T Heh, you are right. I

dub.json dependencies per configuration?

2015-02-10 Thread Arjan via Digitalmars-d-learn
Snippet from: https://github.com/buggins/ddbc/blob/master/dub.json#L7 ddbc has a dependencies on mysql-native: =0.0.12. But this is only true for configurations: MySQL. Is it allowed to put the dependency within the configuration section for MySQL?. dependencies: { mysql-native:

Re: Ncurses deprecated ~master issue

2015-02-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 21:11:14 UTC, Paul wrote: Yes, I noted the default values, even if I don't understand what they do at present(!). They allow overriding of the input/output files. fdIn normally refers to standard input, fdOut refers to standard output, and the getSizeOverride

Re: To write such an expressive code D

2015-02-10 Thread Dennis Ritchie via Digitalmars-d-learn
F#: let f = function | 0 , 0 , 0 - 0 | 0 , 1 , 1 - 0 | 1 , 0 , 1 - 0 | 1 , 1 , 0 - 0 | _ - 1 for a in 0..1 do for b in 0..1 do for c in 0..1 do printfn %i xor %i xor %i = %i a b c (f (a, b, c)) Output: 0 xor 0 xor 0 = 0 0 xor 0 xor 1 = 1 0

Re: To write such an expressive code D

2015-02-10 Thread bearophile via Digitalmars-d-learn
Dennis Ritchie: Output: 0 xor 0 xor 0 = 0 0 xor 0 xor 1 = 1 0 xor 1 xor 0 = 1 0 xor 1 xor 1 = 0 1 xor 0 xor 0 = 1 1 xor 0 xor 1 = 0 1 xor 1 xor 0 = 0 1 xor 1 xor 1 = 1 This man again took advantage of the fact that in D there is no such operation - (analog switch). A natural solution in D:

Re: dub.json dependencies per configuration?

2015-02-10 Thread Mike Parker via Digitalmars-d-learn
On 2/11/2015 8:38 AM, Arjan wrote: Snippet from: https://github.com/buggins/ddbc/blob/master/dub.json#L7 ddbc has a dependencies on mysql-native: =0.0.12. But this is only true for configurations: MySQL. Is it allowed to put the dependency within the configuration section for MySQL?. Yes.

Re: To write such an expressive code D

2015-02-10 Thread Dennis Ritchie via Digitalmars-d-learn
On Wednesday, 11 February 2015 at 00:56:03 UTC, bearophile wrote: Dennis Ritchie: Output: 0 xor 0 xor 0 = 0 0 xor 0 xor 1 = 1 0 xor 1 xor 0 = 1 0 xor 1 xor 1 = 0 1 xor 0 xor 0 = 1 1 xor 0 xor 1 = 0 1 xor 1 xor 0 = 0 1 xor 1 xor 1 = 1 This man again took advantage of the fact that in D there