Re: Struct Inheritence

2016-02-19 Thread user001 via Digitalmars-d-learn
Yes that's exactly what i needed, thanks!

Re: Get memory usage report from GC

2016-02-19 Thread tcak via Digitalmars-d-learn
On Saturday, 20 February 2016 at 05:55:26 UTC, Jon D wrote: On Saturday, 20 February 2016 at 05:34:01 UTC, tcak wrote: On Saturday, 20 February 2016 at 05:33:00 UTC, tcak wrote: Is there any way (I checked core.memory already) to collect report about memory usage from garbage collector? So, I c

Re: Get memory usage report from GC

2016-02-19 Thread Jon D via Digitalmars-d-learn
On Saturday, 20 February 2016 at 05:34:01 UTC, tcak wrote: On Saturday, 20 February 2016 at 05:33:00 UTC, tcak wrote: Is there any way (I checked core.memory already) to collect report about memory usage from garbage collector? So, I can see a list of pointer and length information. Since getti

Re: Get memory usage report from GC

2016-02-19 Thread tcak via Digitalmars-d-learn
On Saturday, 20 February 2016 at 05:33:00 UTC, tcak wrote: Is there any way (I checked core.memory already) to collect report about memory usage from garbage collector? So, I can see a list of pointer and length information. Since getting this information would require another memory area in he

Get memory usage report from GC

2016-02-19 Thread tcak via Digitalmars-d-learn
Is there any way (I checked core.memory already) to collect report about memory usage from garbage collector? So, I can see a list of pointer and length information. Since getting this information would require another memory area in heap, it could be like logging when report is asked. My lon

Status icon on Linux

2016-02-19 Thread Chris Wright via Digitalmars-d-learn
I want a status icon for a Linux application. gtk.StatusIcon notes that it's deprecated (and doesn't work on MATE 1.8.2). What should I be using?

Re: 111

