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/operatoroverloading.html#op-assign

[...]




Y, i have came up the same conclusion. I have to place an event 
like system into the Point.


Ty


[Issue 17077] Unexpected optlink termination

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17077

Walter Bright  changed:

   What|Removed |Added

 CC||bugzi...@digitalmars.com

--- Comment #1 from Walter Bright  ---
Since this is a linker error, just a zip file with the .obj files and a linker
command should be sufficient.

--


Re: Seemingly patternless optlink premature termination

2017-01-08 Thread Walter Bright via Digitalmars-d

On 1/8/2017 8:24 PM, pineapple wrote:

On this subject, I spent a good chunk of my day trying to compile my code using
the -m32mscoff switch and was never able to get it to work. (My most recent
obstacle is this error, occurring even for a very simple test program importing
no dependencies, if anyone cares to take a look:
https://hastebin.com/vezojehaxo.txt)


Please post bug reports to bugzilla, not pastebins.



Regarding the above: Because I have not managed to get an alternative to optlink
working, I currently am unable to work on mach on my Windows desktop. In order
to keep up progress I've been having to write and compile code on OSX on a
laptop; it is nowhere near an ideal workflow. I understand you likely have a lot
on your plate, but please prioritize solving this problem. It's causing me a
great deal of irritation and inconvenience, and it's embarrassing that my
library now simply won't compile on Windows.


You could try compiling it with -m64.


Re: Seemingly patternless optlink premature termination

2017-01-08 Thread Walter Bright via Digitalmars-d

On 1/8/2017 6:34 PM, Jerry wrote:

There's more, just the bugs are so obscure the people filing the bugs don't know
that the problem lies with Optlink. There's problems with shared libraries not
being loaded and unloaded properly. Random crashes during runtime, more often
crashes when a debugger is attached. Some more that I ran into as well before I
switched away from optlink. What point is there to report these bugs though,


If you don't report bugs, they are guaranteed to not get fixed. There's nothing 
anyone can do with the statement you made.




If you know of unreported issues with Optlink, please report them to bugzilla.

To what end?


Complaining that somebody didn't fix problems neither you nor anyone else 
reported is not very sporting.




There isn't even an Optlink specific bug list.


I found the list I posted by searching bugzilla for "optlink". If there are any 
I missed, please let me know.




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, when I import numpy from python3, it works, but if I do:
context.py_stmts("import numpy");

I get this error:
pyd.exception.PythonException@source/app.d(20):
ImportError: 
/usr/lib/python3.4/lib-dynload/_ctypes.cpython-34m-x86_64-linux-gnu.so: undefined symbol: _PyTraceback_Add





Re: Dlang remote junior developer jobs

2017-01-08 Thread Benjiro via Digitalmars-d

On Sunday, 8 January 2017 at 22:34:33 UTC, eugene wrote:

Hello, everyone,
could you share, please, your knowledge, where can i search D 
lang remote junior developer jobs?


Nowhere?


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 error:

pyd.exception.PythonException@source/app.d(19):
ImportError: 
/usr/lib/python3.4/lib-dynload/_ctypes.cpython-34m-x86_64-linux-gnu.so: undefined symbol: _PyTraceback_Add


../../.dub/packages/pyd-0.9.8/pyd/infrastructure/pyd/exception.d:46 void 
pyd.exception.handle_exception(immutable(char)[], ulong) [0x5917f6]
../../.dub/packages/pyd-0.9.8/pyd/infrastructure/pyd/embedded.d:147 void 
pyd.embedded.InterpContext.py_stmts(immutable(char)[], immutable(char)[], 
ulong) [0x59149a]
source/app.d:13 _Dmain [0x573cb2]
??:? 
_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv 
[0x5abfae]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int 
function(char[][])*).tryExec(scope void delegate()) [0x5abf04]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int 
function(char[][])*).runAll() [0x5abf6a]
??:? void rt.dmain2._d_run_main(int, char**, extern (C) int 
function(char[][])*).tryExec(scope void delegate()) [0x5abf04]

??:? _d_run_main [0x5abe61]
??:? main [0x575e6f]
??:? __libc_start_main [0x3fffbec4]
Program exited with code 1

How can I debug what the problem is?

