Re: opOpAssign on object properties

2017-01-08 Thread collerblade via Digitalmars-d-learn
On Sunday, 8 January 2017 at 21:50:12 UTC, Ivan Kazmenko wrote: On Sunday, 8 January 2017 at 18:23:34 UTC, collerblade wrote: [...] Hmm, right. The setter is not called, and it's by the spec. Which says that "a op= b" is rewritten as "a.opOpAssign !(op) (b)". Here: https://dlang.org/spec/op

Re: Need some help understanding PyD

2017-01-08 Thread Saurabh Das via Digitalmars-d-learn
PS: Noticed something off. My python installation is 3.4.3: Python 3.4.3 (default, Sep 14 2016, 12:36:27) [GCC 4.8.4] on linux However when I run: context.py_stmts("import sys"); context.py_stmts("print(sys.version)"); I get: 3.4.0 (default, Apr 11 2014, 13:08:40) [GCC 4.8.2] Also, whe

Need some help understanding PyD

2017-01-08 Thread Saurabh Das via Digitalmars-d-learn
I've been giving PyD a try. It's really nice and mostly everything works out of the box. I'm trying to use TensorFlow in D via Pytho, so I need to call Python functions in D. When I try to do: auto context = new InterpContext(); context.py_stmts("import tensorflow"); I get this erro

Re: Getch() Problem: C vs D

2017-01-08 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 8 January 2017 at 21:19:15 UTC, LouisHK wrote: And works fine, but the D version below nothing happens when I hit ESCAPE: Is this a bug or there is another approach? Could this be because of maybe somehow it handles the console input? Kinda like how shift and different keys are to

Re: Mixin in Inline Assembly

2017-01-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 9 January 2017 at 02:31:42 UTC, Chris M. wrote: asm { mov EAX, tmp; // I'd also like to know if I could just load *op1 directly into EAX mov ECX, op2[EBP]; mixin(ins ~ " EAX, CL;"); // Issue here mov tmp, EAX; } *op1 = tmp; } However,

Re: Mixin in Inline Assembly

2017-01-08 Thread Chris M. via Digitalmars-d-learn
On Monday, 9 January 2017 at 02:38:01 UTC, Stefan Koch wrote: On Monday, 9 January 2017 at 02:31:42 UTC, Chris M. wrote: [...] Yes make the whole inline asm a mixin. Awesome, got it working. Thanks to both replies.

Re: Mixin in Inline Assembly

2017-01-08 Thread ketmar via Digitalmars-d-learn
On Monday, 9 January 2017 at 02:31:42 UTC, Chris M. wrote: However, the inline assembler doesn't like me trying to do a mixin. yep. iasm is completely independent from other fronted, it has it's own lexer, parser and so on. don't expect those things to work. the only way is to mixin the whole

Re: Mixin in Inline Assembly

2017-01-08 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 9 January 2017 at 02:31:42 UTC, Chris M. wrote: Right now I'm working on a project where I'm implementing a VM in D. I'm on the rotate instructions, and realized I could *almost* abstract the ror and rol instructions with the following function private void rot(string ins)(int *op1

Mixin in Inline Assembly

2017-01-08 Thread Chris M. via Digitalmars-d-learn
Right now I'm working on a project where I'm implementing a VM in D. I'm on the rotate instructions, and realized I could *almost* abstract the ror and rol instructions with the following function private void rot(string ins)(int *op1, int op2) { int tmp = *op1; asm { mov EA

Re: Android Status

2017-01-08 Thread Ignacious via Digitalmars-d-learn
On Sunday, 8 January 2017 at 22:19:31 UTC, Joakim wrote: On Sunday, 8 January 2017 at 21:52:01 UTC, Ignacious wrote: Not sure what is going on, of course ;) So much BS just to do something that is suppose to be simple ;) test.d void main() { } here is test.o http://pastebin.com/NRrKgKtb

Re: Android Status

2017-01-08 Thread Joakim via Digitalmars-d-learn
On Sunday, 8 January 2017 at 21:52:01 UTC, Ignacious wrote: Not sure what is going on, of course ;) So much BS just to do something that is suppose to be simple ;) test.d void main() { } here is test.o http://pastebin.com/NRrKgKtb Any ideas? Oh, that's easy: install the NDK too, as sh

