Re: Intended behavior or bug (private vs public static)

2014-11-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 07, 2014 05:43:28 Andre via Digitalmars-d-learn wrote: > Hi, > > following code fails with errors: > class test.A member b is not accessible > > I am not sure, whether it should work or not? > > Kind regards > André > > module app; > import test; > > void main() > { > A.b("");

Intended behavior or bug (private vs public static)

2014-11-06 Thread Andre via Digitalmars-d-learn
Hi, following code fails with errors: class test.A member b is not accessible I am not sure, whether it should work or not? Kind regards André module app; import test; void main() { A.b(""); } module test; class A { private void b(){} static void b(string b){} }

Re: Access Violation Tracking

2014-11-06 Thread ketmar via Digitalmars-d-learn
On Thu, 06 Nov 2014 22:45:23 -0500 Steven Schveighoffer via Digitalmars-d-learn wrote: > In an environment that you don't control, the default behavior is likely > to print "Segmentation Fault" and exit. No core dump, no nothing. > > This leads to unhelpful bug reports, and seeing if you can ge

Re: Access Violation Tracking

2014-11-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/6/14 10:22 PM, ketmar via Digitalmars-d-learn wrote: On Thu, 06 Nov 2014 20:13:02 + "Nordlöw" via Digitalmars-d-learn wrote: On Wednesday, 5 November 2014 at 11:39:21 UTC, Marc Schütz wrote: If you're on Linux, you can turn SEGVs into Errors: import etc.linux.memoryerror;

Re: Access Violation Tracking

2014-11-06 Thread ketmar via Digitalmars-d-learn
On Thu, 06 Nov 2014 20:13:02 + "Nordlöw" via Digitalmars-d-learn wrote: > On Wednesday, 5 November 2014 at 11:39:21 UTC, Marc Schütz wrote: > > If you're on Linux, you can turn SEGVs into Errors: > > > > import etc.linux.memoryerror; > > registerMemoryErrorHandler(); > > Why isn't su

Audio file read/write?

2014-11-06 Thread Daren Scot Wilson via Digitalmars-d-learn
What's the current recommended way to read and write audio files? I don't need to play it on the speakers or deal with anything real time - just read a file's data into an array, fiddle with it, and write it out to a file. I found some other threads about audio files, but none recent, mentio

Re: How to tell how an object/class is declared

2014-11-06 Thread Meta via Digitalmars-d-learn
One other thing. I know about `template this`, but I'm not sure if that's a tenable solution or not in my case. In addition to templating the struct or class, would I not also have to template the constructor so it could pick up the type of `this` at the declaration site?

Re: How to tell how an object/class is declared

2014-11-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 6 November 2014 at 23:43:19 UTC, Meta wrote: How can I tell at the points marked in the above code if the class or struct instance was declared as const, shared, etc.? Is this possible? You can't do that, but you can overload on const void doSomething() const { called on const in

How to tell how an object/class is declared

2014-11-06 Thread Meta via Digitalmars-d-learn
Say I have the following struct and object definitions: struct Test1(T) { static if (???) { void doSomething() { writeln(typeof(this).stringof); } } T t; } class Test2(T) { static if (???) { void doSomething() {

Re: transversal sum

2014-11-06 Thread John Colvin via Digitalmars-d-learn
On Thursday, 6 November 2014 at 15:53:27 UTC, Jack Applegame wrote: I have rectangular forward range of forward ranges (not arrays): [ [a11, a12, ... a1N], [a21, a22, ... a2N], ... [aM1, aM2, ... aMN] ] I need lazy forward range: [ a11 + a21 + ... aM1, a12 + a22 + ... aM2, ... a1N +

Re: transversal sum

2014-11-06 Thread John Colvin via Digitalmars-d-learn
On Thursday, 6 November 2014 at 22:02:09 UTC, John Colvin wrote: On Thursday, 6 November 2014 at 15:53:27 UTC, Jack Applegame wrote: I have rectangular forward range of forward ranges (not arrays): [ [a11, a12, ... a1N], [a21, a22, ... a2N], ... [aM1, aM2, ... aMN] ] I need lazy forward ra

Re: transversal sum

2014-11-06 Thread John Colvin via Digitalmars-d-learn
On Thursday, 6 November 2014 at 15:53:27 UTC, Jack Applegame wrote: I have rectangular forward range of forward ranges (not arrays): [ [a11, a12, ... a1N], [a21, a22, ... a2N], ... [aM1, aM2, ... aMN] ] I need lazy forward range: [ a11 + a21 + ... aM1, a12 + a22 + ... aM2, ... a1N +

Re: Why does this declaration exist inside std.range.put?

2014-11-06 Thread Meta via Digitalmars-d-learn
On Thursday, 6 November 2014 at 21:57:36 UTC, Steven Schveighoffer wrote: github blame is quite useful: https://github.com/D-Programming-Language/phobos/blame/master/std/range.d#L668 The commit: https://github.com/D-Programming-Language/phobos/commit/c717b503e7305a92410c23ca2bc2ea14b40f8aa2

Re: transversal sum

2014-11-06 Thread John Colvin via Digitalmars-d-learn
On Thursday, 6 November 2014 at 15:53:27 UTC, Jack Applegame wrote: I have rectangular forward range of forward ranges (not arrays): [ [a11, a12, ... a1N], [a21, a22, ... a2N], ... [aM1, aM2, ... aMN] ] I need lazy forward range: [ a11 + a21 + ... aM1, a12 + a22 + ... aM2, ... a1N +

Re: Why does this declaration exist inside std.range.put?

2014-11-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/6/14 4:19 PM, Meta wrote: This is the code for std.range.put: void put(R, E)(ref R r, E e) { //Why? @property ref E[] EArrayInit(); //@@@9186@@@: Can't use (E[]).init //First level: simply straight up put. static if (is(typeof(doPut(r, e { doPut(r, e)

Re: transversal sum

2014-11-06 Thread Jack Applegame via Digitalmars-d-learn
void popFront() { foreach (ref r; rr) r.popFront(); } I think it should be void popFront() { foreach (ref r; rr.save) r.popFront(); } but I think OP wanted a ready-made phobos solution, w/o all the range boilerplate... exactly.

Why does this declaration exist inside std.range.put?

2014-11-06 Thread Meta via Digitalmars-d-learn
This is the code for std.range.put: void put(R, E)(ref R r, E e) { //Why? @property ref E[] EArrayInit(); //@@@9186@@@: Can't use (E[]).init //First level: simply straight up put. static if (is(typeof(doPut(r, e { doPut(r, e); } //Optional optimization b

Re: transversal sum

2014-11-06 Thread Artur Skawina via Digitalmars-d-learn
On 11/06/14 18:32, bearophile via Digitalmars-d-learn wrote: > Marc Schütz: > >> We'd need something taking and returning a RoR that "mirrors" them >> diagonally. Then we could simply apply `map!(r => r.sum)` on the result. > > A simple solution is to create a row of values, and then sum them co

Re: Access Violation Tracking

2014-11-06 Thread Andrej Mitrovic via Digitalmars-d-learn
On Nov 5, 2014 12:10 PM, "Bauss via Digitalmars-d-learn" < digitalmars-d-learn@puremagic.com> wrote: > > Is there any way to track down access violations, instead of me having to look through my source code manually. Whenever you don't get a stack trace on Windows, it's 99% guaranteed you're calli

Re: Access Violation Tracking

2014-11-06 Thread Nordlöw
On Wednesday, 5 November 2014 at 11:39:21 UTC, Marc Schütz wrote: If you're on Linux, you can turn SEGVs into Errors: import etc.linux.memoryerror; registerMemoryErrorHandler(); Why isn't such a useful feature activated by default? Performance reasons?

Re: scope exception do not rise

2014-11-06 Thread Ali Çehreli via Digitalmars-d-learn
On 11/06/2014 08:47 AM, Suliman wrote: We have to look at the documentation of the function. In this case the possibilities are FileException and UTFException. http://dlang.org/phobos/std_file.html#.readText However, judging by their names, they are both descendants of Exception, so what you

Re: transversal sum

2014-11-06 Thread bearophile via Digitalmars-d-learn
Marc Schütz: We'd need something taking and returning a RoR that "mirrors" them diagonally. Then we could simply apply `map!(r => r.sum)` on the result. A simple solution is to create a row of values, and then sum them correctly while you scan the rows. Bye, bearophile

Re: transversal sum

2014-11-06 Thread via Digitalmars-d-learn
On Thursday, 6 November 2014 at 17:08:23 UTC, Justin Whear wrote: This would sum along the wrong dimension. I think the correct solution will make use of std.range.frontTraversal, but it will be a bit more complex due to needing to sum every column. std.range.traversal would make it easy, b

Re: transversal sum

2014-11-06 Thread via Digitalmars-d-learn
On Thursday, 6 November 2014 at 16:57:50 UTC, Marc Schütz wrote: On Thursday, 6 November 2014 at 15:53:27 UTC, Jack Applegame wrote: I have rectangular forward range of forward ranges (not arrays): [ [a11, a12, ... a1N], [a21, a22, ... a2N], ... [aM1, aM2, ... aMN] ] I need lazy forward ra

Re: transversal sum

2014-11-06 Thread Justin Whear via Digitalmars-d-learn
On Thu, 06 Nov 2014 17:08:23 +, Justin Whear wrote: > I think the correct solution > will make use of std.range.frontTraversal, but it will be a bit more > complex due to needing to sum every column. std.range.traversal would > make it easy, but it requires random access. That should be std.

Re: transversal sum

2014-11-06 Thread Justin Whear via Digitalmars-d-learn
On Thu, 06 Nov 2014 16:57:48 +, Marc Schütz wrote: > On Thursday, 6 November 2014 at 15:53:27 UTC, Jack Applegame wrote: >> I have rectangular forward range of forward ranges (not arrays): >> [ >> [a11, a12, ... a1N], >> [a21, a22, ... a2N], >> ... >> [aM1, aM2, ... aMN] >> ] >> >> I n

Re: transversal sum

2014-11-06 Thread via Digitalmars-d-learn
On Thursday, 6 November 2014 at 15:53:27 UTC, Jack Applegame wrote: I have rectangular forward range of forward ranges (not arrays): [ [a11, a12, ... a1N], [a21, a22, ... a2N], ... [aM1, aM2, ... aMN] ] I need lazy forward range: [ a11 + a21 + ... aM1, a12 + a22 + ... aM2, ... a1N +

Re: scope exception do not rise

2014-11-06 Thread Suliman via Digitalmars-d-learn
We have to look at the documentation of the function. In this case the possibilities are FileException and UTFException. http://dlang.org/phobos/std_file.html#.readText However, judging by their names, they are both descendants of Exception, so what you are doing will catch either of them.

transversal sum

2014-11-06 Thread Jack Applegame via Digitalmars-d-learn
I have rectangular forward range of forward ranges (not arrays): [ [a11, a12, ... a1N], [a21, a22, ... a2N], ... [aM1, aM2, ... aMN] ] I need lazy forward range: [ a11 + a21 + ... aM1, a12 + a22 + ... aM2, ... a1N + a2N + ... aMN ] Range of sum elements of every columns; M, N - runti

Re: scope exception do not rise

2014-11-06 Thread Ali Çehreli via Digitalmars-d-learn
On 11/05/2014 11:02 PM, Suliman wrote: Replace that with something like writeln("caught") and you will see that it is indeed caught. :) Printing the exception mimicks the default behavior and you (and I) think that the exception is not caught. :) that's work, but I can not understand where I ca

Re: cannot sort an array of char

2014-11-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/5/14 7:54 AM, Ivan Kazmenko wrote: Hi! This gives an error (cannot deduce template function from argument types): - import std.algorithm; void main () { char [] c; sort (c); } - Why is "char []" so special that it can't be sorted? Because sort works on ranges, and std

Re: How to turn this C++ into D?

2014-11-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/5/14 2:05 PM, Patrick Jeeves wrote: On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone wrote: unless delete is explicitly called, I don't believe the destructor would ever be called, it would still have a reference in the static foo_list object that would stop it from being collect

Re: Complexity guaranties of array append operator

2014-11-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/5/14 10:48 PM, Dmitriy wrote: Hello, I'm in the middle of learning D. I can't find any definitive information about what is the complexity of operator ~= when used for adding an element to an array. Is it amortized O(1) or is it implementation defined? (I hope it at worst O(n) though I have

Re: cannot sort an array of char

2014-11-06 Thread via Digitalmars-d-learn
On Thursday, 6 November 2014 at 10:52:32 UTC, Ivan Kazmenko wrote: On Wednesday, 5 November 2014 at 13:34:05 UTC, Marc Schütz wrote: On Wednesday, 5 November 2014 at 12:54:03 UTC, Ivan Kazmenko wrote: Hi! This gives an error (cannot deduce template function from argument types): - impor

Re: Network scanner

2014-11-06 Thread RuZzz via Digitalmars-d-learn
Or the program doesn't find the address after IP 192.168.110.34...

Network scanner

2014-11-06 Thread RuZzz via Digitalmars-d-learn
Hi ppl! I want to scan the local network to find nodes with open 80 port. code: import core.thread, core.atomic; import std.stdio, std.system, std.file, std.conv, std.datetime, std.socket, std.socketstream, std.stream; import vibe.core.log; import vibe.d; void main() { ushort port = 80

Re: Share array element between threads

2014-11-06 Thread Misu via Digitalmars-d-learn
On Thursday, 6 November 2014 at 13:04:18 UTC, Marc Schütz wrote: It's a bug: https://issues.dlang.org/show_bug.cgi?id=2043 As a workaround, you can nest the call in another lambda: foreach(acc; accounts) { (Account acc) { task(() { writeln(acc.id); }).executeInNewThr

Re: Share array element between threads

2014-11-06 Thread via Digitalmars-d-learn
On Thursday, 6 November 2014 at 10:53:32 UTC, Misu wrote: Hi, when I execute this code I have 7 7 7 as result, I think I understand why. How can I execute a special task for one element ? import std.stdio; import std.parallelism; void main(string[] args) { class Account {

Re: Pragma mangle and D shared objects

2014-11-06 Thread Etienne Cimon via Digitalmars-d-learn
On 2014-10-26 14:25, Etienne Cimon wrote: On 2014-10-25 23:31, H. S. Teoh via Digitalmars-d-learn wrote: Hmm. You can probably use __traits(getAllMembers...) to introspect a library module at compile-time and build a hash based on that, so that it's completely automated. If you have this availab

Re: Share array element between threads

2014-11-06 Thread bearophile via Digitalmars-d-learn
Misu: void main(string[] args) { class Account { public this(int id) { this.id = id; } int id; } ... This is not an answer to your question, but note: void main() { class Foo {} static class Bar {} pragma(msg, __traits(classI

Re: How to turn this C++ into D?

2014-11-06 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 17:45:00 UTC, luminousone wrote: abstract class foo { static DList!foo foo_list; ~this(){ foo_list.remove(this); } One note: when your program exits the runtime does a final GC cycle and collects those things calling destructors/finalizers, however the

Re: cannot sort an array of char

2014-11-06 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 13:34:05 UTC, Marc Schütz wrote: On Wednesday, 5 November 2014 at 12:54:03 UTC, Ivan Kazmenko wrote: Hi! This gives an error (cannot deduce template function from argument types): - import std.algorithm; void main () { char [] c; sort (c);

Share array element between threads

2014-11-06 Thread Misu via Digitalmars-d-learn
Hi, when I execute this code I have 7 7 7 as result, I think I understand why. How can I execute a special task for one element ? import std.stdio; import std.parallelism; void main(string[] args) { class Account { public this(int id) { this.id = id; }