Thanks,
Saurabh



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 toggles rather 
than dedicated to specific codes?


 Regardless, try ^[ ( Ctrl+[ ), which is 27 and ^] is 29.


Re: Seemingly patternless optlink premature termination

2017-01-08 Thread pineapple via Digitalmars-d

On Monday, 9 January 2017 at 02:34:31 UTC, Jerry wrote:
before I switched away from optlink. What point is there to 
report these bugs though, Microsoft's linker works with fewer 
bugs and actually supports the format of the platform. So no 
need to convert .lib files with it. This is my point, it's just 
one more thing that has to be maintained, but it's not even 
being maintained. Supporting MinGW would be a better option as 
then you don't have to maintain the linker and not have it 
degrade over time.


On this subject, I spent a good chunk of my day trying to compile 
my code using the -m32mscoff switch and was never able to get it 
to work. (My most recent obstacle is this error, occurring even 
for a very simple test program importing no dependencies, if 
anyone cares to take a look: https://hastebin.com/vezojehaxo.txt)


On Monday, 9 January 2017 at 01:27:27 UTC, Walter Bright wrote:

On 1/8/2017 12:58 PM, pineapple wrote:

On Sunday, 8 January 2017 at 18:49:50 UTC, Walter Bright wrote:

Please post bug reports to bugzilla.


Here you go: https://issues.dlang.org/show_bug.cgi?id=17077


Thank you.


Regarding the above: Because I have not managed to get an 
alternative to optlink working, I currently am unable to work on 
mach on my Windows desktop. In order to keep up progress I've 
been having to write and compile code on OSX on a laptop; it is 
nowhere near an ideal workflow. I understand you likely have a 
lot on your plate, but please prioritize solving this problem. 
It's causing me a great deal of irritation and inconvenience, and 
it's embarrassing that my library now simply won't compile on 
Windows.


Re: Alexa Skill written in D

2017-01-08 Thread bachmeier via Digitalmars-d-announce

On Monday, 9 January 2017 at 01:28:22 UTC, Walter Bright wrote:

On 1/8/2017 2:58 PM, extrawurst wrote:

On Sunday, 8 January 2017 at 22:54:58 UTC, Walter Bright wrote:

On 1/8/2017 1:15 PM, extrawurst wrote:
On Sunday, 8 January 2017 at 18:51:45 UTC, Walter Bright 
wrote:

On 1/7/2017 5:17 AM, extrawurst wrote:
the last 2 weeks I jumped on a new toy project: An Alexa 
Skill written in D.


Post this to reddit!


Isn't it better someone else does that?


Yes. I can't because anything I post gets autobanned.


Someone shared it now:
https://www.reddit.com/r/d_language/comments/5msngh/alexa_skill_written_in_d/

Thanks bachmeier!


Unfortunately, it would be better off in the programming 
subreddit.


Definitely. I wasn't going to post it on a Sunday afternoon 
though.


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, the inline assembler doesn't like me trying to do a 
mixin. Is there a way around this?

'

You should be able to break it up too

asm {
   mov EAX, tmp;
}
mixin("asm { "~ ins ~ "EAX, CL;" }");
asm {
   move tmp, EAX;
}


you get the idea. It should compile to the same thing.


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: Alexa Skill written in D

2017-01-08 Thread Mike Parker via Digitalmars-d-announce

On Monday, 9 January 2017 at 01:46:18 UTC, extrawurst wrote:



Unfortunately, it would be better off in the programming 
subreddit.


Volunteers to post it there aswell ?


I'll do it in about 10 hours or so.


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, int op2)
{
int tmp = *op1;
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, the inline assembler doesn't like me trying to do a 
mixin. Is there a way around this?


(There is a reason op1 is a pointer instead of a ref int, 
please don't ask about it)


Yes make the whole inline asm a mixin.


Re: Seemingly patternless optlink premature termination

2017-01-08 Thread Jerry via Digitalmars-d

On Monday, 9 January 2017 at 01:26:48 UTC, Walter Bright wrote:

On Sunday, 8 January 2017 at 19:15:49 UTC, Jerry wrote:
A bit more maddening that D is still trying to support 
optlink, a linker that

hasn't seen a commit in 2 years when it is hardly bug free.



Optlink has had many bugs fixed in it. There are currently 7 
open issues with it on bugzilla:


https://issues.dlang.org/buglist.cgi?bug_status=NEW_status=ASSIGNED_status=REOPENED=dmd_id=212971_format=advanced_desc=optlink_desc_type=allwordssubstr

This includes the issue in this thread. Only 1 of the other 
issues looks like a bug in Optlink.


There's more, just the bugs are so obscure the people filing the 
bugs don't know that the problem lies with Optlink. There's 
problems with shared libraries not being loaded and unloaded 
properly. Random crashes during runtime, more often crashes when 
a debugger is attached. Some more that I ran into as well before 
I switched away from optlink. What point is there to report these 
bugs though, Microsoft's linker works with fewer bugs and 
actually supports the format of the platform. So no need to 
convert .lib files with it. This is my point, it's just one more 
thing that has to be maintained, but it's not even being 
maintained. Supporting MinGW would be a better option as then you 
don't have to maintain the linker and not have it degrade over 
time.


If you know of unreported issues with Optlink, please report 
them to bugzilla.


To what end? There isn't even an Optlink specific bug list. Look 
at the bug with Optlink related to data that has more than 16 MB. 
What happened with that? Was that known bug fixed? No, a 
limitation was introduced into DMD to accommodate Optlink's bug. 
Rather than doing the sane decision to fix the bug in Optlink. 
Why? Probably because no one wants to deal with assembly.


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 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, the inline assembler doesn't like me trying to do a 
mixin. Is there a way around this?


(There is a reason op1 is a pointer instead of a ref int, please 
don't ask about it)


[Issue 16513] Speed up TemplateInstance.findExistingInstance hash

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16513

Martin Nowak  changed:

   What|Removed |Added

   Keywords||pull

--- Comment #5 from Martin Nowak  ---
https://github.com/dlang/dmd/pull/6418

--


[Issue 16513] Speed up TemplateInstance.findExistingInstance hash

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16513

Martin Nowak  changed:

   What|Removed |Added

Summary|Speed up|Speed up
   |TemplateInstance.findExisti |TemplateInstance.findExisti
   |ngInstance, hash by |ngInstance hash
   |mangling|

--


Re: Alexa Skill written in D

2017-01-08 Thread extrawurst via Digitalmars-d-announce

On Monday, 9 January 2017 at 01:28:22 UTC, Walter Bright wrote:

On 1/8/2017 2:58 PM, extrawurst wrote:

On Sunday, 8 January 2017 at 22:54:58 UTC, Walter Bright wrote:

On 1/8/2017 1:15 PM, extrawurst wrote:
On Sunday, 8 January 2017 at 18:51:45 UTC, Walter Bright 
wrote:

On 1/7/2017 5:17 AM, extrawurst wrote:
the last 2 weeks I jumped on a new toy project: An Alexa 
Skill written in D.


Post this to reddit!


Isn't it better someone else does that?


Yes. I can't because anything I post gets autobanned.


Someone shared it now:
https://www.reddit.com/r/d_language/comments/5msngh/alexa_skill_written_in_d/

Thanks bachmeier!


Unfortunately, it would be better off in the programming 
subreddit.


Volunteers to post it there aswell ?


Re: Alexa Skill written in D

2017-01-08 Thread Walter Bright via Digitalmars-d-announce

On 1/8/2017 2:58 PM, extrawurst wrote:

On Sunday, 8 January 2017 at 22:54:58 UTC, Walter Bright wrote:

On 1/8/2017 1:15 PM, extrawurst wrote:

On Sunday, 8 January 2017 at 18:51:45 UTC, Walter Bright wrote:

On 1/7/2017 5:17 AM, extrawurst wrote:

the last 2 weeks I jumped on a new toy project: An Alexa Skill written in D.


Post this to reddit!


Isn't it better someone else does that?


Yes. I can't because anything I post gets autobanned.


Someone shared it now:
https://www.reddit.com/r/d_language/comments/5msngh/alexa_skill_written_in_d/

Thanks bachmeier!


Unfortunately, it would be better off in the programming subreddit.


Re: Seemingly patternless optlink premature termination

2017-01-08 Thread Walter Bright via Digitalmars-d

On 1/8/2017 12:58 PM, pineapple wrote:

On Sunday, 8 January 2017 at 18:49:50 UTC, Walter Bright wrote:

Please post bug reports to bugzilla.


Here you go: https://issues.dlang.org/show_bug.cgi?id=17077


Thank you.


Re: Seemingly patternless optlink premature termination

2017-01-08 Thread Walter Bright via Digitalmars-d

On Sunday, 8 January 2017 at 19:15:49 UTC, Jerry wrote:

A bit more maddening that D is still trying to support optlink, a linker that
hasn't seen a commit in 2 years when it is hardly bug free.



Optlink has had many bugs fixed in it. There are currently 7 open issues with it 
on bugzilla:


https://issues.dlang.org/buglist.cgi?bug_status=NEW_status=ASSIGNED_status=REOPENED=dmd_id=212971_format=advanced_desc=optlink_desc_type=allwordssubstr

This includes the issue in this thread. Only 1 of the other issues looks like a 
bug in Optlink.


If you know of unreported issues with Optlink, please report them to bugzilla.


[Issue 16855] Global void[0] causes OPTLINK Error when passed as ref Parameter

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16855

Walter Bright  changed:

   What|Removed |Added

 CC||bugzi...@digitalmars.com

--- Comment #1 from Walter Bright  ---
This produces the error:

OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
bug4.obj(bug4)  Offset 0026DH Record Type 009D
 Error 16: Index Range
Error: linker exited with status 1

which looks like a corrupt object file being passed to it.

--


Re: Reminder - DConf 2017 is May 4-6 !!

2017-01-08 Thread Adam Wilson via Digitalmars-d-announce

On 1/6/17 4:46 PM, Walter Bright wrote:

It's 2017 already - sharpen your pencils and start on a proposal for a
presentation! Time is moving fast!


Just sent mine in!

--
Adam Wilson
IRC: LightBender
import quiet.dlang.dev;


Re: Seemingly patternless optlink premature termination

2017-01-08 Thread Walter Bright via Digitalmars-d

On 1/8/2017 10:56 AM, jkpl wrote:

On Sunday, 8 January 2017 at 18:49:50 UTC, Walter Bright wrote:

P.S. Isn't it maddening that Windows doesn't allow copying the data from a
message window?


Not really, because you can, Ctrl+C...


That frequently does not work. For example, take the "Help" window of 
Thunderbird, which is my email program. You cannot copy data from it.


Re: It's alive! D building D building D, all on Android

2017-01-08 Thread Ignacious via Digitalmars-d-announce
Just reporting here that I was able to get a hello world working 
using windows and UoW.


Some issues I had:

1. Had issues with outdated libraries. (ncurses, gcc, etc)
2. UoW Aniversary is based on Ubuntu 14, I was able to upgrade to 
16.04 following online sources. Lots of snags but eventually 
worked. (had to remove an file like 
50unattended-upgrades.ucf-dist to get everything to finish 
upgrading)


Basically search for solutions of each error online and 
eventually one will work. If anyone does this they could document 
it a bit better for others.


3. Installed android NDK without too much trouble.

4. Building with ldc2 works but must link with something like

$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/clang 
-Wl,-z,nocopyreloc --sysroot=$NDK/platforms/android-9/arch-arm 
-lgcc -gcc-toolchain 
$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 
-target armv7-none-linux-androideabi -no-canonical-prefixes 
-fuse-ld=bfd -Wl,--fix-cortex-a8 -Wl,--no-undefined 
-Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -fPIE -pie -mthumb 
-Wl,--export-dynamic -lc -lm test.o lib/libphobos2-ldc.a 
lib/libdruntime-ldc.a -o test


5. Push to android device and make sure to make executable or it 
will fail silently(e.g., chmod 755 test). Install a terminal 
emulator, obviously.


Haven't tried more complex examples but all the hard work seems 
to be paying off.


Thanks.




Re: Vision document for H1 2017

2017-01-08 Thread Jonathan M Davis via Digitalmars-d-announce
On Sunday, January 08, 2017 18:06:53 Brian via Digitalmars-d-announce wrote:
> On Wednesday, 4 January 2017 at 19:22:33 UTC, Andrei Alexandrescu
>
> wrote:
> > We release a brief Vision document summarizing the main goals
> > we plan to pursue in the coming six months. This half we are
> > focusing on three things: safety, lifetime management, and
> > static introspection.
> >
> > https://wiki.dlang.org/Vision/2017H1
> >
> >
> > Andrei
>
> I hope dlang can support QT5 binding

Binding to Qt in general is really nasty in comparison to a lot of C++ code,
since Qt does stuff like have its own preprocessor to generate additional
code so that signals and slots work. We had qtd (which did Qt4), but it
seems to have lost all its contributors and died off a few years ago, and it
seems to have used Qt Jambi stuff (or at least been based on it) and Qt
Jambi doesn't seem to have ever made the transition to Qt5. So, I don't know
how possible it would be to get qtd to work with Qt5, even if the original
contributors were still working on it (but it doesn't seem to compile now,
so it's not even currently viable for Qt4). I think that someone put up a
solution on code.dlang.org that involves QML, but I have no idea how well it
works or how complete it is (personally, I have less than zero interest in
QML).

I've actually started work on a solution for binding Qt5 to D, because I
have something I'm working on that uses Qt, and I'm sick of doing the GUI
portion in C++. So, I may end up releasing a Qt5 bindings project at some
point here, but I'm making no promises.

- Jonathan M Davis



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

Any ideas?


Oh, that's easy: install the NDK too, as shown on the wiki.  
You need the linker that supports ARM from the NDK.  Follow the 
instructions from the wiki to compile and link the binary, 
simply having ldc do everything won't work.




Ok, after executing

$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/clang 
-Wl,-z,nocopyreloc --sysroot=$NDK/platforms/android-9/arch-arm 
-lgcc -gcc-toolchain 
$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 
-target armv7-none-linux-androideabi -no-canonical-prefixes 
-fuse-ld=bfd -Wl,--fix-cortex-a8 -Wl,--no-undefined 
-Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -fPIE -pie -mthumb 
-Wl,--export-dynamic -lc -lm test.o lib/libphobos2-ldc.a 
lib/libdruntime-ldc.a -o test


I get a test elf file with no errors(although 2.5MB for a hello 
world).


I had to do the chmod 755 test

then

./test

to get any output. Before that no output and no errors so wasn't 
sure what as going on.


Looks like everything is working! ;)

Seems like someone really needs to put some time in to getting 
all this stuff organized and situated


Maybe the D language foundation can push some money towards it to 
get it started off on the right foot?


I'll try to get some of the opengl examples on your repository to 
see if they work soon.



Cross-compiler toolchains are never simple, consider yourself 
lucky for having gotten off easy. :)


I realize things are difficult but it's people that make it that 
way ;) Life would be so much simpler if people would just 
properly document stuff exactly(or, rather, do what they are 
suppose to do). (Even windows seems to love to forget to put in 
descriptions of services, tasks, application descriptions, etc).


The main problem I have had seems to be that UoW uses ver 14. 
Somehow I was able to upgrade by following docs online(wasn't 
easy but eventually got there and everything seems to work... I 
should have documented ;) but I wasn't sure if the process would 
work. Supposedly ver 16 exists by one has to be part of the dev 
team or something.




[Issue 16955] std.process.spawnProcessImpl can crash due to alloca

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16955

deadalnix  changed:

   What|Removed |Added

 CC||deadal...@gmail.com

--- Comment #4 from deadalnix  ---
*** Issue 17078 has been marked as a duplicate of this issue. ***

--


[Issue 17078] std.process.execute fails on travis

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17078

deadalnix  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #2 from deadalnix  ---
It turns out there is already a fix, but it didn't make the release.

*** This issue has been marked as a duplicate of issue 16955 ***

--


[Issue 17078] std.process.execute fails on travis

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17078

--- Comment #1 from deadalnix  ---
As far my investigation goes, it looks like the spawned process dies with
signal 11 before it even reaches main in the child.

--


Re: CTFE Status

2017-01-08 Thread Stefan Koch via Digitalmars-d

On Thursday, 5 January 2017 at 06:04:00 UTC, Stefan Koch wrote:

On Monday, 2 January 2017 at 18:40:44 UTC, Stefan Koch wrote:

So guys.

basic function-calls are supported.

Hell YEAH!


Disabled for now. Since it pushes some buffers/caches to their 
limit. A more flexible solution is needed.


This is now fixed by simply extending the limits.
Now more failures start to show and more manual bailouts are 
required again.


Although, I expected this to happen it bums me. :(


[Issue 17078] New: std.process.execute fails on travis

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17078

  Issue ID: 17078
   Summary: std.process.execute fails on travis
   Product: D
   Version: D2
  Hardware: x86_64
OS: Windows
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: deadal...@gmail.com

As per title. Spawning process using std.process.execute in travis-ci always
fails. The process apparently return error code -11 and does nothing.

For some obscure reason, wait(spanShell()) does work.

--


Re: Alexa Skill written in D

2017-01-08 Thread extrawurst via Digitalmars-d-announce

On Sunday, 8 January 2017 at 22:54:58 UTC, Walter Bright wrote:

On 1/8/2017 1:15 PM, extrawurst wrote:

On Sunday, 8 January 2017 at 18:51:45 UTC, Walter Bright wrote:

On 1/7/2017 5:17 AM, extrawurst wrote:
the last 2 weeks I jumped on a new toy project: An Alexa 
Skill written in D.


Post this to reddit!


Isn't it better someone else does that?


Yes. I can't because anything I post gets autobanned.


Someone shared it now: 
https://www.reddit.com/r/d_language/comments/5msngh/alexa_skill_written_in_d/


Thanks bachmeier!


Re: Alexa Skill written in D

2017-01-08 Thread Walter Bright via Digitalmars-d-announce

On 1/8/2017 1:15 PM, extrawurst wrote:

On Sunday, 8 January 2017 at 18:51:45 UTC, Walter Bright wrote:

On 1/7/2017 5:17 AM, extrawurst wrote:

the last 2 weeks I jumped on a new toy project: An Alexa Skill written in D.


Post this to reddit!


Isn't it better someone else does that?


Yes. I can't because anything I post gets autobanned.



Re: symlinks in repo (ddmd->src) breaks Dropbox (or google drive)

2017-01-08 Thread Timothee Cour via Digitalmars-d
actually here's the article explaning the symlink in dropbox disaster:
http://www.paulingraham.com/dropbox-and-symlinks.html



On Sun, Jan 8, 2017 at 2:35 PM, Timothee Cour 
wrote:

> https://github.com/dlang/dmd/commit/801742d93ecb6c929409a19c024dd8
> 7ca25330a3 introduced a symlink dmd repo; if a user clones it inside a
> Dropbox (or google drive) and syncs his dropbox to another machine, it will
> create havoc:
>
> * google drive doesn't support symlinks at all
> * dropbox supports it in a horrible way, resolving symlinks, leading to
> duplicating the folder that's being symlinked on the 2nd machine:
> http://askubuntu.com/questions/452714/is-dropbox-
> going-to-always-resolve-my-symlinks,
>
>


symlinks in repo (ddmd->src) breaks Dropbox (or google drive)

2017-01-08 Thread Timothee Cour via Digitalmars-d
https://github.com/dlang/dmd/commit/801742d93ecb6c929409a19c024dd87ca25330a3
introduced a symlink dmd repo; if a user clones it inside a Dropbox (or
google drive) and syncs his dropbox to another machine, it will create
havoc:

* google drive doesn't support symlinks at all
* dropbox supports it in a horrible way, resolving symlinks, leading to
duplicating the folder that's being symlinked on the 2nd machine:
http://askubuntu.com/questions/452714/is-dropbox-going-to-always-resolve-my-symlinks
,


Dlang remote junior developer jobs

2017-01-08 Thread eugene via Digitalmars-d

Hello, everyone,
could you share, please, your knowledge, where can i search D 
lang remote junior developer jobs?


[Issue 14894] mangling of mixins and lambdas is not unique and depends on compilation flags

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14894

Martin Nowak  changed:

   What|Removed |Added

Summary|mangling of mixins and  |mangling of mixins and
   |lambdas can change w/   |lambdas is not unique and
   |-unittest or other versions |depends on compilation
   ||flags
   Severity|normal  |critical

--- Comment #8 from Martin Nowak  ---
Apparently can also cause calls of the wrong function instead of linker errors,
see issue 16994.
Different compilations end up with instances of the same mangling.

cat > lib.d << CODE
alias min = (a, b) => a < b ? a : b;
alias max = (a, b) => a > b ? a : b;

auto reduce(alias func, T...)(T args)
{
return func(args);
}
CODE
cat > a.d << CODE
import lib;

unittest
{
assert(reduce!min(1, 2) == 1);
}
CODE
cat > b.d << CODE
import lib;

unittest
{
assert(reduce!max(1, 2) == 2);
}
CODE

# works
dmd -main -unittest -ofmain a.d b.d
./main

# fails
dmd -unittest -c a.d
dmd -unittest -c b.d
dmd -main -ofmain a.o b.o // one of the tests calls the wrong reduce
./main



$ dmd -unittest -c a.d
$ nm a.o | grep lambda
 W _D3lib18__T9__lambda5TiTiZ9__lambda5FNaNbNiNfiiZi
 W _D3lib32__T6reduceS143lib9__lambda5TiTiZ6reduceFNaNbNiNfiiZi
$ dmd -unittest -c b.d
$ nm b.o | grep lambda
 W _D3lib18__T9__lambda5TiTiZ9__lambda5FNaNbNiNfiiZi
 W _D3lib32__T6reduceS143lib9__lambda5TiTiZ6reduceFNaNbNiNfiiZi

--


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 shown on the wiki.  You 
need the linker that supports ARM from the NDK.  Follow the 
instructions from the wiki to compile and link the binary, simply 
having ldc do everything won't work.


Cross-compiler toolchains are never simple, consider yourself 
lucky for having gotten off easy. :)


Re: Linker-hacking out the D runtime

2017-01-08 Thread Iain Buclaw via Digitalmars-d-announce
On 20 December 2016 at 12:24, Mike via Digitalmars-d-announce
 wrote:
> On Monday, 19 December 2016 at 19:53:06 UTC, Iain Buclaw wrote:
>
>> The compiler doesn't actually generate any code that peeks inside
>> TypeInfo.  It only generates the reference to the right typeinfo to pass to
>> library runtime functions -  or on request via typeid().  It doesn't
>> actually care about the data stored inside.  And that's the angle I've taken
>> when laying out the actual data - if you provide the fields we want to
>> populate, then we'll populate them.  If you omit a few, then the compiler
>> won't bother with them.  Because at the end of the day, it's druntime
>> library that uses and makes sense of the TypeInfo data provided.  The
>> compile just says: "Well, this is as much as I'm willing to tell you about
>> the type."
>
>
> Ok, that's interesting, but what if you don't want TypeInfo at all?  Can you
> omit the TypeInfo structure entirely from object.d?  Or perhaps you still
> need to declare it in object.d, but since the compiler doesn't find any
> fields to populate, it results in an empty struct?  I'd really hate to have
> to add empty TypeInfo_XXX classes to my object.d though.
>

Yeah, there are two logical steps that need ratifying.

1) -fno-rtti should be a flag that is honoured by the compiler.
2) Runtime functions that "lower" to a C function call should not
generate RTTI if all information about the type is known at
compile-time.

