Re: How to copy object of class A to another object of class B?

2015-01-28 Thread zhmt via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 14:59:52 UTC, Ali Çehreli wrote: name must be 'enum': On 01/28/2015 06:34 AM, zhmt wrote: void getT(SRC,DEST)(SRC src,DEST dest) { foreach (i, type; typeof(SRC.tupleof)) { string name = SRC.tupleof[i].stringof; enum name = SRC.tupleof[i].st

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread zhmt via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 23:34:10 UTC, Chris Williams wrote: On Wednesday, 28 January 2015 at 09:44:29 UTC, zhmt wrote: Sometime , I need to copy them: thrift.Card tc; db.Card dc; dc.id = tc.id; dc.pwd = tc.pwd; ... It is boring coding, I want a solution to copy them automatica

Re: Import paths do not work

2015-01-28 Thread Rikki Cattermole via Digitalmars-d-learn
On 29/01/2015 8:08 p.m., tcak wrote: I have a library that has many folders and D files in them. I do not want to list name of all module files one by one while compiling projects. So, I thought I could use "-I" flag while compiling. It says: -Ipath where to look for imports So, I made a t

Import paths do not work

2015-01-28 Thread tcak via Digitalmars-d-learn
I have a library that has many folders and D files in them. I do not want to list name of all module files one by one while compiling projects. So, I thought I could use "-I" flag while compiling. It says: -Ipath where to look for imports So, I made a test as follows: ./test.d =

Re: What is @return?

2015-01-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 29, 2015 05:02:58 ketmar via Digitalmars-d-learn wrote: > http://wiki.dlang.org/DIP25 > this is a very recent thing, it wasn't coded when 2.066 was released. I don't know if it's even fully coded up in git master, though clearly it's at least partially there, because @ was put

Re: What is @return?

2015-01-28 Thread ketmar via Digitalmars-d-learn
On Thu, 29 Jan 2015 04:54:38 +, Jesse Phillips wrote: > A recent discussion over in digitalmars.D > http://forum.dlang.org/post/rtwbtxigfeupvykpb...@forum.dlang.org > > talks about accepting @return... Here is an example from the PR: > https://github.com/D-Programming-Language/dmd/ compare/36

What is @return?

2015-01-28 Thread Jesse Phillips via Digitalmars-d-learn
A recent discussion over in digitalmars.D http://forum.dlang.org/post/rtwbtxigfeupvykpb...@forum.dlang.org talks about accepting @return... Here is an example from the PR: https://github.com/D-Programming-Language/dmd/compare/366422338ece...6b86b12f79e8 struct At { @property auto info() @safe @

Re: shared Variant[string]

2015-01-28 Thread Meta via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 12:46:20 UTC, Fyodor Ustinov wrote: On Wednesday, 28 January 2015 at 12:32:29 UTC, Tobias Pankrath wrote: In your case above, it's std.variant : Variant, which does not work when shared. I look into variant.d and after seeing so many lines "@@@ BUG" - strange

Re: Using dub

2015-01-28 Thread Joel via Digitalmars-d-learn
[0] http://brew.sh/ Do I just put 'brew dub'? First install brew then $ brew install dub From that it should just be dub to run. Don't forget to restart terminal afterwards or just rerun bash. If dub isn't found, PATH variable will need to be changed via .bashrc. But I'm doubting its needed

Re: Using dub

2015-01-28 Thread Rikki Cattermole via Digitalmars-d-learn
On 29/01/2015 1:24 p.m., Joel wrote: On Wednesday, 28 January 2015 at 23:48:52 UTC, Rikki Cattermole wrote: On 29/01/2015 11:27 a.m., Joel wrote: When I setup dub/dmd on my OSX install, I used the OSX packages and it should already be on the PATH variable. What packages? I'm new to Mac OS.

Re: Using dub

2015-01-28 Thread Joel via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 23:48:52 UTC, Rikki Cattermole wrote: On 29/01/2015 11:27 a.m., Joel wrote: When I setup dub/dmd on my OSX install, I used the OSX packages and it should already be on the PATH variable. What packages? I'm new to Mac OS. Ohh, I was meaning a dmg. But ugh lo

Re: Print to Win Printer

2015-01-28 Thread Paul via Digitalmars-d-learn
Thanks Vladimir.

Re: Using dub

2015-01-28 Thread Rikki Cattermole via Digitalmars-d-learn
On 29/01/2015 11:27 a.m., Joel wrote: When I setup dub/dmd on my OSX install, I used the OSX packages and it should already be on the PATH variable. What packages? I'm new to Mac OS. Ohh, I was meaning a dmg. But ugh looks like I lied, my bad, only had to do it once. Looks like I used brew[0]

Re: Using std.net.curl to stream data

2015-01-28 Thread Chris Williams via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 14:18:38 UTC, Trollgeir wrote: I'm having some trouble trying to stream data to my plot.ly graph: https://plot.ly/62/~Trollgeir/ The API: https://plot.ly/streaming/ I am able to post messages that get recorded into the stream live, although right after curl u

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread Chris Williams via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 09:44:29 UTC, zhmt wrote: Sometime , I need to copy them: thrift.Card tc; db.Card dc; dc.id = tc.id; dc.pwd = tc.pwd; ... It is boring coding, I want a solution to copy them automatically: void copyObj(SRC,DEST)(SRC src,DEST dest) { foreach (i,

Re: how convert the range to slice ?

2015-01-28 Thread Nordlöw
On Wednesday, 28 January 2015 at 23:15:32 UTC, bearophile wrote: I think you can try to open a diagnostic enhancement request. Nice, that's what I'd hoped for you'd say :) I'll dig into it later on...

Re: how convert the range to slice ?

2015-01-28 Thread Nordlöw
On Wednesday, 28 January 2015 at 22:43:36 UTC, bearophile wrote: It's such a fundamental part of D+Phobos that newbies are forced to learn this quickly. On the other hand an informative error message could be useful... What error message do you suggest? Something like: ..., expression o

Re: how convert the range to slice ?

2015-01-28 Thread bearophile via Digitalmars-d-learn
Chris Williams: Range is not castable to array. See std.array.array to generate an array from a Range. Currently this program: void main() { import std.range; int[] a = iota(10); } Gives an error like: test.d(3,19): Error: cannot implicitly convert expression (iota(10)) of type R

Re: how convert the range to slice ?

2015-01-28 Thread Chris Williams via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 22:43:36 UTC, bearophile wrote: Nordlöw: Is there any chance we could add logic to dmd+phobos that hints user about this? It's such a fundamental part of D+Phobos that newbies are forced to learn this quickly. On the other hand an informative error message c

Re: how convert the range to slice ?

2015-01-28 Thread bearophile via Digitalmars-d-learn
Nordlöw: Is there any chance we could add logic to dmd+phobos that hints user about this? It's such a fundamental part of D+Phobos that newbies are forced to learn this quickly. On the other hand an informative error message could be useful... What error message do you suggest? Bye, bearo

Re: Cached Incremental Updates of DUB Builds

2015-01-28 Thread Nordlöw
On Wednesday, 28 January 2015 at 01:39:21 UTC, Nordlöw wrote: Ping. Why no answers? Should i post this as a DUB issue on github instead? I made it an issue here: https://github.com/D-Programming-Language/dub/issues/498

Re: Using dub

2015-01-28 Thread Joel via Digitalmars-d-learn
When I setup dub/dmd on my OSX install, I used the OSX packages and it should already be on the PATH variable. What packages? I'm new to Mac OS.

Re: how convert the range to slice ?

2015-01-28 Thread Nordlöw
On Wednesday, 28 January 2015 at 14:54:27 UTC, data man wrote: auto arr1 = [1,2,3].map!"a*2".array; auto arr2 = [1,2,3].filter!"a<3".array; Is there any chance we could add logic to dmd+phobos that hints user about this?

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread zhmt via Digitalmars-d-learn
Thx very much for all the help, I will try.

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread Ali Çehreli via Digitalmars-d-learn
name must be 'enum': On 01/28/2015 06:34 AM, zhmt wrote: void getT(SRC,DEST)(SRC src,DEST dest) { foreach (i, type; typeof(SRC.tupleof)) { string name = SRC.tupleof[i].stringof; enum name = SRC.tupleof[i].stringof; __traits(getMember, dest, name) = __traits(ge

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread aldanor via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 11:30:13 UTC, Marc Schütz wrote: On Wednesday, 28 January 2015 at 09:44:29 UTC, zhmt wrote: It is boring coding, I want a solution to copy them automatically: void copyObj(SRC,DEST)(SRC src,DEST dest) { foreach (i, type; typeof(SRC.tupleof)) {

Re: how convert the range to slice ?

2015-01-28 Thread data man via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 14:32:38 UTC, mzf wrote: is there any simple way to convert? int [] arr1 = [1,2,3].map!"a*2"; //compile error int [] arr2 = [1,2,3].filter!"a<3";//compile error auto arr1 = [1,2,3].map!"a*2".array; auto arr2 = [1,2,3].filter!"a<3".array;

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread Baz via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 14:35:58 UTC, zhmt wrote: Anybody help? __Traits functions are evaluated at compile time so it's not as simple. The best you can do is to generate a string to mixin based on the aggragate members. here i have an example of how you can iterate through the memb

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread zhmt via Digitalmars-d-learn
The final version works well: void copyObj(SRC,DEST)(ref SRC src,ref DEST dest) { foreach (i, type; typeof(SRC.tupleof)) { __traits(getMember, dest, SRC.tupleof[i].stringof) = __traits(getMember, src, SRC.tupleof[i].stringof); } } thank u , @Marc Schütz .

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread Artur Skawina via Digitalmars-d-learn
On 01/28/15 10:44, zhmt via Digitalmars-d-learn wrote: > I have a struct created by thrift: > > struct Card { > long id; > string pwd; > long agentId; > bool valid; > long rmb; > long createDate; > long soldDate; > long chargeDate; > > mixin TStructHelpers!([ > TFieldMeta(`i

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread zhmt via Digitalmars-d-learn
Anybody help?

how convert the range to slice ?

2015-01-28 Thread mzfhhhh via Digitalmars-d-learn
is there any simple way to convert? int [] arr1 = [1,2,3].map!"a*2"; //compile error int [] arr2 = [1,2,3].filter!"a<3";//compile error

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread zhmt via Digitalmars-d-learn
void getT(SRC,DEST)(SRC src,DEST dest) { foreach (i, type; typeof(SRC.tupleof)) { string name = SRC.tupleof[i].stringof; __traits(getMember, dest, name) = __traits(getMember, src, name); writeln(name); } } when I write the code above, the compi

Using std.net.curl to stream data

2015-01-28 Thread Trollgeir via Digitalmars-d-learn
I'm having some trouble trying to stream data to my plot.ly graph: https://plot.ly/62/~Trollgeir/ The API: https://plot.ly/streaming/ I am able to post messages that get recorded into the stream live, although right after curl uploads it, it just seems to wait for a response it's not getting,

Re: shared Variant[string]

2015-01-28 Thread Fyodor Ustinov via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 12:32:29 UTC, Tobias Pankrath wrote: In your case above, it's std.variant : Variant, which does not work when shared. I look into variant.d and after seeing so many lines "@@@ BUG" - strange that it somehow works. :)

Re: shared Variant[string]

2015-01-28 Thread Tobias Pankrath via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 12:29:09 UTC, Fyodor Ustinov wrote: On Wednesday, 28 January 2015 at 11:27:53 UTC, Kagamin wrote: Associative array doesn't support thread-safe operations, that's why they don't work on shared instance. You should use std.concurrency or implement low-level concu

Re: shared Variant[string]

2015-01-28 Thread Fyodor Ustinov via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 11:27:53 UTC, Kagamin wrote: Associative array doesn't support thread-safe operations, that's why they don't work on shared instance. You should use std.concurrency or implement low-level concurrency mechanism. If associative array does not support "share" attr

Re: Threads and stdio and HANDLE

2015-01-28 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 11:50:46 UTC, Danny wrote: For Windows, if I use GetStdHandle, is the resulting HANDLE valid for threads other than the one that called GetStdHandle ? Because the HANDLE is a pointer but doesn't have "shared". Does one know for Windows handles in general which a

Re: Does anybody work on std.net.curl?

2015-01-28 Thread Rikki Cattermole via Digitalmars-d-learn
On 29/01/2015 12:54 a.m., Suliman wrote: Just interesting is there any plans to replace net.curl on native lib? I mean not plans for long future, but some stuff on which somebody active work? The best I can suggest is Vibe.d.

Does anybody work on std.net.curl?

2015-01-28 Thread Suliman via Digitalmars-d-learn
Just interesting is there any plans to replace net.curl on native lib? I mean not plans for long future, but some stuff on which somebody active work?

Threads and stdio and HANDLE

2015-01-28 Thread Danny via Digitalmars-d-learn
Hello, I'm trying to write some toy examples using threads in D. Is the std.stdio.File thread-local or shared? Is flockfile used when I synchronize on it? I tried checking phobos myself and found some things I don't get (in stdio.d): alias FLOCK = flockfile; this(this) { @trusted if(fps

Re: Using dub

2015-01-28 Thread Rikki Cattermole via Digitalmars-d-learn
On 28/01/2015 1:34 p.m., Joel wrote: On Tuesday, 27 January 2015 at 08:08:19 UTC, Joel wrote: Oope, yeah, and it ran. Thanks Rikki, I wiped off the dub installation. Now, no errors. The small program worked too. I don't now how to set up the dub executable to work with out doing stuff like th

Re: Using dub

2015-01-28 Thread Rikki Cattermole via Digitalmars-d-learn
On 28/01/2015 2:14 p.m., Joel wrote: On Wednesday, 28 January 2015 at 00:34:13 UTC, Joel wrote: On Tuesday, 27 January 2015 at 08:08:19 UTC, Joel wrote: Oope, yeah, and it ran. Thanks Rikki, I wiped off the dub installation. Now, no errors. The small program worked too. Actually I got this

Re: shared Variant[string]

2015-01-28 Thread Kagamin via Digitalmars-d-learn
Some reading: http://ddili.org/ders/d.en/concurrency.html http://ddili.org/ders/d.en/concurrency_shared.html http://www.informit.com/articles/article.aspx?p=1609144

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 09:44:29 UTC, zhmt wrote: It is boring coding, I want a solution to copy them automatically: void copyObj(SRC,DEST)(SRC src,DEST dest) { foreach (i, type; typeof(SRC.tupleof)) { auto name = SRC.tupleof[i].stringof; __traits(getMember, de

Re: shared Variant[string]

2015-01-28 Thread Kagamin via Digitalmars-d-learn
Associative array doesn't support thread-safe operations, that's why they don't work on shared instance. You should use std.concurrency or implement low-level concurrency mechanism.

Re: Cached Incremental Updates of DUB Builds

2015-01-28 Thread data man via Digitalmars-d-learn
How you thought about merging Cook2 with DUB? I'm not the author the Cook2. :)

Re: shared Variant[string]

2015-01-28 Thread zhmt via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 10:32:56 UTC, Fyodor Ustinov wrote: On Wednesday, 28 January 2015 at 10:20:42 UTC, zhmt wrote: try __gshared It seems to me - is not the solution, it's a hack. I want to understand what the happening. :) I am new to D. But I that error yesterday, and it's s

Re: shared Variant[string]

2015-01-28 Thread Fyodor Ustinov via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 10:20:42 UTC, zhmt wrote: try __gshared It seems to me - is not the solution, it's a hack. I want to understand what the happening. :)

Re: Cached Incremental Updates of DUB Builds

2015-01-28 Thread Nordlöw
On Wednesday, 28 January 2015 at 01:53:43 UTC, data man wrote: Try it: https://github.com/gecko0307/Cook2 Looks nice...I'll try it...but I still want integration with DUB's other feature to automatically download external packages from github. How you thought about merging Cook2 with DUB?

Re: shared Variant[string]

2015-01-28 Thread zhmt via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 10:16:02 UTC, Fyodor Ustinov wrote: Hi! Simple program: import std.variant; shared Variant[string] t; void main() { t["t"] = "bebebe"; } Without "shared" this program compiles and works. With shared I get: aa.d(6): Error: template std.variant.VariantN!3

shared Variant[string]

2015-01-28 Thread Fyodor Ustinov via Digitalmars-d-learn
Hi! Simple program: import std.variant; shared Variant[string] t; void main() { t["t"] = "bebebe"; } Without "shared" this program compiles and works. With shared I get: aa.d(6): Error: template std.variant.VariantN!32LU.VariantN.opAssign cannot deduce function from argument types !()(

How to copy object of class A to another object of class B?

2015-01-28 Thread zhmt via Digitalmars-d-learn
I have a struct created by thrift: struct Card { long id; string pwd; long agentId; bool valid; long rmb; long createDate; long soldDate; long chargeDate; mixin TStructHelpers!([ TFieldMeta(`id`, 1, TReq.OPTIONAL), TFieldMeta(`pwd`, 2, TReq.OPTIONAL), TFieldMeta(`ag