2016-02-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/19/16 11:15 PM, Lisa wrote: module main; import std.stdio; import std.math; int main() { int A, B, C; writef("A = "); readf("%lf", %A); You want &A, not %A. Also, note that you declared A, B, C as integers, but are using %lf which is for doubles. However, readf is muc

Re: Parallel example from documentation does not compile

2016-02-19 Thread Russel Winder via Digitalmars-d-learn
Sadly the answer is no. This is due to https://issues.dlang.org/show_bug.cgi?id=5710 which apparently no-one is either willing or able to fix. The problem afflicts dmd, l;dc2 and I suspect gdc. cf. https://github.com/russel/Pi_Quadrature/tree/master/D for some extra detail and some workarounds.

Re: 111

2016-02-19 Thread Lisa via Digitalmars-d-learn
On Saturday, 20 February 2016 at 03:43:17 UTC, Ali Çehreli wrote: On 02/19/2016 07:37 PM, Lisa wrote: > import std.stdio; > import std.math; > > int main() > { > double a, b, c, p; > > writef("Enter a: "); > scanf("%d", &a); scanf is not a safe function. It trusts the format stri

Re: 111

2016-02-19 Thread Ali Çehreli via Digitalmars-d-learn
On 02/19/2016 07:37 PM, Lisa wrote: > import std.stdio; > import std.math; > > int main() > { > double a, b, c, p; > > writef("Enter a: "); > scanf("%d", &a); scanf is not a safe function. It trusts the format string and assumes that 'a' really is what the programmer told it. (Fo

Re: 111

2016-02-19 Thread Lisa via Digitalmars-d-learn
On Saturday, 20 February 2016 at 01:48:35 UTC, Ali Çehreli wrote: On 02/19/2016 03:56 PM, Lisa wrote: Can you please help me and explain how to create a program, which would find area of triangle and its perimeter? It's great to have student questions on this forum. If you don't mind telling

Why does partial ordering of overloaded functions not take return type into account?

2016-02-19 Thread Jeremy DeHaan via Digitalmars-d-learn
module main; struct ThingOne { int thing = 1; } struct ThingTwo { float thing = 2; } struct Test { ThingOne thing() { return ThingOne(); } ThingTwo thing() { return ThingTwo(); } } voi

Re: Installing DUB on OSX

2016-02-19 Thread Joel via Digitalmars-d-learn
On Thursday, 18 February 2016 at 08:18:20 UTC, Guillaume Piolat wrote: On Thursday, 18 February 2016 at 07:52:11 UTC, Joel wrote: On Thursday, 18 February 2016 at 07:11:23 UTC, Joel wrote: I had dub installed in a folder that meant I had to put 'sudo dub' to run it. I've tried to fix the proble

Re: Modify Function Pointer to Take Additional Parameters

2016-02-19 Thread jmh530 via Digitalmars-d-learn
On Friday, 19 February 2016 at 22:34:48 UTC, Chris Wright wrote: I tested this a fair bit today, and I haven't been able to do any of the nefarious things I expected to be able to do. No overwriting variables in the caller's scope, no smashing stack pointers, etc. I was surprised by this re

Re: 111

2016-02-19 Thread Lisa via Digitalmars-d-learn
On Friday, 19 February 2016 at 23:56:29 UTC, Lisa wrote: Can you please help me and explain how to create a program, which would find area of triangle and its perimeter? And for everybody - I know how to find area and perimetr, but i don't know how to write it on programming language) Can i u

Re: 111

2016-02-19 Thread Lisa via Digitalmars-d-learn
On Saturday, 20 February 2016 at 01:48:35 UTC, Ali Çehreli wrote: On 02/19/2016 03:56 PM, Lisa wrote: Can you please help me and explain how to create a program, which would find area of triangle and its perimeter? It's great to have student questions on this forum. If you don't mind telling

Re: Transposing a static array

2016-02-19 Thread Ali Çehreli via Digitalmars-d-learn
On 02/19/2016 06:26 PM, maik klein wrote: > On Saturday, 20 February 2016 at 02:22:12 UTC, Ali Çehreli wrote: >> On 02/19/2016 06:00 PM, maik klein wrote: >>> How would I transpose >>> >>> float[3][2] >>> >>> to >>> >>> float[2][3] >>> >>> with http://dlang.org/phobos/std_range.html#.transposed >

Re: Transposing a static array

2016-02-19 Thread cym13 via Digitalmars-d-learn
On Saturday, 20 February 2016 at 02:26:56 UTC, maik klein wrote: On Saturday, 20 February 2016 at 02:22:12 UTC, Ali Çehreli wrote: On 02/19/2016 06:00 PM, maik klein wrote: How would I transpose float[3][2] to float[2][3] with http://dlang.org/phobos/std_range.html#.transposed Because s

Re: Transposing a static array

2016-02-19 Thread maik klein via Digitalmars-d-learn
On Saturday, 20 February 2016 at 02:22:12 UTC, Ali Çehreli wrote: On 02/19/2016 06:00 PM, maik klein wrote: How would I transpose float[3][2] to float[2][3] with http://dlang.org/phobos/std_range.html#.transposed Because static arrays are not ranges, they must be used as slices with the

Re: Transposing a static array

2016-02-19 Thread Ali Çehreli via Digitalmars-d-learn
On 02/19/2016 06:00 PM, maik klein wrote: How would I transpose float[3][2] to float[2][3] with http://dlang.org/phobos/std_range.html#.transposed Because static arrays are not ranges, they must be used as slices with the help of []. The following code does the same thing in two differen

Re: Create a proxy

2016-02-19 Thread Ali Çehreli via Digitalmars-d-learn
On 02/19/2016 06:18 AM, Voitech wrote: > I was trying to use mixins for this i > created some functions but this not working don't know why Compilation errors or something else? pragma(msg) helps with debugging generated code. You can also use unittest blocks to make sure that the generated co

Transposing a static array

2016-02-19 Thread maik klein via Digitalmars-d-learn
How would I transpose float[3][2] to float[2][3] with http://dlang.org/phobos/std_range.html#.transposed

Re: 111

2016-02-19 Thread Ali Çehreli via Digitalmars-d-learn
On 02/19/2016 03:56 PM, Lisa wrote: Can you please help me and explain how to create a program, which would find area of triangle and its perimeter? It's great to have student questions on this forum. If you don't mind telling us, which teacher and school teaches or uses D? The only one that

Re: 111

2016-02-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 20 February 2016 at 00:42:36 UTC, Chris Wright wrote: How do you calculate the area of a triangle? Same way as you'd do it by hand -- 1/2 base times height. Getting the height can be tricky sometimes though, depending on what information you know about the triangle. I like to ch

Re: 111

2016-02-19 Thread Chris Wright via Digitalmars-d-learn
On Sat, 20 Feb 2016 00:17:28 +, Lisa wrote: > On Saturday, 20 February 2016 at 00:15:16 UTC, Chris Wright wrote: >> On Sat, 20 Feb 2016 00:04:04 +, Lisa wrote: >> >>> On Saturday, 20 February 2016 at 00:01:47 UTC, cym13 wrote: On Friday, 19 February 2016 at 23:56:29 UTC, Lisa wrote: >

Re: 111

2016-02-19 Thread cym13 via Digitalmars-d-learn
On Saturday, 20 February 2016 at 00:04:04 UTC, Lisa wrote: On Saturday, 20 February 2016 at 00:01:47 UTC, cym13 wrote: On Friday, 19 February 2016 at 23:56:29 UTC, Lisa wrote: Can you please help me and explain how to create a program, which would find area of triangle and its perimeter? What

Re: 111

2016-02-19 Thread Ivan Kazmenko via Digitalmars-d-learn
On Friday, 19 February 2016 at 23:56:29 UTC, Lisa wrote: Can you please help me and explain how to create a program, which would find area of triangle and its perimeter? First, one can't find these unless something is given. So, what is given: sides? angles? two-dimensional coordinates? The

Re: 111

2016-02-19 Thread Lisa via Digitalmars-d-learn
On Saturday, 20 February 2016 at 00:15:16 UTC, Chris Wright wrote: On Sat, 20 Feb 2016 00:04:04 +, Lisa wrote: On Saturday, 20 February 2016 at 00:01:47 UTC, cym13 wrote: On Friday, 19 February 2016 at 23:56:29 UTC, Lisa wrote: Can you please help me and explain how to create a program, w

Re: 111

2016-02-19 Thread Chris Wright via Digitalmars-d-learn
On Sat, 20 Feb 2016 00:04:04 +, Lisa wrote: > On Saturday, 20 February 2016 at 00:01:47 UTC, cym13 wrote: >> On Friday, 19 February 2016 at 23:56:29 UTC, Lisa wrote: >>> Can you please help me and explain how to create a program, >>> which would find area of triangle and its perimeter? >> >> W

Re: D Grammar Parser In D

2016-02-19 Thread cym13 via Digitalmars-d-learn
On Friday, 19 February 2016 at 23:09:11 UTC, Patience wrote: On Friday, 19 February 2016 at 22:34:22 UTC, Adam D. Ruppe wrote: On Friday, 19 February 2016 at 22:29:32 UTC, Patience wrote: Is there anything in D like https://irony.codeplex.com/ https://github.com/Hackerpilot/libdparse/ I do

Re: 111

2016-02-19 Thread Lisa via Digitalmars-d-learn
On Saturday, 20 February 2016 at 00:01:47 UTC, cym13 wrote: On Friday, 19 February 2016 at 23:56:29 UTC, Lisa wrote: Can you please help me and explain how to create a program, which would find area of triangle and its perimeter? What do you need help for exactly? What have you tried? What do

Re: 111

2016-02-19 Thread cym13 via Digitalmars-d-learn
On Friday, 19 February 2016 at 23:56:29 UTC, Lisa wrote: Can you please help me and explain how to create a program, which would find area of triangle and its perimeter? What do you need help for exactly? What have you tried? What do you struggle with?

111

2016-02-19 Thread Lisa via Digitalmars-d-learn
Can you please help me and explain how to create a program, which would find area of triangle and its perimeter?

Re: D Grammar Parser In D

2016-02-19 Thread Patience via Digitalmars-d-learn
On Friday, 19 February 2016 at 22:34:22 UTC, Adam D. Ruppe wrote: On Friday, 19 February 2016 at 22:29:32 UTC, Patience wrote: Is there anything in D like https://irony.codeplex.com/ https://github.com/Hackerpilot/libdparse/ I don't want to parse d code. I want a generic parser that is wri

Re: Installing DUB on OSX

2016-02-19 Thread Joel via Digitalmars-d-learn
On Friday, 19 February 2016 at 11:34:33 UTC, John Colvin wrote: On Thursday, 18 February 2016 at 23:28:43 UTC, Joel wrote: On Thursday, 18 February 2016 at 16:33:51 UTC, John Colvin wrote: [...] I don't think I put 'sudo brew' at any point (I can't remember). I hope I haven't broken my OSX!

Re: Modify Function Pointer to Take Additional Parameters

2016-02-19 Thread Chris Wright via Digitalmars-d-learn
On Fri, 19 Feb 2016 21:57:46 +, Yuxuan Shui wrote: > I don't think it's safe to convert between function pointer with > different number of arguments... It's possible to mess up the stack > frame. I tested this a fair bit today, and I haven't been able to do any of the nefarious things I exp

Re: D Grammar Parser In D

2016-02-19 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 19 February 2016 at 22:29:32 UTC, Patience wrote: Is there anything in D like https://irony.codeplex.com/ https://github.com/Hackerpilot/libdparse/

D Grammar Parser In D

2016-02-19 Thread Patience via Digitalmars-d-learn
Is there anything in D like https://irony.codeplex.com/

Re: Decoding Pattern to a Tuple

2016-02-19 Thread Ali Çehreli via Digitalmars-d-learn
On 02/19/2016 11:04 AM, Ali Çehreli wrote: > can be templatized: Not ready for prime time but now it's templatized: import std.stdio; import std.string; import std.regex; import std.typecons; import std.conv; import std.algorithm; import std.range; template regexClass(T) { static if (is (T

Re: Modify Function Pointer to Take Additional Parameters

2016-02-19 Thread jmh530 via Digitalmars-d-learn
On Friday, 19 February 2016 at 22:07:25 UTC, Chris Wright wrote: If you want to cast function pointers successfully, you have to know the D calling convention. [snip] I figured there was an explanation. Definitely "here be dragons" territory. I hope I can figure out a better solution, but

Re: Struct Inheritence

2016-02-19 Thread Yuxuan Shui via Digitalmars-d-learn
On Friday, 19 February 2016 at 21:58:24 UTC, user001 wrote: Well struct don't have it, but i would like something like it but only for data, i don't need functions or anything like that just data. [...] How about struct A { int valueA; } struct B { A a; int valueB; alias a

Re: Struct Inheritence

2016-02-19 Thread cym13 via Digitalmars-d-learn
On Friday, 19 February 2016 at 21:58:24 UTC, user001 wrote: Well struct don't have it, but i would like something like it but only for data, i don't need functions or anything like that just data. struct A { int valueA; } struct B { A a; int valueB

Re: Modify Function Pointer to Take Additional Parameters

2016-02-19 Thread Chris Wright via Digitalmars-d-learn
On Fri, 19 Feb 2016 20:45:23 +, jmh530 wrote: > I tried to use a cast (below) to modify the function pointer, but it is > printing the second number instead of the first. I find this behavior > strange... If you want to cast function pointers successfully, you have to know the D calling conv

Struct Inheritence

2016-02-19 Thread user001 via Digitalmars-d-learn
Well struct don't have it, but i would like something like it but only for data, i don't need functions or anything like that just data. struct A { int valueA; } struct B { A a; int valueB; } struct C { B b; int valueC;

Re: Modify Function Pointer to Take Additional Parameters

2016-02-19 Thread Yuxuan Shui via Digitalmars-d-learn
On Friday, 19 February 2016 at 20:45:23 UTC, jmh530 wrote: On Friday, 19 February 2016 at 15:00:51 UTC, jmh530 wrote: This works. But when I re-write foo to take that into account as in below, I get an error that I can't implicitly convert int function(int x) to int function(int x, int y).

Parallel example fron documentation does not compile

2016-02-19 Thread Ish via Digitalmars-d-learn
This code snippet is from: http://dlang.org/phobos/std_parallelism.html --- import std.algorithm, std.parallelism, std.range; void main() { // Parallel reduce can be combined with // std.algorithm.map to interesting effect. // The following example (thanks to Russel Winder) // ca

Re: Modify Function Pointer to Take Additional Parameters

2016-02-19 Thread jmh530 via Digitalmars-d-learn
On Friday, 19 February 2016 at 15:00:51 UTC, jmh530 wrote: This works. But when I re-write foo to take that into account as in below, I get an error that I can't implicitly convert int function(int x) to int function(int x, int y). I don't think I had looked at what you had done carefully

Re: Decoding Pattern to a Tuple

2016-02-19 Thread Ali Çehreli via Digitalmars-d-learn
On 02/19/2016 10:10 AM, Nordlöw wrote: Have anybody put together a generalised form of findSplit that can split and decode using a compile time parameters somewhat like "(1)-(2.0)".decode!("(", int, ")", char, "(", double, ")") evaluates to to a tuple!(int, char, double) with value tuple(1,

Decoding Pattern to a Tuple

2016-02-19 Thread Nordlöw via Digitalmars-d-learn
Have anybody put together a generalised form of findSplit that can split and decode using a compile time parameters somewhat like "(1)-(2.0)".decode!("(", int, ")", char, "(", double, ")") evaluates to to a tuple!(int, char, double) with value tuple(1, '-', 2.0)

Re: Modify Function Pointer to Take Additional Parameters

2016-02-19 Thread jmh530 via Digitalmars-d-learn
On Friday, 19 February 2016 at 14:21:26 UTC, Kagamin wrote: int bar(int x) { return x; } int baz(int x, int y) { return bar(x); } void main() { import std.stdio : writeln; int function(int x, int y) foo_bar = &baz; writeln(foo_bar(1, 2)); } T

Re: Modify Function Pointer to Take Additional Parameters

2016-02-19 Thread jmh530 via Digitalmars-d-learn
On Friday, 19 February 2016 at 11:26:56 UTC, Nicholas Wilson wrote: Like alias fp1 = int function(int x); alias fp2 = int function(int x, int y); auto foo(T)(T f) { static if (is(T == fp2)) return f; else static if (is(T == fp1)) { return

Re: multi-dimensional dynamic arrays

2016-02-19 Thread Jay Norwood via Digitalmars-d-learn
On Friday, 19 February 2016 at 14:26:25 UTC, Steven Schveighoffer wrote: Try ub[0].length = 3. You are trying to change the length on one of the static arrays. yes, right these compile. I was surpised it wouldn't accept the append with just an int. int[1][][1] ubb; ubb[0].

Re: multi-dimensional dynamic arrays

2016-02-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/19/16 8:53 AM, Jay Norwood wrote: On Friday, 19 February 2016 at 07:59:29 UTC, Jonathan M Davis wrote: .. Or you could do something really wonky like auto arr = new int[][2][](5); which would be a dynamic array of length 5 which holds static arrays of length 2 which hold dynamic array

Re: Modify Function Pointer to Take Additional Parameters

2016-02-19 Thread Kagamin via Digitalmars-d-learn
On Friday, 19 February 2016 at 05:41:01 UTC, jmh530 wrote: void main() { import std.stdio : writeln; auto foo_bar = foo(&bar); writeln(qux(1, 2, foo_bar)); //compiler error writeln(qux(1, 2, &baz)); } int bar(int x) { return x; } int baz(int x,

Re: Duration at runtime

2016-02-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/18/16 11:36 PM, Zekereth wrote: On Friday, 19 February 2016 at 04:21:43 UTC, Zekereth wrote: On Friday, 19 February 2016 at 04:16:23 UTC, Adam D. Ruppe wrote: On Friday, 19 February 2016 at 04:08:02 UTC, Zekereth wrote: How is seconds able to be read at compile time but unitType cannot?

Create a proxy

2016-02-19 Thread Voitech via Digitalmars-d-learn
Hi, I'm trying to create a proxy with automatic method generation . Let say i hava Service object which can be Local service and Remote service. f.e: interface Service{ string serviceInfo(); } interface LocalService:Service{ int doSmth(string param); } class LocalServiceImpl:LocalServic

Re: Arrays of noncopyables/Invalid memory operation

2016-02-19 Thread Matt Elkins via Digitalmars-d-learn
On Thursday, 18 February 2016 at 01:14:00 UTC, ZombineDev wrote: https://issues.dlang.org/show_bug.cgi?id=15661. I suggest testing this code again with a newer compiler (see my answer in the other thread - http://forum.dlang.org/post/omfyqfulgyzbrxlzr...@forum.dlang.org). Thanks -- I might ge

Re: Arrays of noncopyables/Invalid memory operation

2016-02-19 Thread Matt Elkins via Digitalmars-d-learn
On Friday, 19 February 2016 at 01:30:13 UTC, H. S. Teoh wrote: Suppose the array gets moved sometime after i=500 because it ran out of space in the current memory location. Since there is another slice middleSlice pointing at the old data, it's not just a matter of *moving* the elements over t

Re: Example of code with manual memory management

2016-02-19 Thread Kagamin via Digitalmars-d-learn
https://dlang.org/phobos/std_container.html and corresponding code in phobos. Though recently allocators were introduced and containers are going to be written with support for allocators.

Re: multi-dimensional dynamic arrays

2016-02-19 Thread Jay Norwood via Digitalmars-d-learn
On Friday, 19 February 2016 at 07:59:29 UTC, Jonathan M Davis wrote: .. Or you could do something really wonky like auto arr = new int[][2][](5); which would be a dynamic array of length 5 which holds static arrays of length 2 which hold dynamic arrays which are null. In my case, int [1]

Example of code with manual memory management

2016-02-19 Thread Dibyendu Majumdar via Digitalmars-d-learn
Hi, I am looking for example of types where memory management is manual, and the type supports operator overloading, etc. Grateful if someone could point me to sample example code. Thanks and Regards Dibyendu

Re: Installing DUB on OSX

2016-02-19 Thread John Colvin via Digitalmars-d-learn
On Thursday, 18 February 2016 at 23:28:43 UTC, Joel wrote: On Thursday, 18 February 2016 at 16:33:51 UTC, John Colvin wrote: [...] I don't think I put 'sudo brew' at any point (I can't remember). I hope I haven't broken my OSX! [...] Did you recently upgrade OS X? Anyway, you should proba

Re: Modify Function Pointer to Take Additional Parameters

2016-02-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 19 February 2016 at 05:41:01 UTC, jmh530 wrote: I'm trying to write a function that will adjust the parameters of a function pointer. I think the problem is that it defaults to a delegate not that it cannot be one does clarifying this to the compiler work Like alias fp1 = int f

Re: multi-dimensional dynamic arrays

2016-02-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, February 19, 2016 06:54:51 Jay Norwood via Digitalmars-d-learn wrote: > Strange to me that this compiles, since I would expect there to > be some C-like limitation on the position of the unspecified > dimension. Is allowing this somehow useful? > > int[1][][1] ub; > writeln("ub",ub); Y