There are ideas floating around to improve [2], but for the time being
however, marking all functions as @nogc catches almost all cases where
this happens.


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 to run with a
huge number of iterations to actually _get_ a random number.  It runs
fast, though.  Why might this be?  Code:
http://lpaste.net/1034777940820230144


Fixed version:

import std.bigint;
import std.stdio;

private alias bigint = BigInt;
bigint pow(bigint base,bigint exponent){
bigint tmp=1;
for(auto x=base,y=exponent;y;x*=x,y/=2)
if(y%2) tmp*=x;
return tmp;
}
bigint powm(bigint base,bigint exponent,bigint modulus){
bigint tmp=1;
for(auto x=base,y=exponent;y;x=x*x%modulus,y/=2)
if(y%2) tmp=tmp*x%modulus;
return tmp;
}
private pragma(inline, true) bigint pow(int base, bigint exponent) {
return pow(bigint(base), exponent);
}
private pragma(inline, true) bigint pow(bigint base, int exponent) {
return pow(base, bigint(exponent));
}
private pragma(inline, true) bigint pow(int base, int exponent) {
return pow(bigint(base), bigint(exponent));
}

// Credit to 
http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf appendix C.3

private bigint genprime(int bits, int numtests){
import std.random: uniform;

bool mrprime(bigint integer, int iterations) {
if(integer%2==0)
return false;

bigint m, a = 0, tmp = integer, b, z;
int length;

for(m=integer-1;m%2==0;m/=2,++a){}
assert((integer-1)%pow(bigint(2), a)==0);

while(tmp != 0) {
tmp >>=1;
length += 1;
}

for (int i=0; i= (integer-1))) {
b = 0;
for (int j = 1; j<=length; j++) {
b <<= 1;
b += uniform(0, 2);
}
}

z = powm(b, m, integer);
if((z == 1) || (z == integer-1))
goto endofloop;

for(int k=1; k<=a-1; k++) {
z = z*z%integer;
if(z == integer-1)
goto endofloop;
if(z == 1)
return false;
}
return false;
endofloop:
}
return true;
}

