Re: Better native D 2D graphics library?

2015-02-09 Thread Namespace via Digitalmars-d-learn
On Monday, 9 February 2015 at 05:50:00 UTC, uri wrote: On Saturday, 7 February 2015 at 23:29:01 UTC, Namespace wrote: On Saturday, 7 February 2015 at 22:09:03 UTC, Gan wrote: Is there a better D graphics library in the works? I'm using SFML(which is very easy and has lots of features) but it

Re: Static method of inner class needs this

2015-02-09 Thread wobbles via Digitalmars-d-learn
On Monday, 9 February 2015 at 07:32:33 UTC, rumbu wrote: class Outer { class Inner { static Inner createInner() { return new Inner(); //need 'this' to access member this } } } Is this a bug? If Inner is not nested, it works as expected: class I

Re: Static method of inner class needs this

2015-02-09 Thread ketmar via Digitalmars-d-learn
On Mon, 09 Feb 2015 07:32:32 +, rumbu wrote: > class Outer { > class Inner { > static Inner createInner() > { > return new Inner(); //need 'this' to access member > this > } > } > } > > Is this a bug? strictly speaking, this is not a bug. com

Re: Template constructor in a non-template struct.

2015-02-09 Thread via Digitalmars-d-learn
On Sunday, 8 February 2015 at 22:19:35 UTC, ChrisG wrote: Thanks bearophile. Your first suggestion about making the struct a template is something I considered. However, because of all the code I've already written that approach would force me to use inheritance or convert a ton of functions to

Re: Classes and @disable this()

2015-02-09 Thread via Digitalmars-d-learn
On Sunday, 8 February 2015 at 19:57:28 UTC, Jonathan M Davis wrote: On Sunday, February 08, 2015 17:51:09 bearophile via Digitalmars-d-learn wrote: fra: > However making it a compiler error would be far, far better I think this can be filed in Bugzilla as diagnostic enhancement: class Foo

Re: Static method of inner class needs this

2015-02-09 Thread rumbu via Digitalmars-d-learn
On Monday, 9 February 2015 at 09:30:55 UTC, ketmar wrote: ... you can use `static class Inner` to tell the compiler that `Inner` doesn't require any context. Thank you, static qualifier works. I thought in C# terms where a static class means anything else.

Re: Learning to XML with D

2015-02-09 Thread Derix via Digitalmars-d-learn
What I don't quite grab is the construct (in Element e) , especially the *in* part. Function parameters in D can be qualified as in or out, optionally: But of course. Actually I kinda found out just a little while after posting the question. Asking questions is a great way to figure out th

Re: Learning to XML with D

2015-02-09 Thread Derix via Digitalmars-d-learn
my dom.d works in a familiar way OK, will check it useful for scraping html sites. Not exactly what I'm doing, but close. I'm in the midst of a self-training spree, and what I use as test-tubes fodder is the following : a collection of 300+ html files constituting an electronic version of a

Re: Better native D 2D graphics library?

2015-02-09 Thread ponce via Digitalmars-d-learn
On Saturday, 7 February 2015 at 22:09:03 UTC, Gan wrote: Is there a better D graphics library in the works? I'm using SFML(which is very easy and has lots of features) but it seems to use a lot of ram(if you leave it running for a while on a graphic intensive scene) and trying to make it incl

Re: parse string as char

2015-02-09 Thread FG via Digitalmars-d-learn
On 2015-02-09 at 03:40, Timothee Cour via Digitalmars-d-learn wrote: Is there a simple way to parse a string as a char? eg: unittest{ assert(parseChar(`a`)=='a'); assert(parseChar(`\n`)=='\n'); //NOTE: I'm looking at `\n` not "\n" // should also work with other forms of characters, see

Re: parse string as char

2015-02-09 Thread FG via Digitalmars-d-learn
Of course consuming it dchar by dchar also works: string s = `\tabŁŃ\r\nx`; assert(parseDchar(s) == '\t'); assert(parseDchar(s) == 'a'); assert(parseDchar(s) == 'b'); assert(parseDchar(s) == 'Ł'); assert(parseDchar(s) == 'Ń'); assert(parseDchar(s) == '\r'); assert(

Worker is not finished while sending message to intermediate worker

2015-02-09 Thread xtreak via Digitalmars-d-learn
I am using "programming in D" to learn about D language. I wrote a simple program that spawns a worker and sends it a number to receive its square as a string. The worker 1 gets the number squares it and sends to worker 2 (a different function) to get casted as string which is returned to the w

Re: parse string as char

2015-02-09 Thread Kagamin via Digitalmars-d-learn
https://github.com/Hackerpilot/libdparse/blob/master/src/std/d/lexer.d#L1491

Re: Classes and @disable this()

2015-02-09 Thread Steven Schveighoffer via Digitalmars-d-learn
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 Digitalmars-d-learn wrote: fra: However making it a compiler error would be far, far better I think this can be filed in Bugzilla as diagnostic enhancement: class Foo {

Re: Static method of inner class needs this

2015-02-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/9/15 4:30 AM, ketmar wrote: On Mon, 09 Feb 2015 07:32:32 +, rumbu wrote: class Outer { class Inner { static Inner createInner() { return new Inner(); //need 'this' to access member this } } } Is this a bug? strictly speaking, t

Binding C++ value types

2015-02-09 Thread Benjamin Thaut via Digitalmars-d-learn
When binding C++ value types you might want to use them by placing them on the D-Stack. This however seems to be not supported as the mangling for the constructor is completely wrong. Is this supposed to work? Kind Regards Benjamin Thaut

To write such an expressive code D

2015-02-09 Thread Dennis Ritchie via Digitalmars-d-learn
Good evening. Is it possible to D something to replace the container on the F#, which displays the values of the sine from 0 to 90 degrees with an interval of 10 degrees: let pi = Math.PI let sins = [for x in 0.0..pi / 2.0 / 9.0..pi / 2.0 -> sin x] sins.Dump() Output: 0 0,17364817766693 0,3420

Re: To write such an expressive code D

2015-02-09 Thread Tobias Pankrath via Digitalmars-d-learn
On Monday, 9 February 2015 at 19:40:42 UTC, Dennis Ritchie wrote: Good evening. Is it possible to D something to replace the container on the F#, which displays the values of the sine from 0 to 90 degrees with an interval of 10 degrees: let pi = Math.PI let sins = [for x in 0.0..pi / 2.0 / 9.0

Re: Worker is not finished while sending message to intermediate worker

2015-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 02/09/2015 08:00 AM, xtreak wrote: I am using "programming in D" to learn about D language. I wrote a simple program that spawns a worker and sends it a number to receive its square as a string. The worker 1 gets the number squares it and sends to worker 2 (a different function) to get casted

Re: To write such an expressive code D

2015-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 02/09/2015 11:45 AM, Tobias Pankrath wrote: iota(0, 91, 10).map!sin.writeln or something like that. Yes: :) import std.math; import std.stdio; import std.range; import std.algorithm; void main() { const beg = 0.0L; const interval = PI_2 / 9; const end = PI_2 + interval;

Re: signal handling

2015-02-09 Thread rlonstein via Digitalmars-d-learn
On Saturday, 7 February 2015 at 18:30:00 UTC, Danny wrote: [snip] Seems to work fine so far. Not sure whether it's safe to raise() inside a signal handler. Calling raise() without reinstalling the old signal handler is a very bad idea, I [snip] I'm not sure that it's really safe to cal

Re: To write such an expressive code D

2015-02-09 Thread Vladimir Panteleev via Digitalmars-d-learn
On Monday, 9 February 2015 at 19:57:23 UTC, Ali Çehreli wrote: writefln("%(%.15g\n%)", sins); In 2.067, you can write: iota(0, PI/2, PI/2/9).map!sin.each!writeln;

Re: To write such an expressive code D

2015-02-09 Thread Dennis Ritchie via Digitalmars-d-learn
Thank you, Tobias Pankrath and Ali Çehreli.

Re: To write such an expressive code D

2015-02-09 Thread Dennis Ritchie via Digitalmars-d-learn
On Monday, 9 February 2015 at 20:03:00 UTC, Vladimir Panteleev wrote: On Monday, 9 February 2015 at 19:57:23 UTC, Ali Çehreli wrote: writefln("%(%.15g\n%)", sins); In 2.067, you can write: iota(0, PI/2, PI/2/9).map!sin.each!writeln; March 1!

Re: Worker is not finished while sending message to intermediate worker

2015-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 02/09/2015 11:46 AM, Ali Çehreli wrote: > threads normally start one [or] more worker threads and > send tasks to those threads Accordingly, the following program uses just three threads: import std.stdio; import std.concurrency; import std.conv; import core.thread; struct Terminate {} voi

Re: Classes and @disable this()

2015-02-09 Thread Jonathan M Davis via Digitalmars-d-learn
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 Digitalmars-d-learn > > wrote: > >> fra: > >> > >>> However making it a compiler

Re: To write such an expressive code D

2015-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 02/09/2015 12:05 PM, Dennis Ritchie wrote: On Monday, 9 February 2015 at 20:03:00 UTC, Vladimir Panteleev wrote: On Monday, 9 February 2015 at 19:57:23 UTC, Ali Çehreli wrote: writefln("%(%.15g\n%)", sins); In 2.067, you can write: iota(0, PI/2, PI/2/9).map!sin.each!writeln; March 1!

Re: Classes and @disable this()

2015-02-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/9/15 3:15 PM, Jonathan M Davis via Digitalmars-d-learn 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 Digitalmars-d-lea

Re: Worker is not finished while sending message to intermediate worker

2015-02-09 Thread xtreak via Digitalmars-d-learn
On Monday, 9 February 2015 at 20:11:09 UTC, Ali Çehreli wrote: On 02/09/2015 11:46 AM, Ali Çehreli wrote: > threads normally start one [or] more worker threads and > send tasks to those threads Accordingly, the following program uses just three threads: import std.stdio; import std.concurrency

hasmap with tuple as key

2015-02-09 Thread Ondra via Digitalmars-d-learn
Is there any drawback of doing this: string[Tuple!(int, int)] a; Especially performance one. Thanks.

Re: Worker is not finished while sending message to intermediate worker

2015-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 02/09/2015 12:34 PM, xtreak wrote: > I want the stringConverter to send a message to square which in > turn messages the main function with string "hello". Your code did almost that but there was a bug (which I've pointed out). > So are you saying that message is not delivered to square from

Re: signal handling

2015-02-09 Thread Danny via Digitalmars-d-learn
Hmmm... Just found , the bottom part "Compliant Solution (POSIX)" does raise() in the signal handler. However, I can't find it in the POSIX standard at

How to write similar code D?

2015-02-09 Thread Dennis Ritchie via Digitalmars-d-learn
Tell me, please, how to write similar С# code D: using System; using System.Linq; public class Test { public static void Main() { var query = Enumerable.Range(2, 10) .Select(c => new { Length = 2 * c, Height = c * c - 1, Hypotenuse = c * c + 1 }) .Select(x => str

Re: internal compiler error with immutable

2015-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 02/08/2015 05:21 AM, Danny wrote: The obvious bool opEquals(immutable(C) b) immutable { return value == b.value; } doesn't work. Probably have to override the one from Object ? Even though I don't really use polymorphism here. override bool opEquals(Object b) immutabl

Re: How to write similar code D?

2015-02-09 Thread bearophile via Digitalmars-d-learn
Dennis Ritchie: Tell me, please, how to write similar С# code D: This is more or less exactly the same: void main() { import std.stdio, std.range, std.algorithm, std.typecons, std.format; auto query = iota(2, 12) .map!(c => Tuple!(int,"length", int,"height", int,"

Re: How to write similar code D?

2015-02-09 Thread FG via Digitalmars-d-learn
On 2015-02-10 at 01:41, bearophile wrote: auto query = iota(2, 12) .map!(c => Tuple!(int,"length", int,"height", int,"hypotenuse") (2 * c, c ^^ 2 - 1, c ^^ 2 + 1)) .map!(x => "%3d%4d%4d".format(x.height, x.hypotenuse,

Re: How to write similar code D?

2015-02-09 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 01:31:54 UTC, FG wrote: On 2015-02-10 at 01:41, bearophile wrote: auto query = iota(2, 12) .map!(c => Tuple!(int,"length", int,"height", int,"hypotenuse") (2 * c, c ^^ 2 - 1, c ^^ 2 + 1)) .

function and variable

2015-02-09 Thread Fyodor Ustinov via Digitalmars-d-learn
Hi! I think this code should not be compiled without any warning: import std.stdio; void f(int a) { writeln("it's a function! : ", a); } void main() { auto f = function (int a) {writeln("It's a variable! : ", a);}; 5.f(); f(5); } Output: it's a function! : 5 It's a variable

Re: function and variable

2015-02-09 Thread Rikki Cattermole via Digitalmars-d-learn
On 10/02/2015 4:28 p.m., Fyodor Ustinov wrote: Hi! I think this code should not be compiled without any warning: import std.stdio; void f(int a) { writeln("it's a function! : ", a); } void main() { auto f = function (int a) {writeln("It's a variable! : ", a);}; 5.f(); f(5)

Re: function and variable

2015-02-09 Thread Fyodor Ustinov via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 03:59:22 UTC, Rikki Cattermole wrote: That's a bug. It should be using the function pointer. UFCS call should abide by the same scoping rules as anything else. https://issues.dlang.org/show_bug.cgi?id=14161 Moreover. If the function is not defined (only pointe

Re: function and variable

2015-02-09 Thread Vlad Levenfeld via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 03:59:22 UTC, Rikki Cattermole wrote: That's a bug. It should be using the function pointer. UFCS call should abide by the same scoping rules as anything else. https://issues.dlang.org/show_bug.cgi?id=14161 I thought that's how UFCS was explicitly designed? Gl

Re: To write such an expressive code D

2015-02-09 Thread Dennis Ritchie via Digitalmars-d-learn
On Monday, 9 February 2015 at 20:16:45 UTC, Ali Çehreli wrote: Yes, but apparently D's default precision for output is less than F#'s so how about the following? :p "%(%.15g\n%)".writefln(iota(0, PI/2, PI/2/9).map!sin); Just for demonstration, I would not write anything like that but the

Re: function and variable

2015-02-09 Thread Fyodor Ustinov via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 04:11:43 UTC, Vlad Levenfeld wrote: On Tuesday, 10 February 2015 at 03:59:22 UTC, Rikki Cattermole wrote: That's a bug. It should be using the function pointer. UFCS call should abide by the same scoping rules as anything else. https://issues.dlang.org/show_bug

Re: function and variable

2015-02-09 Thread Vlad Levenfeld via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 04:20:27 UTC, Fyodor Ustinov wrote: IMHO even if "it is not a bug, it is a feature" - it should not be compiled without notice. WBR, Fyodor. Agreed, should be a warning at least.

Intended to be able to RefCount an interface?

2015-02-09 Thread weaselcat via Digitalmars-d-learn
Thread title. interface Itest{ } class testclass : Itest{ } void main() { import std.typecons; auto test = RefCounted!Itest(new testclass()); } If you change the refcounted to type testclass it doesn't compile because refcounted doesn't support classes. Is this a bug, or intended?

Re: Binding C++ value types

2015-02-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 9 February 2015 at 19:30:32 UTC, Benjamin Thaut wrote: When binding C++ value types you might want to use them by placing them on the D-Stack. This however seems to be not supported as the mangling for the constructor is completely wrong. Is this supposed to work? Kind Regards Benj

Re: hasmap with tuple as key

2015-02-09 Thread Meta via Digitalmars-d-learn
On Monday, 9 February 2015 at 21:22:29 UTC, Ondra wrote: Is there any drawback of doing this: string[Tuple!(int, int)] a; Especially performance one. Thanks. Tuples are really just structs generated "on the fly", so they are very fast. Hashmaps use the GC, though, so keep that in mind.

Re: Intended to be able to RefCount an interface?

2015-02-09 Thread Jakob Ovrum via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 04:44:55 UTC, weaselcat wrote: Thread title. interface Itest{ } class testclass : Itest{ } void main() { import std.typecons; auto test = RefCounted!Itest(new testclass()); } If you change the refcounted to type testclass it doesn't compile because r

Re: To write such an expressive code D

2015-02-09 Thread Ali Çehreli via Digitalmars-d-learn
On 02/09/2015 08:17 PM, Dennis Ritchie wrote: > Ali, and you can write it without using the function "iota()" and map? No because the a..b syntax is not a D language construct that we can use anywhere that it makes sense. It only works as number ranges inside foreach loops, when indexing slice

Re: Intended to be able to RefCount an interface?

2015-02-09 Thread weaselcat via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 05:09:00 UTC, Jakob Ovrum wrote: On Tuesday, 10 February 2015 at 04:44:55 UTC, weaselcat wrote: Thread title. interface Itest{ } class testclass : Itest{ } void main() { import std.typecons; auto test = RefCounted!Itest(new testclass()); } If you chang

Re: To write such an expressive code D

2015-02-09 Thread Dennis Ritchie via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 06:17:17 UTC, Ali Çehreli wrote: On 02/09/2015 08:17 PM, Dennis Ritchie wrote: > Ali, and you can write it without using the function "iota()" and map? No because the a..b syntax is not a D language construct that we can use anywhere that it makes sense. It only