Re: Primality test function doesn't work on large numbers?

2017-01-08 Thread Timon Gehr via Digitalmars-d-learn
On 08.01.2017 08:52, Elronnd wrote: I'm working on writing an RSA implementation, but I've run into a roadblock generating primes. With a more than 9 bits, my program either hangs for a long time (utilizing %100 CPU!) or returns a composite number. With 9 or fewer bits, I get primes, but I have

Re: Android Status

2017-01-08 Thread Ignacious via Digitalmars-d-learn
On Sunday, 8 January 2017 at 20:34:21 UTC, Joakim wrote: On Sunday, 8 January 2017 at 19:58:06 UTC, Ignacious wrote: I suppose it will be easier to install a real ubuntu distro rather than relying on windows? All these issues seem to be related to outdated versions? Distributor ID: Ubuntu Des

Re: opOpAssign on object properties

2017-01-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 8 January 2017 at 18:23:34 UTC, collerblade wrote: On Sunday, 8 January 2017 at 10:03:50 UTC, Ivan Kazmenko wrote: On Sunday, 8 January 2017 at 09:22:12 UTC, collerblade wrote: [...] 1. If you want the member variable to change, naturally, you should provide a getter property whic

Getch() Problem: C vs D

2017-01-08 Thread LouisHK via Digitalmars-d-learn
Hello, I minimize the problem to identify the problem: Here the C version: #include int main(){ int c; while(c != 27){ printf("%d\n", (c = getch())); } return 0; } And works fine, but the D version below nothing happens when I hit ESCAPE: import std.stdio; extern (C) int

Re: Android Status

2017-01-08 Thread Joakim via Digitalmars-d-learn
On Sunday, 8 January 2017 at 19:58:06 UTC, Ignacious wrote: I suppose it will be easier to install a real ubuntu distro rather than relying on windows? All these issues seem to be related to outdated versions? Distributor ID: Ubuntu Description:Ubuntu 14.04.5 LTS Release:14.04 Code

Re: Android Status

2017-01-08 Thread Ignacious via Digitalmars-d-learn
Yeah, not a good idea to build from source yourself. Try the advice here, ie see if you can install a package with that library or just symlink to the older library if not: http://askubuntu.com/questions/771047/erlang-error-while-loading-shared-libraries-libncursesw-so-6 Well, the only wa

Re: opOpAssign on object properties

2017-01-08 Thread collerblade via Digitalmars-d-learn
On Sunday, 8 January 2017 at 10:03:50 UTC, Ivan Kazmenko wrote: On Sunday, 8 January 2017 at 09:22:12 UTC, collerblade wrote: [...] 1. If you want the member variable to change, naturally, you should provide a getter property which returns a reference to that variable: [...] yes i tried

Re: CTFE difference between dmd and ldc2

2017-01-08 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On Saturday, 7 January 2017 at 22:55:55 UTC, Joseph Rushton Wakeling wrote: I should probably also create a formal issue for this. Any thoughts on how best to break it down into a minimal example? It does not appear easy to do so at first glance :-\ Turned out to be easier than I anticipated

Re: opOpAssign on object properties

2017-01-08 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 8 January 2017 at 09:22:12 UTC, collerblade wrote: How can i do opOpAssign with properties?? 1. If you want the member variable to change, naturally, you should provide a getter property which returns a reference to that variable: ref Point location() @property { return

Re: Primality test function doesn't work on large numbers?

2017-01-08 Thread Eugene Wissner via Digitalmars-d-learn
On Sunday, 8 January 2017 at 07:52:33 UTC, Elronnd wrote: I'm working on writing an RSA implementation, but I've run into a roadblock generating primes. With a more than 9 bits, my program either hangs for a long time (utilizing %100 CPU!) or returns a composite number. With 9 or fewer bits,

opOpAssign on object properties

2017-01-08 Thread collerblade via Digitalmars-d-learn
hello guys, i would like to have properties with /= *= += -= operators. My code: struct Point { float x=0,y=0; this(float _x, float _y) { x=_x; y=_y; } //opassign for + //opopassign for += void opOpAssign(string op=="+")(in Point p) { x+=p.x; y+=p.y; } } class