bigint genbigint(int numbits) {
bigint tmp;
while (numbits --> 0) {
tmp <<= 1;
tmp += uniform(0, 2);
}
return tmp;
}
bigint currnum;
while (true) {
currnum = genbigint(bits);
if (mrprime(currnum, numtests)) {
return currnum;
}
}
assert(0);
}

void main(){
writeln(genprime(300,30));
}



[Issue 14894] mangling of mixins and lambdas can change w/ -unittest or other versions

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14894

Martin Nowak  changed:

   What|Removed |Added

 CC||meapineap...@gmail.com

--- Comment #7 from Martin Nowak  ---
*** Issue 16994 has been marked as a duplicate of this issue. ***

--


[Issue 16994] Apparently faulty symbol resolution in some cases

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16994

Martin Nowak  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #4 from Martin Nowak  ---


*** This issue has been marked as a duplicate of issue 14894 ***

--


[Issue 16994] Apparently faulty symbol resolution in some cases

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16994

--- Comment #3 from Martin Nowak  ---
Seems to be a duplicate of issue 14894, only in this case the 2 compilations
produce different functions with the same mangling instead of causing a linker
error.
It just happens that in both compilations a lambda with the same number
(__lambda21) is passed to varreduce paired with the same argument types, the
linker will just pick the implementation that occurs first.

A workaround is to convert the lambdas

alias VarReduceMin = (a, b) => (a < b ? a : b);

to template functions.

auto VarReduceMin(A, B)(A a, B b) { return (a < b ? a : b); }

--


[Issue 16680] dmd doesn't use druntime optimized versions of subtraction array operations

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16680

--- Comment #3 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/8eb8a67e6e4d47244db99e35ad02f42e1de7d253
fix issue 16680: avoid inconsistent usage of Sub and Min

https://github.com/dlang/dmd/commit/c0d93d18a99a2425961a036138afbc9b1c0ddfae
Merge pull request #6413 from rainers/fix16680

fix issue 16680: avoid inconsistent usage of Sub and Min in array operations

--


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
Description:Ubuntu 14.04.5 LTS
Release:14.04
Codename:   trusty


I doubt that'd work either as Debian just uses older packages.  
Your best bet may be to just compile ldc yourself, by following 
the instructions on the wiki.


Well, I finally got it to upgrade to 16.. when I run ldc2 or 
ldmd2 I get the following errors


/usr/bin/ld: test.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: test.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: test.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: test.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: test.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: test.o: Relocations in generic ELF (EM: 40)
/usr/bin/ld: test.o: Relocations in generic ELF (EM: 40)
test.o: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
Error: /usr/bin/gcc failed with status: 1

test is just a simple hello world.



root@:/mnt/b/DLang/ldc2Android# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 
5.4.0-6ubuntu1~16.04.4' 
--with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs 
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ 
--prefix=/usr --program-suffix=-5 --enable-shared 
--enable-linker-build-id --libexecdir=/usr/lib 
--without-included-gettext --enable-threads=posix 
--libdir=/usr/lib --enable-nls --with-sysroot=/ 
--enable-clocale=gnu --enable-libstdcxx-debug 
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new 
--enable-gnu-unique-object --disable-vtable-verify 
--enable-libmpx --enable-plugin --with-system-zlib 
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo 
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre 
--enable-java-home 
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 
--with-arch-directory=amd64 
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc 
--enable-multiarch --disable-werror --with-arch-32=i686 
--with-abi=m64 --with-multilib-list=m32,m64,mx32 
--enable-multilib --with-tune=generic --enable-checking=release 
--build=x86_64-linux-gnu --host=x86_64-linux-gnu 
--target=x86_64-linux-gnu

Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)


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?




Re: Seemingly patternless optlink premature termination

2017-01-08 Thread Jerry via Digitalmars-d

On Sunday, 8 January 2017 at 20:36:38 UTC, jkpl wrote:

On Sunday, 8 January 2017 at 19:15:49 UTC, Jerry wrote:

On Sunday, 8 January 2017 at 18:49:50 UTC, Walter Bright wrote:
P.S. Isn't it maddening that Windows doesn't allow copying 
the data from a message window?


A bit more maddening that D is still trying to support 
optlink, a linker that hasn't seen a commit in 2 years when it 
is hardly bug free.


Your comment is not pertinent. The object format doesn't change 
so the linker doesn't need to be updated. The problem here 
seems to be a bug. Until someone finds it, it can't be fixed.


We are discussing Optlink and a bug related to it. The fact it's 
20 years old, written in assembly, and hasn't had a bug fix in 
years even though they have been reported is very very very much 
relevant. It's legacy software that shouldn't be relied on unless 
you also consider D to be legacy (I think most probably won't).


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 which returns a reference to 
that variable:


[...]


yes i tried the reference return, but the problem is, that the 
setter does NOT gets called, no matter what the result type of 
the opOpAssign method is.

I want to detect changes, but this way i still not able.

A a = new A;

a.location+=Point(1,1); //the private value changes, but the 
setter does not get called


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/operatoroverloading.html#op-assign

So, no *assignment* happens when you call a.location+=Point(1,1).
To have a side effect triggered by opAssign-ment, you can do it 
inside the opOpAssign function.


Looking at it another way, actions with struct Point can be seen 
as the responsibility of struct Point.  If you want to monitor 
these actions, do it in the code of opOpAssign function.  After 
that, your class A can inspect the state of its corresponding 
Point.  If normal Points don't need that, you can have a special 
SelfAwarePoint which has an alias this to its member Point.


Alternatively, you can have two getter properties: one as const 
and one by reference.  When the reference one gets called, you 
know the value of Point *may* have changed.


Well, I'm out of ideas for now.  If these still don't quite 
satisfy you, including a bigger picture of what you want to 
achieve may help.


Ivan Kazmenko.



Re: D in MPLAB FOR PIC32

2017-01-08 Thread Iain Buclaw via Digitalmars-d
On 7 January 2017 at 01:39, Mike via Digitalmars-d
 wrote:
> On Friday, 6 January 2017 at 15:47:21 UTC, Igor Myronov wrote:
>>
>> Is possible to program in D micro*-controllers like the PIC32 ?
>> Thanks to all.
>
>
> D has 3 compilers DMD, LDC, and GCC,
>
> DMD only has a backend for Intel CPUs.  LDC uses the LLVM backend, but I
> don't see an LLVM backend for PIC.  GDC uses GCC's backends, but again, I
> don't see a backend there for PIC either.
>
> LLVM and GDC both, however, have backends for other microcontrollers,
> specifically ARM Cortex-M (search for ST Discovery[1], Teensy, Adafruit
> Feather, Arduino Zero).  There was even some success a few years back
> testing D on an Atmel AVR [2].
>
> The Arduino 101 [3] uses an Intel Quark MCU, so it may be possible to
> program that using DMD, but to my knowledge, noone has tried.
>
> [1] - D on ST Discovery - https://github.com/JinShil/stm32f42_discovery_demo
> [2] - D on Atmel AVR -
> https://github.com/D-Programming-microD/avr-playground
> [3] - Arduino 101 - Intel Quark MCU -
> https://www.arduino.cc/en/Main/ArduinoBoard101
>
> That all being said, as being one spent some time exploring D on
> microcontrollers, I can't recommend it.  The problem is that the D compiler
> is tightly coupled to the D runtime, and expects a full-featured runtime in
> order to get build [4] [5] (even if your code doesn't make use of the
> features).
>
> I'm the one who wrote the previously mentioned ST Discovery proof of concept
> [1], and in order to reduce code bloat from the D runtime, I had to compile
> to assembly, use a sed script [6] to modify the assembly, and then recompile
> the assembly to the binary.  Sometimes it didn't even work. The binary was
> 600K without the sed script, and 6K after the sed script.  There is no way
> such huge binary sizes can be used for microcontrollers, and the hacks to
> get around it are just too ridiculous for me recommend D for this kind of
> work.
>
> An issue [7] for this problem was created, but the solution wasn't
> implemented properly to allow the LDC and GDC backends to benefit.  And
> since DMD doesn't support ARM Cortex-M, it was essentially useless.
>
> [4] - Demonstration of D compiler-runtime coupling -
> http://forum.dlang.org/post/kfspvnrbykweyowjt...@forum.dlang.org
> [5] - D compiler-typeInfo coupling -
> http://forum.dlang.org/post/nevipjrkdqxivoerf...@forum.dlang.org
> [6] - Sed command to reduce code bloat -
> https://github.com/JinShil/stm32f42_discovery_demo/blob/master/build.d#L69
> [7] - TypeInfo code-bloat issue -
> https://issues.dlang.org/show_bug.cgi?id=14758
>
> DMD has a switch called -betterC [8] which was intended to use a C-like
> dialect of D, but it was never fully implemented. One problem with the whole
> idea of the -betterC switch is it's not granular enough to disable only some
> features, but not others, so its not a good solution anyway.  I believe
> there are better solutions [9].
>

No, -betterC is not a dialect, it just tells the compiler not to
generate module info.

Making it also mean to tell the compiler not to generate any RTTI
would be an improvement, but then you have every runtime function
depending on RTTI. :-)

Iain


Re: Lets talk about fibers

2017-01-08 Thread Russel Winder via Digitalmars-d
On Sun, 2017-01-08 at 09:18 +, Suliman via Digitalmars-d wrote:
> > Simply picking a worker thread + worker fiber when task is 
> > assigned and sticking to it until finished should work good 
> > enough. It is also important to note though that "fiber" is not 
> > the same as "task". Former is execution context primitive, 
> > latter is scheduling abstraction. In fact, heavy load systems 
> > are likely to have many more tasks than fibers at certain spike 
> > points.
> 
> Could you explain difference between fibers and tasks. I read a 
> lot, but still can't understand the difference.

A fibre is what a thread used to be before kernels supported threads
directly. Having provided that historical backdrop, that seems sadly
missing from the entire Web, the current status is roughly described
by:

https://en.wikipedia.org/wiki/Fiber_(computer_science)

http://stackoverflow.com/questions/796217/what-is-the-difference-betwee
n-a-thread-and-a-fiber

Tasks are things that can be scheduled using threads or fibres. It's
all down to thread pools and kernel processes. Which probably doesn't
help per se, but:

http://docs.paralleluniverse.co/quasar/

Quasar, GPars, std.parallelism, Java Fork/Join all harness all these
ideas.

In the end as a programmer you should be using actors, agents,
dataflow, data parallelism or some similar high level model. Anything
lower level and, to be honest, you are doing it wrong.


-- 
Russel.
=
Dr Russel Winder  t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Roadm: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

signature.asc
Description: This is a digitally signed message part


Re: Alexa Skill written in D

2017-01-08 Thread extrawurst via Digitalmars-d-announce

On Sunday, 8 January 2017 at 18:51:45 UTC, Walter Bright wrote:

On 1/7/2017 5:17 AM, extrawurst wrote:
the last 2 weeks I jumped on a new toy project: An Alexa Skill 
written in D.


Post this to reddit!


Isn't it better someone else does that?

~Stephan


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 getch();
int main(){
   int c;
   while(c != 27){
   printf("%d\n", (c = getch()));
   }
   return 0;
}

Is this a bug or there is another approach?

Thanks,

L.





Re: Seemingly patternless optlink premature termination

2017-01-08 Thread pineapple via Digitalmars-d

On Sunday, 8 January 2017 at 18:49:50 UTC, Walter Bright wrote:

Please post bug reports to bugzilla.


Here you go: https://issues.dlang.org/show_bug.cgi?id=17077


[Issue 17077] New: Unexpected optlink termination

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17077

  Issue ID: 17077
   Summary: Unexpected optlink termination
   Product: D
   Version: D2
  Hardware: x86_64
OS: Windows
Status: NEW
  Severity: major
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: meapineap...@gmail.com

This is the code for which this error is occurring when linking on Win7:
https://github.com/pineapplemachine/mach.d/tree/optlink-error-repro

I was experiencing errors with 2.071.2-b6 and the current state of that branch
was one where the error was not being produced. Compiling with 2.071.2 should
produce the error as-is. To produce the error in 2.071.2-b6, add `unittest{}`
to line 14 in mach.d/mach/error/enforce/bounds.d. (The specific line should not
particularly matter, but that is where I was placing it while testing myself.)

https://github.com/pineapplemachine/mach.d/blob/optlink-error-repro/mach/error/enforce/bounds.d#L14

In order to reproduce, clone the repository and run the following command:
rdmd -I "path/to/mach.d" -g -main -unittest
"path/to/mach.d/mach/error/enforce/bounds.d"

The same optlink error occurs when attempting to run unit tests for modules
depending on bounds.d. It does not occur for any of the dependencies of
bounds.d.

The optlink error involves this popup: http://puu.sh/tfmBK/c5068eb2fb.png
And this text in stdout/err:

checkpoint(256)
--- errorlevel 1

The text in the popup is this:

EAX=0010
EBX=001C
ECX=
EDX=004337CF
ESI=0044AAE8
EDI=0100
EBP=0018FF54
ESP=0018FDEC
EIP=0040347E
First=00402000

In addition to adding `unittest{}` to bounds.d, I have also been hitting this
same error depending on the addition of seemingly arbitrary method and function
calls in other modules, too. When the calls are commented out, the code is
successfully compiled.

--


[Issue 16994] Apparently faulty symbol resolution in some cases

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16994

--- Comment #2 from Martin Nowak  ---
Only happens with rdmd's double compilation mode,
https://github.com/dlang/tools/pull/194, which firsts builds object for the
root module, then builds another (single) object for all dependencies.
That PR caused a number of issues and was reverted for 2.072.2
https://github.com/dlang/tools/commit/8a5b9d6224eec712d3d6ce533b426a194848c77c.

--


Re: Seemingly patternless optlink premature termination

2017-01-08 Thread jkpl via Digitalmars-d

On Sunday, 8 January 2017 at 19:15:49 UTC, Jerry wrote:

On Sunday, 8 January 2017 at 18:49:50 UTC, Walter Bright wrote:
P.S. Isn't it maddening that Windows doesn't allow copying the 
data from a message window?


A bit more maddening that D is still trying to support optlink, 
a linker that hasn't seen a commit in 2 years when it is hardly 
bug free.


Your comment is not pertinent. The object format doesn't change 
so the linker doesn't need to be updated. The problem here seems 
to be a bug. Until someone finds it, it can't be fixed.


Re: Annotation programming in my design code ..

2017-01-08 Thread Eugene Wissner via Digitalmars-d

On Sunday, 8 January 2017 at 20:11:23 UTC, Brian wrote:

On Friday, 6 January 2017 at 17:48:23 UTC, Eugene Wissner wrote:

On Friday, 6 January 2017 at 17:44:13 UTC, Brian wrote:

I would like to design features, how should I do?

coding:

class User
{
@GenerateProperty
int id;

@GenerateProperty
string name;
}

struct GenerateProperty
{
this(string propertyName)
{
propertyName = propertyName
}

string propertyName;

string getGenerateCode()
{
		return "@property int " ~ propertyName ~ "() { return __" ~ 
propertyName ~ "; }\n@property int " ~ propertyName ~ "(int 
value) { return __" ~ propertyName ~ " = value; }";

}
}

result code:

class User
{
@property int id() { return __id; }
@property int id(int value) { return __id = value; }

@property string name() { return __name; }
@property string name(int value) { return __name = value; 
}


private
{
int __id;
string __name;
}
}


Look into https://github.com/funkwerk/accessors for the 
implementation.
You should have a mixin which iterates through all class 
members and generates the properties.


Can write this code to impl it?

import accessors;
import std.stdio;

class Base
{
mixin(GenerateFieldAccessors);
}

class Person : Base
{
@Read @Write
private uint age_;

@ConstRead
private string name_;

this(in string name, in uint age = 0)
{
this.name_ = name;
this.age_ = age;
}
}

void main()
{
auto person = new Person("Saul Kripke");

person.age = 57;

writeln(person.name, ": ", person.age);
}


I think you have to include "mixin(GenerateFieldAccessors);" into 
"Person" class. accessors has currently a problem with 
inheritance. We're looking for a way to fix it.
I gave a link, so you can take a look how it is implemented. But 
you can also use the library if it meets your needs :)
But yes you can define a enum mixin which iterates through the 
class members and generates the code:


template GenerateFieldAccessorMethods()
{
static enum GenerateFieldAccessorMethods()
{
foreach (name; __traits(allMembers, typeof(this)))
{
return "Generated code";
}
}

and then you can include it in the class/struct with 
"mixin(GenerateFieldAccessorMethods!());".


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
Codename:   trusty


I doubt that'd work either as Debian just uses older packages.  
Your best bet may be to just compile ldc yourself, by following 
the instructions on the wiki.


Re: Annotation programming in my design code ..

2017-01-08 Thread Brian via Digitalmars-d

On Friday, 6 January 2017 at 17:48:23 UTC, Eugene Wissner wrote:

On Friday, 6 January 2017 at 17:44:13 UTC, Brian wrote:

I would like to design features, how should I do?

coding:

class User
{
@GenerateProperty
int id;

@GenerateProperty
string name;
}

struct GenerateProperty
{
this(string propertyName)
{
propertyName = propertyName
}

string propertyName;

string getGenerateCode()
{
		return "@property int " ~ propertyName ~ "() { return __" ~ 
propertyName ~ "; }\n@property int " ~ propertyName ~ "(int 
value) { return __" ~ propertyName ~ " = value; }";

}
}

result code:

class User
{
@property int id() { return __id; }
@property int id(int value) { return __id = value; }

@property string name() { return __name; }
@property string name(int value) { return __name = value; }

private
{
int __id;
string __name;
}
}


Look into https://github.com/funkwerk/accessors for the 
implementation.
You should have a mixin which iterates through all class 
members and generates the properties.


Can write this code to impl it?

import accessors;
import std.stdio;

class Base
{
mixin(GenerateFieldAccessors);
}

class Person : Base
{
@Read @Write
private uint age_;

@ConstRead
private string name_;

this(in string name, in uint age = 0)
{
this.name_ = name;
this.age_ = age;
}
}

void main()
{
auto person = new Person("Saul Kripke");

person.age = 57;

writeln(person.name, ": ", person.age);
}



[Issue 17076] New: [scope] compiling identity function template with -dip1000 causes error

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17076

  Issue ID: 17076
   Summary: [scope] compiling identity function template with
-dip1000 causes error
   Product: D
   Version: D2
  Hardware: x86_64
OS: Windows
Status: NEW
  Keywords: safe
  Severity: normal
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: r.sagita...@gmx.de

With dmd-2.073-beta1, compiling this:

  int identity(T)(T a) { return a; }
  int ii = identity(3);

with "dmd -dip1000 test.d" yields

test.d(1): Error: parameter a is 'return' but function does not return any
indirections

--


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 way to get it to work is rename 5.9 ver to 6.0, 
but then now I get the error


root@DESKTOP:/mnt/b/DLang/ldc2Android# bin/ldmd2 test.d
bin/ldmd2: error while loading shared libraries: 
libncursesw.so.6: cannot open shared object file: No such file or 
directory

root@DESKTOP:/mnt/b/DLang/ldc2Android# bin/ldmd2 test.d
bin/ldmd2: error while loading shared libraries: 
libncursesw.so.6: cannot open shared object file: No such file or 
directory

root@DESKTOP:/mnt/b/DLang/ldc2Android# bin/ldmd2 test.d
bin/ldmd2: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version 
`GLIBCXX_3.4.21' not found (required by bin/ldmd2)

root@DESKTOP:/mnt/b/DLang/ldc2Android# bin/ldc2 test.d
bin/ldc2: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version 
`GLIBCXX_3.4.20' not found (required by bin/ldc2)
bin/ldc2: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version 
`GLIBCXX_3.4.21' not found (required by bin/ldc2)


I followed this page:

http://askubuntu.com/questions/575505/glibcxx-3-4-20-not-found-how-to-fix-this-error

and now I get the error


bin/ldc2: relocation error: bin/ldc2: symbol 
_ZNKSt3_V214error_category10_M_messageB5cxx11Ei, version 
GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time 
reference


even though

strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_DEBUG_MESSAGE_LENGTH

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
Codename:   trusty



Re: Seemingly patternless optlink premature termination

2017-01-08 Thread Jerry via Digitalmars-d

On Sunday, 8 January 2017 at 18:49:50 UTC, Walter Bright wrote:
P.S. Isn't it maddening that Windows doesn't allow copying the 
data from a message window?


A bit more maddening that D is still trying to support optlink, a 
linker that hasn't seen a commit in 2 years when it is hardly bug 
free.


Re: Seemingly patternless optlink premature termination

2017-01-08 Thread jkpl via Digitalmars-d

On Sunday, 8 January 2017 at 18:49:50 UTC, Walter Bright wrote:
P.S. Isn't it maddening that Windows doesn't allow copying the 
data from a message window?


Not really, because you can, Ctrl+C...


Re: Seemingly patternless optlink premature termination

2017-01-08 Thread Stefan Koch via Digitalmars-d

On Sunday, 8 January 2017 at 18:49:50 UTC, Walter Bright wrote:

On 1/8/2017 6:15 AM, pineapple wrote:
I'm working on my dumb library and I have run into a case 
where when I add this
line to a module, I get an optlink error attempting to compile 
it:


unittest{}

The module compiles fine without it. So do the modules which 
depend on it.


But with that line? optlink errors everywhere.

A screencap of the error box that pops up:

http://puu.sh/tfmBK/c5068eb2fb.png

And the contents of stdout:

checkpoint(256)
--- errorlevel 1

I encountered a similar error right before this and eventually 
worked out that I
had introduced a cyclic dependency into my project some time 
ago - strangely not
rearing its head as an error until I made a completely 
unrelated addition to the
tests in a module incidentally importing one of the modules 
involved in that
dependency cycle - and addressing that issue seemed to resolve 
the optlink
error. (At least until I tried to add some extra unit tests to 
one of the

modules involved in that cycle.)

I am utterly failing to find a way to make a simple repro case 
from this, or to
understand what could conceivably be causing this error to 
occur in a module

whose dependency graph is small and simple.



Please post bug reports to bugzilla. I transcribed the error 
here:


EAX=0010
EBX=001C
ECX=
EDX=004337CF
ESI=0044AAE8
EDI=0100
EBP=0018FF54
ESP=0018FDEC
EIP=0040347E
First=00402000

Try to include the code that causes the problem.

The way to debug this (for anyone interested) is to get it to 
fail running under windbg.exe. Then examine the instructions 
around where it failed. Look in the source code to find where 
those instructions are, and hence the location in the code 
where it faulted.


P.S. Isn't it maddening that Windows doesn't allow copying the 
data from a message window?


Any chance to get a debug build of optlink ?



[Issue 17075] New: ctRegex BacktrackingMatcher.prevStack: free(): invalid pointer

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17075

  Issue ID: 17075
   Summary: ctRegex BacktrackingMatcher.prevStack: free(): invalid
pointer
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: normal
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: zor...@gmail.com

Created attachment 1633
  --> https://issues.dlang.org/attachment.cgi?id=1633=edit
Input that triggers the crash

Download http://pastebin.com/raw/UVF41mPf and pipe it into the following:

import std.stdio;
import std.regex;
import std.conv;

enum titlePattern = `(.+)`;
static titleRegex = ctRegex!titlePattern;

void main()
{
auto content = stdin.byLineCopy.to!string;
auto hits = content.matchAll(titleRegex);
}

--

*** Error in `./test': free(): invalid pointer: 0x00f42148 ***
=== Backtrace: =
/usr/lib/libc.so.6(+0x70c4b)[0x7fef85a22c4b]
/usr/lib/libc.so.6(+0x76fe6)[0x7fef85a28fe6]
/usr/lib/libc.so.6(+0x777de)[0x7fef85a297de]
./test(nothrow @nogc @trusted bool
std.regex.internal.backtracking.BacktrackingMatcher!(true).BacktrackingMatcher!(char,
std.regex.internal.ir.Input!(char).Input).BacktrackingMatcher.prevStack()+0x90)[0x4
cd2b8]
[...]

Tested on two machines, both running linux.

--


Re: Alexa Skill written in D

2017-01-08 Thread Walter Bright via Digitalmars-d-announce

On 1/7/2017 5:17 AM, extrawurst wrote:

the last 2 weeks I jumped on a new toy project: An Alexa Skill written in D.


Post this to reddit!


Re: Seemingly patternless optlink premature termination

2017-01-08 Thread Walter Bright via Digitalmars-d

On 1/8/2017 6:15 AM, pineapple wrote:

I'm working on my dumb library and I have run into a case where when I add this
line to a module, I get an optlink error attempting to compile it:

unittest{}

The module compiles fine without it. So do the modules which depend on it.

But with that line? optlink errors everywhere.

A screencap of the error box that pops up:

http://puu.sh/tfmBK/c5068eb2fb.png

And the contents of stdout:

checkpoint(256)
--- errorlevel 1

I encountered a similar error right before this and eventually worked out that I
had introduced a cyclic dependency into my project some time ago - strangely not
rearing its head as an error until I made a completely unrelated addition to the
tests in a module incidentally importing one of the modules involved in that
dependency cycle - and addressing that issue seemed to resolve the optlink
error. (At least until I tried to add some extra unit tests to one of the
modules involved in that cycle.)

I am utterly failing to find a way to make a simple repro case from this, or to
understand what could conceivably be causing this error to occur in a module
whose dependency graph is small and simple.



Please post bug reports to bugzilla. I transcribed the error here:

EAX=0010
EBX=001C
ECX=
EDX=004337CF
ESI=0044AAE8
EDI=0100
EBP=0018FF54
ESP=0018FDEC
EIP=0040347E
First=00402000

Try to include the code that causes the problem.

The way to debug this (for anyone interested) is to get it to fail running under 
windbg.exe. Then examine the instructions around where it failed. Look in the 
source code to find where those instructions are, and hence the location in the 
code where it faulted.


P.S. Isn't it maddening that Windows doesn't allow copying the data from a 
message window?


Re: Alexa Skill written in D

2017-01-08 Thread extrawurst via Digitalmars-d-announce

On Sunday, 8 January 2017 at 16:22:09 UTC, docandrew wrote:

On Saturday, 7 January 2017 at 13:17:35 UTC, extrawurst wrote:

Hi guys,
the last 2 weeks I jumped on a new toy project: An Alexa Skill 
written in D.


It is a skill that allows me to voice control my TV receiver 
with commands like:



[...]


The project and all the source code sits on github:
https://github.com/Extrawurst/alexa-openwebif

I created two new dub libraries that this app uses:
https://github.com/Extrawurst/openwebif-client-d
https://github.com/Extrawurst/alexa-skill-kit-d

*openwebif-client-d* is the REST api that my receiver speaks.
*alexa-skill-kit-d* is the base class and the types that 
amazon throws at when the user activated your skill.


you can find the blog post here:
http://blog.extrawurst.org/programming/dlang/alexa/2017/01/06/alexa-in-d.html

Feel free to share, to spread the word about using D for this 
fancy new tech.


~Stephan


Good work! I've been using my Echo for a little while now and 
it's great to know I can start using D with it! Great write-up 
on the project, thanks for sharing this.


-Doc


Nice, good to know there are just two problems with that:
1) I am on Mac, so no luck here
2) I needed to be as close to the Amazon Linux as possible and 
that unfortunately is rhel based :( did not test Ubuntu though


~stephan


[Issue 17074] extern(C++, keyword) crashes compiler

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17074

Iain Buclaw  changed:

   What|Removed |Added

 CC||ibuc...@gdcproject.org

--- Comment #1 from Iain Buclaw  ---
Putting as regression as adding `extern(C++, nspace)` support would have been
the reason this happens, and it looks like was implemented without proper
handling of syntax errors.

--


[Issue 17074] New: extern(C++, keyword) crashes compiler

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17074

  Issue ID: 17074
   Summary: extern(C++, keyword) crashes compiler
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: regression
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: ibuc...@gdcproject.org

Some random examples, just to show that any tokenized keyword can trigger it.

extern(C++, cast) void crash();
extern(C++, __parameters) void crash();
extern(C++, __MODULE__) void crash();
extern(C++, macro) void crash();
extern(C++, ...) void crash();

--


Re: Alexa Skill written in D

2017-01-08 Thread Andre Pany via Digitalmars-d-announce

On Saturday, 7 January 2017 at 13:17:35 UTC, extrawurst wrote:

Hi guys,
the last 2 weeks I jumped on a new toy project: An Alexa Skill 
written in D.


It is a skill that allows me to voice control my TV receiver 
with commands like:



Alexa, ask Telly to go to standby
Alexa, ask Telly what is currently running


The project and all the source code sits on github:
https://github.com/Extrawurst/alexa-openwebif

I created two new dub libraries that this app uses:
https://github.com/Extrawurst/openwebif-client-d
https://github.com/Extrawurst/alexa-skill-kit-d

*openwebif-client-d* is the REST api that my receiver speaks.
*alexa-skill-kit-d* is the base class and the types that amazon 
throws at when the user activated your skill.


you can find the blog post here:
http://blog.extrawurst.org/programming/dlang/alexa/2017/01/06/alexa-in-d.html

Feel free to share, to spread the word about using D for this 
fancy new tech.


~Stephan


Very interesting article, thanks for sharing. For your info, you 
can directly compile linux binaries from windows 10 by using the 
ubuntu sub system. No need to use vagrant.


Kind regards
André


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 the reference return, but the problem is, that the 
setter does NOT gets called, no matter what the result type of 
the opOpAssign method is.

I want to detect changes, but this way i still not able.

A a = new A;

a.location+=Point(1,1); //the private value changes, but the 
setter does not get called









[Issue 16994] Apparently faulty symbol resolution in some cases

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16994

Martin Nowak  changed:

   What|Removed |Added

 CC||c...@dawg.eu
   Hardware|x86 |All
 OS|Mac OS X|All

--- Comment #1 from Martin Nowak  ---
Indeed changing the implementation of varsum to return the minimum length fixes
the issue.
This could be a bug in dmd's template instantiation cache.
Note that the issue vanishes with 2.072.2, but likely just as a side effect of
some other rearrangements.

--


Re: Vision document for H1 2017

2017-01-08 Thread Brian via Digitalmars-d-announce
On Wednesday, 4 January 2017 at 19:22:33 UTC, Andrei Alexandrescu 
wrote:
We release a brief Vision document summarizing the main goals 
we plan to pursue in the coming six months. This half we are 
focusing on three things: safety, lifetime management, and 
static introspection.


https://wiki.dlang.org/Vision/2017H1


Andrei


Dlang should strive to improve the standard library, such as 
Python, go, rust.


[Issue 16680] dmd doesn't use druntime optimized versions of subtraction array operations

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16680

Rainer Schuetze  changed:

   What|Removed |Added

   Keywords||pull
 CC||r.sagita...@gmx.de

--- Comment #2 from Rainer Schuetze  ---
Templated array ops are likely to take a couple of years, so here's a fix for
this typo: https://github.com/dlang/dmd/pull/6413

--


Re: Seemingly patternless optlink premature termination

2017-01-08 Thread Stefan Koch via Digitalmars-d

On Sunday, 8 January 2017 at 17:14:13 UTC, pineapple wrote:

On Sunday, 8 January 2017 at 14:42:57 UTC, pineapple wrote:
After deciding to let my inability to add some unit tests to 
that module I started working on some other code in the same 
project. At this point it seems completely arbitrary which 
lines produce optlink errors. Since the `unittest{}` issue I 
have, in other modules, had optlink errors occur depending on 
the presence of arbitrary method and function calls, too.


Update from IRC: Stefan was able to determine that this is a 
stack corruption bug with optlink. (How and why I should be the 
one to stumble upon it is yet to be determined.)


No I was able to determine it not.
I think, it could be one.
I'll post it when there is something concrete to post.


Re: Seemingly patternless optlink premature termination

2017-01-08 Thread Stefan Koch via Digitalmars-d

On Sunday, 8 January 2017 at 17:14:13 UTC, pineapple wrote:

On Sunday, 8 January 2017 at 14:42:57 UTC, pineapple wrote:
After deciding to let my inability to add some unit tests to 
that module I started working on some other code in the same 
project. At this point it seems completely arbitrary which 
lines produce optlink errors. Since the `unittest{}` issue I 
have, in other modules, had optlink errors occur depending on 
the presence of arbitrary method and function calls, too.


Update from IRC: Stefan was able to determine that this is a 
stack corruption bug with optlink. (How and why I should be the 
one to stumble upon it is yet to be determined.)


No I was not.
I think! it could be one.
I'll post it when there is something concrete to post.


Re: Vision document for H1 2017

2017-01-08 Thread bitwise via Digitalmars-d-announce

On Saturday, 7 January 2017 at 19:55:30 UTC, Martin Nowak wrote:

On 01/05/2017 11:00 AM, Basile B. wrote:
I don't known what did you decide in intern but when the 
discussion
between users was hot (just after version 2.071.1 I think) 
I've proposed

that:
https://github.com/BBasile/DIPs/blob/3d5e3f81c541c6e23c69555a230b4d42a7bb6de6/DIPs/DIP8484.md


This is superfluous by now. We figured that allowing access to 
private
fields wouldn't clash with important optimizations, so it can 
be allowed

via traits.
The visibility of allMembers was adjusted in
https://github.com/dlang/dmd/pull/6078.
All access checks will go away once the visibility changes have 
been
fully deprecated. So far those changes were adopted fairly slow 
(not
even phobos has fixed them all), hence we haven't yet switched 
over to

the new visibility semantics.

-Martin


Awesome!

I tried to write a whole-module reflection tool, but was unable 
to finish satisfactorily due to the requirement that code 
actually be included in the module itself in order to reflect all 
it's members.


Re: Seemingly patternless optlink premature termination

2017-01-08 Thread pineapple via Digitalmars-d

On Sunday, 8 January 2017 at 14:42:57 UTC, pineapple wrote:
After deciding to let my inability to add some unit tests to 
that module I started working on some other code in the same 
project. At this point it seems completely arbitrary which 
lines produce optlink errors. Since the `unittest{}` issue I 
have, in other modules, had optlink errors occur depending on 
the presence of arbitrary method and function calls, too.


Update from IRC: Stefan was able to determine that this is a 
stack corruption bug with optlink. (How and why I should be the 
one to stumble upon it is yet to be determined.)


Re: Lets talk about fibers

2017-01-08 Thread Dicebot via Digitalmars-d

On Sunday, 8 January 2017 at 09:18:19 UTC, Suliman wrote:
Simply picking a worker thread + worker fiber when task is 
assigned and sticking to it until finished should work good 
enough. It is also important to note though that "fiber" is 
not the same as "task". Former is execution context primitive, 
latter is scheduling abstraction. In fact, heavy load systems 
are likely to have many more tasks than fibers at certain 
spike points.


Could you explain difference between fibers and tasks. I read a 
lot, but still can't understand the difference.


Fiber is context switching primitive very similar to thread. It 
is different from thread in a sense that it is completely 
invisible to operating system and only does context switching 
when explicitly told so in code. But it still can execute 
arbitrary code. When we talk about fibers in D, we usually mean 
https://dlang.org/library/core/thread/fiber.html


Task is abstraction over some specific piece of work to do. Most 
simple task one can think of is simply a function to execute. 
Other details may vary a lot -different languages and libraries 
implement tasks differently, and D standard library doesn't 
define it all. Most widespread task definition in D comes from 
vibe.d - http://vibed.org/api/vibe.core.task/Task


To summarize - fiber defines HOW to execute code but doesn't care 
which code to execute. Task defines WHAT code to execute but 
normally has no assumptions over how exactly it gets run.


Re: Alexa Skill written in D

2017-01-08 Thread docandrew via Digitalmars-d-announce

On Saturday, 7 January 2017 at 13:17:35 UTC, extrawurst wrote:

Hi guys,
the last 2 weeks I jumped on a new toy project: An Alexa Skill 
written in D.


It is a skill that allows me to voice control my TV receiver 
with commands like:



Alexa, ask Telly to go to standby
Alexa, ask Telly what is currently running


The project and all the source code sits on github:
https://github.com/Extrawurst/alexa-openwebif

I created two new dub libraries that this app uses:
https://github.com/Extrawurst/openwebif-client-d
https://github.com/Extrawurst/alexa-skill-kit-d

*openwebif-client-d* is the REST api that my receiver speaks.
*alexa-skill-kit-d* is the base class and the types that amazon 
throws at when the user activated your skill.


you can find the blog post here:
http://blog.extrawurst.org/programming/dlang/alexa/2017/01/06/alexa-in-d.html

Feel free to share, to spread the word about using D for this 
fancy new tech.


~Stephan


Good work! I've been using my Echo for a little while now and 
it's great to know I can start using D with it! Great write-up on 
the project, thanks for sharing this.


-Doc


[Issue 17059] [REG 2.072.2] incorrect circular reference with `is(Klass : Interface)`

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17059

Martin Nowak  changed:

   What|Removed |Added

Summary|[REG 2.072.2] Possible case |[REG 2.072.2] incorrect
   |of wrong circular reference |circular reference with
   ||`is(Klass : Interface)`

--


Re: dmd download spike

2017-01-08 Thread Mengu via Digitalmars-d

On Saturday, 7 January 2017 at 13:52:12 UTC, Benjiro wrote:
On Saturday, 7 January 2017 at 13:22:02 UTC, rikki cattermole 
wrote:
Btw, I based this mostly off the number of newbies coming on 
to IRC. There has been quite a large number :) At least 
compared to the rest of the yar.


Interesting. Maybe it can be useful to get a poll asking the 
new people how they got introduced to D. Especially if this 
correlates top the release. If the release news draws in 
people, maybe it can be interesting to do more increment 
releases ;)


Btw. IRC ... that is so 1999 :)


1999 times better than slack.


Re: Seemingly patternless optlink premature termination

2017-01-08 Thread pineapple via Digitalmars-d

On Sunday, 8 January 2017 at 14:15:26 UTC, pineapple wrote:
I'm working on my dumb library and I have run into a case where 
when I add this line to a module, I get an optlink error 
attempting to compile it:


unittest{}


After deciding to let my inability to add some unit tests to that 
module I started working on some other code in the same project. 
At this point it seems completely arbitrary which lines produce 
optlink errors. Since the `unittest{}` issue I have, in other 
modules, had optlink errors occur depending on the presence of 
arbitrary method and function calls, too.




Seemingly patternless optlink premature termination

2017-01-08 Thread pineapple via Digitalmars-d
I'm working on my dumb library and I have run into a case where 
when I add this line to a module, I get an optlink error 
attempting to compile it:


unittest{}

The module compiles fine without it. So do the modules which 
depend on it.


But with that line? optlink errors everywhere.

A screencap of the error box that pops up:

http://puu.sh/tfmBK/c5068eb2fb.png

And the contents of stdout:

checkpoint(256)
--- errorlevel 1

I encountered a similar error right before this and eventually 
worked out that I had introduced a cyclic dependency into my 
project some time ago - strangely not rearing its head as an 
error until I made a completely unrelated addition to the tests 
in a module incidentally importing one of the modules involved in 
that dependency cycle - and addressing that issue seemed to 
resolve the optlink error. (At least until I tried to add some 
extra unit tests to one of the modules involved in that cycle.)


I am utterly failing to find a way to make a simple repro case 
from this, or to understand what could conceivably be causing 
this error to occur in a module whose dependency graph is small 
and simple.




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.  It was not a CTFE 
problem but one of default initialization of struct fields:

https://issues.dlang.org/show_bug.cgi?id=17073

In short, `void` default initialization seems to take priority 
with dmd regardless of anything else.


Re: [Bench!][Mir] +54%..+185% performance boost for Mersenne Twister.

2017-01-08 Thread Joseph Rushton Wakeling via Digitalmars-d
On Sunday, 8 January 2017 at 13:16:29 UTC, Joseph Rushton 
Wakeling wrote:
I'm asking for eyes on the problem because reducing it to a 
minimal example appears non-trivial, while the bug itself looks 
serious beyond its effect on this PR.


I underestimated myself :-P  Minimal example is as follows:

/
struct Inner
{
uint value = void;  // <=== removing this `void` initializer
// removes the problem
}

struct Outer
{
Inner inner = defaultInner();

static Inner defaultInner()
{
if (!__ctfe) assert(false);
Inner inn;
inn.value = 23;
return inn;
}
}

void main()
{
import std.stdio : writeln;
Outer outer;
outer.inner.writeln;  // outputs `Inner(0)` with dmd
  // but should be `Inner(23)`
  // ldc gets it right ;-)
}
/

So, the bug comes down to priority of default initialization.  
I'll follow an issue later today and fix the PR accordingly.


Re: Lets talk about fibers

2017-01-08 Thread Chris Wright via Digitalmars-d
On Sun, 08 Jan 2017 09:18:19 +, Suliman wrote:

>> Simply picking a worker thread + worker fiber when task is assigned and
>> sticking to it until finished should work good enough. It is also
>> important to note though that "fiber" is not the same as "task". Former
>> is execution context primitive, latter is scheduling abstraction. In
>> fact, heavy load systems are likely to have many more tasks than fibers
>> at certain spike points.
> 
> Could you explain difference between fibers and tasks. I read a lot, but
> still can't understand the difference.

A task is a unit of work to be scheduled.

A fiber is a concurrency mechanism supporting multiple independent 
stacks, like threads, that you can switch between. Unlike threads, a 
fiber continues to execute until it voluntarily yields execution.

You might have a task: send a registration message to a user who just 
registered. That gets scheduled onto a fiber. Your email sending stuff is 
vibe.d all the way down, and also you have to make some database queries. 
The IO involved causes the fiber that the task was scheduled on to yield 
execution several times. Finally, the task finishes, and the fiber can be 
destroyed -- or reused for another task.


Re: [Bench!][Mir] +54%..+185% performance boost for Mersenne Twister.

2017-01-08 Thread Joseph Rushton Wakeling via Digitalmars-d
On Sunday, 8 January 2017 at 02:51:51 UTC, Andrei Alexandrescu 
wrote:
This indicates a compiler bug in dmd itself, so the best 
outcome for this library work would be a reduced compiler bug + 
a simple library workaround. -- Andrei


Yes, that much is clear -- sorry if I wasn't clear enough myself. 
 I'm asking for eyes on the problem because reducing it to a 
minimal example appears non-trivial, while the bug itself looks 
serious beyond its effect on this PR.


For what it's worth:

  * it appears to be a backend issue, not frontend (using dmd 
with the same

frontend as the latest ldc doesn't make a difference);

  * creating an `enum` manifest constant from the CTFE function 
works fine,
but assigning to the runtime struct field from that enum 
produces the

same mostly-zeros result;

  * it definitely doesn't appear to be something as trivial as 
just default
initializing a struct instance (or a struct instance 
including a static

array of more than a certain size) being the problem.

I will keep trying to reduce it to a minimal example, but 
CTFE-related backend bugs are not something I have a lot of 
experience with tracking down, hence the request for help.


Would filing an issue still be helpful at this stage, even 
without a minimal example?


[Issue 12116] dmd -op -od broken

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12116

--- Comment #7 from Timothee Cour  ---
For windows:

 > Please do not forget about Windows - how would you propose handling `dmd -c
-od=mydir -op C:\bla.d D:\bla.d` then? ;)

=> creates:
mydir/C/bla.o
mydir/D/bla.o

but again, as in the proposal user can also write:

dmd -c -od=mydir -op=C:\ C:\bla.d D:\bla.d
=> creates:
mydir/bla.o
mydir/D/bla.o

it's nice and consistent. Another possiblity is to disallow the
combo(windows+op+absolute files), but that doesn't seem necessary.

But whatever is decided on windows, hopefully we can at least do what's
proposed here on mac/linux.

--


[Issue 17027] Add support for tzcnt and lzcnt in x86(64) iasm

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17027

b2.t...@gmx.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--


[Issue 17072] New: [REG 2.073.0-b1] missing symbols with -inline

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17072

  Issue ID: 17072
   Summary: [REG 2.073.0-b1] missing symbols with -inline
   Product: D
   Version: D2
  Hardware: x86_64
OS: Windows
Status: NEW
  Severity: regression
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: r.sagita...@gmx.de

With dmd 2.073.0-beta1, this code

import core.thread;

void main()
{
Thread.sleep(dur!"msecs"(50));  
}

produces a link error:

>dmd.exe test.d -m64 -inline
test.obj : error LNK2019: unresolved external symbol
_D4core4time8Duration46__T10opOpAssignVAyaa1_2dTS4core4time8DurationZ10opOpAssignMFNaNbNcNiNfxS4core4time8DurationZS4core4time8Duration
referenced in function _Dmain

This does not happen with dmd 2.072 or without -inline.

--


[Issue 12116] dmd -op -od broken

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12116

--- Comment #6 from ki...@gmx.net ---
(In reply to Timothee Cour from comment #5)
> * dmd -od=mydir -op /absolute_path/fun.d should write to:
> mydir/absolute_path/fun.o (eg: -od=/tmp/ => /tmp/absolute_path/fun.o)
> 
> this behavior is useful when users don't want to pollute a source repository
> with .o files, or when they want to keep multiple cached versions of object
> files (eg for different compilation options): the current behavior
> (/absolute_path/fun.o) won't allow that.

Please do not forget about Windows - how would you propose handling `dmd -c
-od=mydir -op C:\bla.d D:\bla.d` then? ;)

--


Re: Reminder - DConf 2017 is May 4-6 !!

2017-01-08 Thread Nordlöw via Digitalmars-d-announce

On Saturday, 7 January 2017 at 01:06:49 UTC, Stefan Koch wrote:

new CTFE engine or the future my plan for O(N log N) templates!


What do you mean?
A performance improvement?
From quadratic?


Re: Lets talk about fibers

2017-01-08 Thread Suliman via Digitalmars-d
"The type of concurrency used when logical threads are created is 
determined by the Scheduler selected at initialization time. The 
default behavior is currently to create a new kernel thread per 
call to spawn, but other schedulers are available that multiplex 
fibers across the main thread or use some combination of the two 
approaches" (с) dlang docs


Am I right understand that `concurrency` is just wrapper that 
hide implementation of tasks and fibers? So programmer can work 
with threads like with fibers and vice versa?


If yes, does it's mean that spawns is planing not but with system 
Scheduler, but with DRuntime Scheduler (or how it's can be 
named?) and all of them work in user-space?


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 m_location;
}

This alone solves the immediate problem.

2. Note that it is common for assignment expressions to return a 
reference to the result, which would, for example, make chains 
like "a = (b += c)" possible:


  ref Point opOpAssign(string op)(in Point p) if (op == "+") {
x+=p.x;
y+=p.y;
return this;
  }

Here's a complete working version of your example:

-
struct Point {
  float x=0,y=0;

  this(float _x, float _y) {
x=_x;
y=_y;
  }

  //opopassign for +=
  ref Point opOpAssign(string op)(in Point p) if (op == "+") {
x+=p.x;
y+=p.y;
return this;
  }
}

class A {
  public:
ref Point location() @property {
  return m_location;
}

void location(in Point newlocation) @property {
  m_location=newlocation;
}

  private:
Point m_location;
}

void main() {
  import std.stdio;
  auto a= new A;
  a.location+=Point(1,1);
  writeln (a.location); // Point(1, 1)
  a.location+=Point(1,1);
  writeln (a.location); // Point(2, 2)
}
-

Ivan Kazmenko.


[Issue 17038] support for std.uni store / load trie entry table

2017-01-08 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17038

--- Comment #1 from Remi Thebault  ---
In addition, it should be supported to store the table for both 32 bits and 64
bits.

Currently the Trie.store method outputs D code for the running architecture
only.
64 bits code output cannot compile in 32 bits.
32 bits code output will compile in 64 bits, but will likely give false
results.

And what about endianness?

--


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, I get 
primes, but I have to run with a huge number of iterations to 
actually _get_ a random number.  It runs fast, though.  Why 
might this be?  Code: http://lpaste.net/1034777940820230144


I haven't read your code very exactly, but I have an assumption 
and you can check if it is helpful:)


I think your actual problem is this line:

z = pow(b, m) % integer;

If it does what I think, it can be horribly slow and memory 
consuming. You have to implement your own pow function that does 
a ^ b mod c. Look into python source code or in "tanya" (D): 
https://github.com/caraus-ecms/tanya/blob/master/source/tanya/math/package.d. It is the same algorithm that phobos uses but with modulo operation built-in and a bit differently written (my code is based neither on python nor on phobos and uses a different bigint implementation). You can also rewrite pow(z, 2) % integer then. It will be faster.

Try to reduce bigint copying and arithmetic anyway if possible.


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 A {
  public:
Point location() const @property {
  return m_location;
}

void location(in Point newlocation) @property {
  m_location=newlocation;
}

  private:
Point m_location;
}

void main() {
  auto a= new A;
  a.location=a.location+Point(1,1); //DOES WORK
  a.location+=Point(1,1); //DOESN'T WORK
}



The problem is that this code is not working. The getter and the 
opOpAssign gets called, but the setter does not.

How can i do opOpAssign with properties??



  1   2   >