Re: code.dlang.org internal server error

2017-02-09 Thread Daniel Kozak via Digitalmars-d

Dne 10.2.2017 v 07:27 puming via Digitalmars-d napsal(a):


On Thursday, 9 February 2017 at 12:19:12 UTC, Daniel Kozák wrote:

V Thu, 9 Feb 2017 11:54:05 +0100
Sönke Ludwig via Digitalmars-d  napsáno:


[...]


In general issue is not with connectivity to China but with
GFW (https://en.wikipedia.org/wiki/Great_Firewall), So you would need
some VPS inside china, unfortunately AFAIK all VPS inside Hong Kong are
outside of GFW so it is still posible it would not help.

But in our company we have VPS inside GFW (for our chinese customers),
so maybe I could ask if they dont mind to provide it for dub
mirror purpose


Yes, GFW is the main problem. What's more, to setup a HTTP site in 
China, one has to file for permission from the govt.
Yes, we have ICP number, so in theory it should be possible to make 
mirror in China


Re: D IDE Coedit - version 3 beta 3

2017-02-09 Thread Basile B. via Digitalmars-d-announce

On Friday, 27 January 2017 at 04:48:56 UTC, Basile B. wrote:
This would probably have been a RC or even the final version if 
I hadn't to wait for the development platform I use to reach 
its next milestone, which may not happen before the next 
spring, so another beta is worth.


All important information, links and other downloads are here:
https://github.com/BBasile/Coedit/releases/tag/3_beta_3

You can report any problem here:
https://github.com/BBasile/Coedit/issues

If you have questions, exactly today, I'll probably be there:
irc://irc.freenode.net/d as "DotBatch"


Yet another update...should be of interest for those who tried D 
for the first time, using CE and experienced a crash


https://www.reddit.com/r/d_language/comments/5t5oum/d_ide_coedit_version_3_beta_4/


Re: code.dlang.org internal server error

2017-02-09 Thread puming via Digitalmars-d

On Thursday, 9 February 2017 at 12:19:12 UTC, Daniel Kozák wrote:

V Thu, 9 Feb 2017 11:54:05 +0100
Sönke Ludwig via Digitalmars-d  
napsáno:



[...]


In general issue is not with connectivity to China but with
GFW (https://en.wikipedia.org/wiki/Great_Firewall), So you 
would need
some VPS inside china, unfortunately AFAIK all VPS inside Hong 
Kong are

outside of GFW so it is still posible it would not help.

But in our company we have VPS inside GFW (for our chinese 
customers),

so maybe I could ask if they dont mind to provide it for dub
mirror purpose


Yes, GFW is the main problem. What's more, to setup a HTTP site 
in China, one has to file for permission from the govt.


[Issue 17172] New: redundant `statement is not reachable`: should only show 1 per code block

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17172

  Issue ID: 17172
   Summary: redundant `statement is not reachable`: should only
show 1 per code block
   Product: D
   Version: D2
  Hardware: x86
OS: Mac OS X
Status: NEW
  Severity: normal
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: timothee.co...@gmail.com

D20170209T222632

dmd -c -o- -w test.d:
```
void test(){
  version(linux) return;
  int a=1;
  int b=1;
}
```
test.d(1): Warning: statement is not reachable
test.d(2): Warning: statement is not reachable

Expected:
test.d(1): Warning: statement is not reachable
The 2nd warning is in the same code block so is redundant. This is annoying:

* when debugging and doing an early return as shown, it can show tons of
warnings (masking more useful ones)

* the workaround is to use:

version(none){
  // unused code
}

but it has issues:

- increases indentation

- the code is no longer checked for being compilable, and after a while becomes
out of sync.

--


Re: code.dlang.org internal server error

2017-02-09 Thread puming via Digitalmars-d

On Thursday, 9 February 2017 at 10:54:05 UTC, Sönke Ludwig wrote:

Am 09.02.2017 um 03:34 schrieb puming:
On Wednesday, 8 February 2017 at 14:11:48 UTC, Sönke Ludwig 
wrote:

[...]


I have a VPS slot in Hong Kong for personal use, with 1GB 
memory, 30GB

disk and 300GB monthly bandwidth. Is that OK for a mirror site?


That should work! Considering that connectivity from my VPS to 
China generally appears to be sub optimal, that would be good 
to have as an alternative anyway.


We just need to implement a mirror mode, where user and package 
management is disabled and updates are pulled from 
code.dlang.org instead of from github directly.


When you get mirror mode working, please make an anouncement so 
that I can contact you about setting up the mirror. I can afford 
to increase VPS capacity to 2GB Mem/60GB disc or something 
similar if neccessary.





[Issue 9695] Ddoc should emit enum member initializers

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9695

Timothee Cour  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 CC||timothee.co...@gmail.com
 Resolution|WONTFIX |---

--- Comment #6 from Timothee Cour  ---
This causes issues because of https://issues.dlang.org/show_bug.cgi?id=129
(DDoc downgrades enum to their integer initializers); I also discuss this in
https://issues.dlang.org/show_bug.cgi?id=17171

--


[Issue 129] DDoc downgrades enum to their integer initializers

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=129

Timothee Cour  changed:

   What|Removed |Added

Summary|DDoc makes enum values  |DDoc downgrades enum to
   |cryptic |their integer initializers

--


[Issue 129] DDoc makes enum values cryptic

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=129

--- Comment #11 from Timothee Cour  ---
(In reply to Timothee Cour from comment #10)
> https://dlang.org/library/std/process/pipe_process.html
> shows:
> 
> ProcessPipes pipeProcess( 
>   const(char[][]) args, 
>   Redirect redirect = cast(Redirect)7, 
>   const(string[string]) env = cast(const(string[string]))null, 
>   Config config = cast(Config)0, 
>   const(char[]) workDir = null 
> ) @safe; 
> 
> 
> with
> 
> cast(Redirect)7, 
> 
> instead of 
> 
> Redirect redirect = Redirect.all,
> 
> as in source code

what's worse is that https://issues.dlang.org/show_bug.cgi?id=9695 was marked
as wontfix, making it impossible to lookup enum values for an integer

Also discussed here: https://issues.dlang.org/show_bug.cgi?id=17171

--


[Issue 17171] New: ddoc: enum misses some values + wrong order + missing member initializers

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17171

  Issue ID: 17171
   Summary: ddoc: enum misses some values + wrong order + missing
member initializers
   Product: D
   Version: D2
  Hardware: x86
OS: Mac OS X
Status: NEW
  Severity: critical
  Priority: P1
 Component: tools
  Assignee: nob...@puremagic.com
  Reporter: timothee.co...@gmail.com

std.process.d:
```
enum Config
{
none = 0,
...
}
```

https://dlang.org/library/std/process/config.html:

* A1 the `none` entry doesn't appear.

* A2 the entries are out of order

* A3 the automatic splitting with a hyphen (re-tain-Stderr) is very annoying,
at least use a bigger margin than 6

* A4 the member initializers are not shown
For A4, https://issues.dlang.org/show_bug.cgi?id=9695 was marked as closed
however it's very arguable, it could be part of documentation (even if with a
CAVEAT mentioning implementation detail); for example: I reopened
https://issues.dlang.org/show_bug.cgi?id=129 because the enums in ddoc are
downgraded to their integral counterparts, which creates a catch 22 situation,
since we can't look up the enum values from ddoc because of A4 !

--


[Issue 17170] New: ddoc shows parameters that are not used in function

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17170

  Issue ID: 17170
   Summary: ddoc shows parameters that are not used in function
   Product: D
   Version: D2
  Hardware: x86
OS: All
Status: NEW
  Severity: normal
  Priority: P1
 Component: tools
  Assignee: nob...@puremagic.com
  Reporter: timothee.co...@gmail.com

https://dlang.org/library/std/process/pipe_process.html
shows

shellPathThe path to the shell to use to run the specified program. By
default this is nativeShell.

but shellPath isn't used in pipeProcess:

ProcessPipes pipeProcess( 
  const(char[][]) args, 
  Redirect redirect = cast(Redirect)7, 
  const(string[string]) env = cast(const(string[string]))null, 
  Config config = cast(Config)0, 
  const(char[]) workDir = null 
) @safe; 

ProcessPipes pipeProcess( 
  const(char[]) program, 
  Redirect redirect = cast(Redirect)7, 
  const(string[string]) env = cast(const(string[string]))null, 
  Config config = cast(Config)0, 
  const(char[]) workDir = null 
) @safe;


https://issues.dlang.org/show_bug.cgi?id=13270 is related but different

--


[Issue 129] DDoc makes enum values cryptic

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=129

Timothee Cour  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 CC||timothee.co...@gmail.com
Version|D1 (retired)|D2
 Resolution|FIXED   |---

--- Comment #10 from Timothee Cour  ---
https://dlang.org/library/std/process/pipe_process.html
shows:

ProcessPipes pipeProcess( 
  const(char[][]) args, 
  Redirect redirect = cast(Redirect)7, 
  const(string[string]) env = cast(const(string[string]))null, 
  Config config = cast(Config)0, 
  const(char[]) workDir = null 
) @safe; 


with

cast(Redirect)7, 

instead of 

Redirect redirect = Redirect.all,

as in source code

--


Re: Best error msg ever

2017-02-09 Thread Era Scarecrow via Digitalmars-d

On Friday, 10 February 2017 at 02:53:50 UTC, Era Scarecrow wrote:
Seems the built in Date class wasn't the same as the Sql.Date 
that was being used (but had the same name). Apparently it took 
like 2 hours to figure out what was going on.


 Oh right forgot to mention one important detail. In Java the 
program compiled without errors; It was when it was trying to be 
used that it would crash unexpectedly. Refusing to compile is 
slightly better than crashing unexpectedly later.


Re: Best error msg ever

2017-02-09 Thread Era Scarecrow via Digitalmars-d

On Friday, 10 February 2017 at 03:07:28 UTC, Adam D. Ruppe wrote:
They do have different full names, which includes the module 
name and uniquely differentiates them. The compiler knows it 
too, just isn't smart enough to actually display it in times 
like this.


So maybe when the class name along can be ambiguous program it to 
give a full or non-ambiguous path for which class/structs they 
actually are? Seems like it would be a 1-2 line change...


Re: Getting familiar with std.process

2017-02-09 Thread jmh530 via Digitalmars-d-learn

On Thursday, 9 February 2017 at 21:36:46 UTC, Ali Çehreli wrote:

On 02/09/2017 12:44 PM, jmh530 wrote:

> I think the issue is that create_file doesn't write to
stdout, it writes
> to file.

Correct. Pipe works by piping the standard input/output streams.

> Other than reading the file and then deleting it, I don't know
> what else to try.

create_file must write to its stdout.

Ali


If only it were that easy. It's not my program writing to file, 
it's some one I didn't write. This was just sort of a beta test. 
I might need to look into the program a bit more.




Re: Best error msg ever

2017-02-09 Thread Adam D. Ruppe via Digitalmars-d

On Friday, 10 February 2017 at 02:53:50 UTC, Era Scarecrow
 In cases like these i really wish the structure of the 
class/struct had a hash or something (based on source or struct 
layout or something)


They do have different full names, which includes the module name 
and uniquely differentiates them. The compiler knows it too, just 
isn't smart enough to actually display it in times like this.


Re: Best error msg ever

2017-02-09 Thread Era Scarecrow via Digitalmars-d

On Thursday, 9 February 2017 at 21:28:58 UTC, Sönke Ludwig wrote:

Am 09.02.2017 um 22:20 schrieb Daniel Kozak:
source/app.d(51,37): Error: function 
dub.internal.utils.jsonFromFile (Path file, bool silent_fail = 
false) is not callable using argument types (Path, bool)


WTF?


Must be caused by Path meaning two different type definitions.


 I'll have to agree. Back in ... 2009? I was in a company where 
we were doing web development for a bit, and one curious error 
that came up was when trying to assign or work with the Date 
object. Seems the built in Date class wasn't the same as the 
Sql.Date that was being used (but had the same name). Apparently 
it took like 2 hours to figure out what was going on.


 In cases like these i really wish the structure of the 
class/struct had a hash or something (based on source or struct 
layout or something) to help differentiate it rather than just by 
name, and reverse lookup the exact file location(s) of where the 
struct in question comes from.


Re: Have some down time at the year's end?

2017-02-09 Thread Andrei Alexandrescu via Digitalmars-d

On 02/09/2017 05:03 PM, Daniel Kozak wrote:

Is this still accurate? I mean if I change some issue to "trivial", is
there any process which will notify you or your students about it? Or
are they actively watch this list?


There is no automation. Thanks! -- Andrei



Re: DWT Support Docs for Windows

2017-02-09 Thread JamesD via Digitalmars-d-dwt
On Wednesday, 8 February 2017 at 14:45:44 UTC, Jacob Carlborg 
wrote:

On 2017-02-07 22:48, JamesD wrote:
I'm a programming hobbyist and I'm new to the D language.  
I've recently
struggled to get a GUI working on Windows. I finally made some 
progress,
and have created a few docs that I hope will help others.  
Constructive

feedback is welcome.

The following are on https://github.com/jasc2v8/dwt-support 
under \doc:


1. Why use the DWT GUI for the D Language
2. Config DWT GUI for Eclipse DDT on Windows
3. Build DWT 64 bit on Windows


That's great. A few comments:

* Since DMD 2.073.0 (I believe) Dub is included

* I don't know how the dub.json file that DDT creates looks 
like. But usually with Dub you build a release build with the 
following command: "dub build -b release". See "dub build -h" 
for more information, there are some other build types 
available as well


* About the disadvantages, in my opinion, native widgets is an 
advantage. I guess there are two kinds of people, those that 
like native widgets and those who don't


Thank you for your constructive feedback - very much appreciated!

You are correct, the DMD download includes DUB, I updated the doc.
(I noticed that DMD also prompts to download VS if you require 
64bit support)


The Eclipse DDT plugin creates a shell dub.json.  My doc "Config 
DWT GUI for Eclipse DDT on Windows" shows how to edit this 
dub.json to reference the DWT imports and libraries.


The Eclipse DDT plugin basically executes the "dub build -b" 
command.  By default, it is the debug version.  Also by default, 
dub reads the dub.json file so the app.d can link to the DWT 
libraries.


The user can certainly execute the commands manually or in a 
windows batch file - I'm working on another doc for that process 
as well.


I agree with you about the native widgets, so I updated my other 
doc as well.




Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread Mike Parker via Digitalmars-d-learn

On Thursday, 9 February 2017 at 16:20:29 UTC, berni wrote:
dmd only compiles in the files you actually pass to it. rdmd 
will try to find the required files automatically.


Since you didn't pass the file with the function to dmd, it 
knows it exists, but leaves it out of the final link (it 
assumes it might come from a library or something). That's why 
you see the error.


Ah ok, I understand. So calling with "dmd Special/special.d 
Common/common.d" works.


But when I compile common.d to common.o (with dmd -c common.d) 
and remove common.d after that is there still a possibility to 
link? The obvious doesn't work:


$> dmd Special/special.d Common/common.o Special/special.d(4): 
Error: module common is in file 'common.d' which cannot be read

import path[0] = /usr/include/dmd/phobos
import path[1] = /usr/include/dmd/druntime/import


This is not a linker error. It's a compiler error. You need 
common.d for the import, so the compiler can know which symbols 
are available. For any modules you import, you need either the 
original source file (.d) or a D interface (header) file (.di) 
which contains the type & function declarations and any template 
implementations you need.


[Issue 9631] Error message not using fully qualified name when appropriate.

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9631

Jack Stouffer  changed:

   What|Removed |Added

   Keywords||trivial
 CC||j...@jackstouffer.com

--


[Issue 17169] New: New default ddoc theme merges all paragraphs except the first

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17169

  Issue ID: 17169
   Summary: New default ddoc theme merges all paragraphs except
the first
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: normal
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: cbkbbej...@mailinator.com

doccomment.d:
-
/++
P1

P2

P3
+/
void foo(){}
-

Compile:
$ dmd -Xf=doccomment.json -Dfdoccomment.html -c doccomment.d

The resulting JSON is ok, same as it's always been, but with the new default
theme, the HTML fails to make P2 and P3 into separate paragraphs:

-

  Discussion
  
P2


P3
  

-

--


Re: two points

2017-02-09 Thread Mike via Digitalmars-d-announce
On Thursday, 9 February 2017 at 17:45:15 UTC, Nick Sabalausky 
wrote:


No. There should be appropriate checks and reviews, yes. But, 
no, every little fix and improvement shouldn't feel like trying 
to get somewhere in a year-long tabs vs spaces debate or making 
a big-budget sales pitch to Indecisives Anonymous.


Yep! There are currently 165 poor sinners in DMD PR purgatory.  
The oldest is going on 5 years, waiting on someone to make a 
decision whether to use "-version", "-versions", "-dversion", or 
"-version=?".  Then, it would have to be rebased, and languish 
again for another indeterminate amount of time.  I wouldn't be at 
all surprised if the original contributor has moved on; I would 
have 4 years ago.


Mike



Re: Questionnaire

2017-02-09 Thread Nicholas Wilson via Digitalmars-d-announce

On Thursday, 9 February 2017 at 17:28:47 UTC, jmh530 wrote:
I would probably say libraries is most important. Mir is a 
great advance. I've been applauding your work all the way 
through. There are two things that I think Mir needs most (and 
we've talked about them before as things you were thinking 
about) and then a third is a nice-to-have

1) A higher level layer with more convenient syntax for Mir-Glas
2) Lapack support (eigenvalues, svd, & cholesky/qr 
decompositions)
3) D compute support (would be nice to easily offload big 
computations to GPU)


number 3 is in the pipeline. LDC should be able to produce .ptx 
and .spv (the intermediate formats for CUDA and OpenCL 
respectively, with host code all at the same time!) RealSoon™ (I 
hope by the end of the month).


From there it's all just plain D API bashing, which will be 
easily automated with .mangleof and templates.


I am hoping to give a DConf talk about this.


Re: two points

2017-02-09 Thread Walter Bright via Digitalmars-d-announce

On 2/9/2017 1:45 PM, Jon Degenhardt wrote:

However, when a PR
associated with the issue is created, the ticket itself is normally not updated
until after the review is finished and the PR closed, to late to help out.


It normally is. I do it for all mine and for others I notice that have not so.



Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Era Scarecrow via Digitalmars-d-learn

On Thursday, 9 February 2017 at 19:39:49 UTC, Nestor wrote:
OK I changed the approach using a multidimensional array for 
the matrix so I could ditch arithmetic operations altogether, 
but curiously after measuring a few thousand runs of both 
implementations through avgtime, I see no noticeable 
difference. Why?


 Truthfully, because you'll need tens of millions or hundreds of 
millions in length to determine if it makes a difference and how 
much. Addition, subtraction and simple memory lookups take very 
little time, and since the entire array (100 bytes) fits in the 
cache, it is going to perform very very very well regardless if 
you can optimize it further.


 If you tested this on a much slower system, say an 8bit 6502 the 
differences would be far more pronounced, but not that much 
different.


 Since the algorithm is more or less O(n) optimizing it won't 
make many differences.


 It's possible you could get a speedup by making them ints 
instead of chars, since then it might not have a penalty for the 
'address not divisible by 4' that applies (which is more for ARM 
architectures and less for x86).


 Other optimizations could be to make it multiple levels, taking 
the basic 100 elements and expanding them 2-3 levels deep in a 
lookup and having it do it in more or less a single operation. 
(100 bytes for 1 level, 10,000 for 2 levels, 1,000,000 for 3 
levels, 100,000,000 for 4 levels, etc), but the steps of 
converting it to the array lookup won't give you that much gain, 
although fewer memory lookups but none of them will be cached, so 
any advantage from that is probably lost. Although if you bump up 
the size to 16x10 instead of 10x10, you could use a shift instead 
of *10 which will make that slightly faster (there will be unused 
empty padded spots)


 In theory if you avoid the memory lookup at all, you could gain 
some amount of speed, depending on how it searches a manual 
table, although using a switch-case and a mixin to do all the 
details it feels like it wouldn't give you any gain...


 Division operations are the slowest operations you can do, but 
otherwise most instructions run really fast. Unless you're trying 
to get it smaller (fewer bytes for the call) or shaving for speed 
by instruction cycle counting (like on the 6502) i doubt you'll 
get much benefit.


Re: two points

2017-02-09 Thread Walter Bright via Digitalmars-d-announce

On 2/9/2017 1:06 PM, Joseph Rushton Wakeling wrote:

On Thursday, 9 February 2017 at 20:43:00 UTC, Walter Bright wrote:

*Anyone* in this community can step up and do that.


Anyone can make observations and proposals, but not everyone has the authority
to effect change.


Anyone can proactively look at, review, analyze, etc. any PR.



I appreciate how frustrating it must be to have people saying, 'Hey, do this!
Do that!' without necessarily volunteering their own efforts in support, but
organizational improvements so very often fail unless they are eagerly pursued
at a leadership level.


There are 29 people with commit privileges on Phobos:

  https://github.com/orgs/dlang/teams/team-phobos

What do you suggest? What are you willing to step up and do?


[Issue 17161] [REG 2.072.2] Massive Regex Slowdown

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17161

--- Comment #5 from Jack Stouffer  ---
(In reply to Dmitry Olshansky from comment #3)
> Will investigate the R-T issue, C-T is (sadly) to be expected.

Is there anyway to revert the CT regex to 2.072 behavior? It would be great if
a performance regression of this size on one of the selling points of D could
be fixed immediately.

--


Re: Multiplayer Game Project

2017-02-09 Thread sarn via Digitalmars-d
I do consulting based in Sydney.  Feel free to contact me if you 
ever need any more help.

s...@theartofmachinery.com


[Issue 17161] [REG 2.072.2] Massive Regex Slowdown

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17161

--- Comment #4 from Dmitry Olshansky  ---
(In reply to Dmitry Olshansky from comment #3)
> (In reply to Jack Stouffer from comment #2)
> > Bad news: I see a similar performance decrease for run-time regex as well.
> > 
> > # 2.073.0
> > $ dmd -O -inline -release test2.d && cat input500.txt | time ./test2
> > ./test2  4.44s user 0.09s system 98% cpu 4.591 total
> > 
> > # 2.072.2
> > ~/digger/result/bin/dmd -O -inline -release test2.d && cat input500.txt
> > | time ./test2
> > ./test2  3.20s user 0.09s system 98% cpu 3.344 total
> > 
> > I consistently get around a second and a half longer run time with 2.073.
> > 
> 
> This is interesting find, thanks for sharing!
> 
> Will investigate the R-T issue, C-T is (sadly) to be expected.

Mystery solved - in R-T version regex is parsed at C-T (because of static)
therefore the disabling of Kickstart affect it too.

--


[Issue 17161] [REG 2.072.2] Massive Regex Slowdown

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17161

Dmitry Olshansky  changed:

   What|Removed |Added

 CC||dmitry.o...@gmail.com

--- Comment #3 from Dmitry Olshansky  ---
(In reply to Jack Stouffer from comment #2)
> Bad news: I see a similar performance decrease for run-time regex as well.
> 
> # 2.073.0
> $ dmd -O -inline -release test2.d && cat input500.txt | time ./test2
> ./test2  4.44s user 0.09s system 98% cpu 4.591 total
> 
> # 2.072.2
> ~/digger/result/bin/dmd -O -inline -release test2.d && cat input500.txt
> | time ./test2
> ./test2  3.20s user 0.09s system 98% cpu 3.344 total
> 
> I consistently get around a second and a half longer run time with 2.073.
> 

This is interesting find, thanks for sharing!

Will investigate the R-T issue, C-T is (sadly) to be expected.

--


Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Daniel Kozak via Digitalmars-d-learn

Dne 9.2.2017 v 23:08 Ali Çehreli via Digitalmars-d-learn napsal(a):


On 02/09/2017 02:04 PM, Nestor wrote:

> I tried running each algoritm a few times through avgtime using
> different digit lengths

avgtime profiles the whole process, right? It measures everything that 
is involved in that little program. At least OS starting the program, 
D runtime initializing, program interacting with the console, etc.


Since you're comparing algorithms, you need to take everything else 
out of the equation. A better approach is to use 
std.datetime.benchmark, which would repeat just the algorithm that 
you're interested in.


Ali

Yes this is important, and for example when you used shared libphobos it 
makes really big difference


Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Ali Çehreli via Digitalmars-d-learn

On 02/09/2017 02:04 PM, Nestor wrote:

> I tried running each algoritm a few times through avgtime using
> different digit lengths

avgtime profiles the whole process, right? It measures everything that 
is involved in that little program. At least OS starting the program, D 
runtime initializing, program interacting with the console, etc.


Since you're comparing algorithms, you need to take everything else out 
of the equation. A better approach is to use std.datetime.benchmark, 
which would repeat just the algorithm that you're interested in.


Ali



Re: Have some down time at the year's end?

2017-02-09 Thread Daniel Kozak via Digitalmars-d
On Friday, 23 December 2016 at 19:50:03 UTC, Andrei Alexandrescu 
wrote:
My students and I are making a pass through a bunch of bugzilla 
issues closing the ones that ought to be closed and marking the 
simple ones with the "trivial" bug.


https://issues.dlang.org/buglist.cgi?bug_status=UNCONFIRMED_status=NEW_status=ASSIGNED_status=REOPENED_status=VERIFIED=dlang.org=dmd=druntime=installer=phobos=tools=visuald=trivial%2C%20_type=allwords_id=212553=D_format=advanced=---=D2

The list is likely to grow so refresh often. If you have some 
down time this time of the year, you may want to take a look at 
fixing some of them. Happy Holidays!



Thanks,

Andrei


Is this still accurate? I mean if I change some issue to 
"trivial", is there any process which will notify you or your 
students about it? Or are they actively watch this list?


Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Nestor via Digitalmars-d-learn

On Thursday, 9 February 2017 at 21:43:08 UTC, Daniel Kozak wrote:

Any idea of what might be happening here?

Did you try it with different backends? llvm (ldc), gcc(gdc)?


Not really, just standard dmd.

I tried running each algoritm a few times through avgtime using 
different digit lengths (upto 10,000, my PC won't handle much 
more) and different amount of repetitions, and the results aren't 
consistent, some times one algorithm is marginally faster, 
sometimes the other. Apparently the compiler is capable of 
optimizing the unidimensional array version.


Thank you all nevertheless for the suggestions.


[Issue 9631] Error message not using fully qualified name when appropriate.

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9631

--- Comment #9 from Daniel Kozak  ---
Maybe we could change this to trivial?
I belive it is not hard to fix this. I can do it my self if there is no one
else willing to do.

--


[Issue 9631] Error message not using fully qualified name when appropriate.

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9631

Daniel Kozak  changed:

   What|Removed |Added

 CC||kozz...@gmail.com

--- Comment #8 from Daniel Kozak  ---
Bump to same error today:
http://forum.dlang.org/post/xpmpakmusudanwuzz...@forum.dlang.org

--


Re: Best error msg ever

2017-02-09 Thread Daniel Kozak via Digitalmars-d

Dne 9.2.2017 v 22:36 Stefan Koch via Digitalmars-d napsal(a):


On Thursday, 9 February 2017 at 21:31:48 UTC, Daniel Kozak wrote:

Dne 9.2.2017 v 22:20 Daniel Kozak via Digitalmars-d napsal(a):

source/app.d(51,37): Error: function dub.internal.utils.jsonFromFile 
(Path file, bool silent_fail = false) is not callable using argument 
types (Path, bool)


WTF?
Problem is with multiple Path declaration, but with this error 
message it is really hard to find out which one. Maybe it would be 
better to show full names of symbol


please do submit an request for this,
It would be probably duplicate of this one 
https://issues.dlang.org/show_bug.cgi?id=9631


Re: two points

2017-02-09 Thread Jon Degenhardt via Digitalmars-d-announce
On Thursday, 9 February 2017 at 16:48:16 UTC, Joseph Rushton 
Wakeling wrote:
There's clearly in part a scaling problem here (in terms of how 
many people are available in general, and in terms of how many 
people have expertise on particular parts of the library) but 
it also feels like a few simple things (like making sure every 
PR author is given a reliable contact or two who they can feel 
entitled to chase up) could make a big difference.


Regarding the scaling problem - Perhaps the bug system could be 
used to help engage a wider community of reviewers. Specifically, 
update the bugzilla ticket early in the PR lifecycle as an 
alerting mechanism.


This idea comes from my experiences so far. I've found any number 
of bugs and enhancements in the bug system that directly interact 
with things I'm implementing. I typically add myself to CC list 
so I hear about changes. In many of these cases I'd be willing to 
help with reviewing. However, when a PR associated with the issue 
is created, the ticket itself is normally not updated until after 
the review is finished and the PR closed, to late to help out.


Of course, someone like myself, a part-timer to the community at 
best, should not be a primary reviewer. However, for specific 
issues, it's often the case that I've studied the area of code 
involved. If there is a wider set of people in a similar 
situation perhaps this might help engage a wider set of people.


--Jon


Re: Best error msg ever

2017-02-09 Thread Daniel Kozak via Digitalmars-d

Dne 9.2.2017 v 22:28 Sönke Ludwig via Digitalmars-d napsal(a):


Am 09.02.2017 um 22:20 schrieb Daniel Kozak:

source/app.d(51,37): Error: function dub.internal.utils.jsonFromFile
(Path file, bool silent_fail = false) is not callable using argument
types (Path, bool)

WTF?


Must be caused by Path meaning two different type definitions. The 
most likely cause is that by default the DUB sources use their own 
version of Path, while if vibe.d is available in the dependency graph, 
they will use the ones defined there instead.


But the error message is indeed awful.
Yes, btw it is impossible to build https://github.com/dlang/dub-registry 
right now because of this


Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Daniel Kozak via Digitalmars-d-learn

Dne 9.2.2017 v 22:29 Nestor via Digitalmars-d-learn napsal(a):


On Thursday, 9 February 2017 at 20:46:06 UTC, Daniel Kozak wrote:

Maybe you can try use static array instead of dynamic
static immutable ubyte[10][10] QG10Matrix = ...


I shaved it to this to discard unneccessary time-consuming functions:

static immutable ubyte[10][10] QG10Matrix = [
  [0,3,1,7,5,9,8,6,4,2],[7,0,9,2,1,5,4,8,6,3],
  [4,2,0,6,8,7,1,3,5,9],[1,7,5,0,9,8,3,4,2,6],
  [6,1,2,3,0,4,5,9,7,8],[3,6,7,4,2,0,9,5,8,1],
  [5,8,6,9,7,2,0,1,3,4],[8,9,4,5,3,6,2,0,1,7],
  [9,4,3,8,6,1,7,2,0,5],[2,5,8,1,4,3,6,7,9,0],
];

static immutable string number =
"0123456789012345678901234567890123456789012345678901234567890123456789";

static int charToInt(char chr) {
  return ((chr >= '0') || (chr <= '9')) ? cast(int)(chr - '0') : -1;
}

ubyte checkDigit(string str) {
  ubyte tmpdigit;
  foreach(chr; str) tmpdigit = QG10Matrix[tmpdigit][charToInt(chr)];
  return tmpdigit;
}

void main() {
  auto digit = checkDigit(number);
}

I even tried making checkDigit static, but surprisingly this increased 
average execution time by 1ms.


Anyway, the previopus version (modified to benefit from a little 
optimization too) is almost as performant, even though it includes 
multiplication and sum:


static immutable char[] QG10Matrix =
  "03175986427092154863420687135917509834266123045978" ~
  "36742095815869720134894536201794386172052581436790";

static immutable string number =
"0123456789012345678901234567890123456789012345678901234567890123456789";

static int charToInt(char chr) {
  return ((chr >= '0') || (chr <= '9')) ? cast(int)(chr - '0') : -1;
}

char checkDigit(string str) {
  char tmpdigit = '0';
  foreach(chr; str) tmpdigit =
QG10Matrix[charToInt(chr) + (charToInt(tmpdigit) * 10)];
  return tmpdigit;
}

void main() {
  auto digit = checkDigit(number);
}

I compiled both with -inline -noboundscheck -release and the 
multidimensional array version does perform 1ms faster for a couple 
hundred runs, but I expected the difference to be much more noticeable.


Any idea of what might be happening here?

Did you try it with different backends? llvm (ldc), gcc(gdc)?


Re: Best error msg ever

2017-02-09 Thread Stefan Koch via Digitalmars-d

On Thursday, 9 February 2017 at 21:31:48 UTC, Daniel Kozak wrote:

Dne 9.2.2017 v 22:20 Daniel Kozak via Digitalmars-d napsal(a):

source/app.d(51,37): Error: function 
dub.internal.utils.jsonFromFile (Path file, bool silent_fail = 
false) is not callable using argument types (Path, bool)


WTF?
Problem is with multiple Path declaration, but with this error 
message it is really hard to find out which one. Maybe it would 
be better to show full names of symbol


please do submit an request for this,


Re: Getting familiar with std.process

2017-02-09 Thread Ali Çehreli via Digitalmars-d-learn

On 02/09/2017 12:44 PM, jmh530 wrote:

> I think the issue is that create_file doesn't write to stdout, it writes
> to file.

Correct. Pipe works by piping the standard input/output streams.

> Other than reading the file and then deleting it, I don't know
> what else to try.

create_file must write to its stdout.

Ali



Re: Best error msg ever

2017-02-09 Thread Daniel Kozak via Digitalmars-d

Dne 9.2.2017 v 22:20 Daniel Kozak via Digitalmars-d napsal(a):

source/app.d(51,37): Error: function dub.internal.utils.jsonFromFile 
(Path file, bool silent_fail = false) is not callable using argument 
types (Path, bool)


WTF?
Problem is with multiple Path declaration, but with this error message 
it is really hard to find out which one. Maybe it would be better to 
show full names of symbol


Re: Best error msg ever

2017-02-09 Thread Sönke Ludwig via Digitalmars-d

Am 09.02.2017 um 22:20 schrieb Daniel Kozak:

source/app.d(51,37): Error: function dub.internal.utils.jsonFromFile
(Path file, bool silent_fail = false) is not callable using argument
types (Path, bool)

WTF?


Must be caused by Path meaning two different type definitions. The most 
likely cause is that by default the DUB sources use their own version of 
Path, while if vibe.d is available in the dependency graph, they will 
use the ones defined there instead.


But the error message is indeed awful.


Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Nestor via Digitalmars-d-learn

On Thursday, 9 February 2017 at 20:46:06 UTC, Daniel Kozak wrote:

Maybe you can try use static array instead of dynamic
static immutable ubyte[10][10] QG10Matrix = ...


I shaved it to this to discard unneccessary time-consuming 
functions:


static immutable ubyte[10][10] QG10Matrix = [
  [0,3,1,7,5,9,8,6,4,2],[7,0,9,2,1,5,4,8,6,3],
  [4,2,0,6,8,7,1,3,5,9],[1,7,5,0,9,8,3,4,2,6],
  [6,1,2,3,0,4,5,9,7,8],[3,6,7,4,2,0,9,5,8,1],
  [5,8,6,9,7,2,0,1,3,4],[8,9,4,5,3,6,2,0,1,7],
  [9,4,3,8,6,1,7,2,0,5],[2,5,8,1,4,3,6,7,9,0],
];

static immutable string number =
  
"0123456789012345678901234567890123456789012345678901234567890123456789";


static int charToInt(char chr) {
  return ((chr >= '0') || (chr <= '9')) ? cast(int)(chr - '0') : 
-1;

}

ubyte checkDigit(string str) {
  ubyte tmpdigit;
  foreach(chr; str) tmpdigit = 
QG10Matrix[tmpdigit][charToInt(chr)];

  return tmpdigit;
}

void main() {
  auto digit = checkDigit(number);
}

I even tried making checkDigit static, but surprisingly this 
increased average execution time by 1ms.


Anyway, the previopus version (modified to benefit from a little 
optimization too) is almost as performant, even though it 
includes multiplication and sum:


static immutable char[] QG10Matrix =
  "03175986427092154863420687135917509834266123045978" ~
  "36742095815869720134894536201794386172052581436790";

static immutable string number =
  
"0123456789012345678901234567890123456789012345678901234567890123456789";


static int charToInt(char chr) {
  return ((chr >= '0') || (chr <= '9')) ? cast(int)(chr - '0') : 
-1;

}

char checkDigit(string str) {
  char tmpdigit = '0';
  foreach(chr; str) tmpdigit =
QG10Matrix[charToInt(chr) + (charToInt(tmpdigit) * 10)];
  return tmpdigit;
}

void main() {
  auto digit = checkDigit(number);
}

I compiled both with -inline -noboundscheck -release and the 
multidimensional array version does perform 1ms faster for a 
couple hundred runs, but I expected the difference to be much 
more noticeable.


Any idea of what might be happening here?


Best error msg ever

2017-02-09 Thread Daniel Kozak via Digitalmars-d
source/app.d(51,37): Error: function 
dub.internal.utils.jsonFromFile (Path file, bool silent_fail = 
false) is not callable using argument types (Path, bool)


WTF?


Re: Multiplayer Game Project

2017-02-09 Thread Orkhan via Digitalmars-d

On Thursday, 9 February 2017 at 18:21:42 UTC, Suliman wrote:

Do you have skype?
I familiar with vibed and vue.js


please add my skype : alioutlawz (profile pic is red flower)
email is : pirokine...@live.ru



Re: two points

2017-02-09 Thread Joseph Rushton Wakeling via Digitalmars-d-announce

On Thursday, 9 February 2017 at 20:43:00 UTC, Walter Bright wrote:

*Anyone* in this community can step up and do that.


Anyone can make observations and proposals, but not everyone has 
the authority to effect change.


I appreciate how frustrating it must be to have people saying, 
'Hey, do this!  Do that!' without necessarily volunteering their 
own efforts in support, but organizational improvements so very 
often fail unless they are eagerly pursued at a leadership level.


Re: two points

2017-02-09 Thread Jack Stouffer via Digitalmars-d-announce
On Thursday, 9 February 2017 at 16:48:16 UTC, Joseph Rushton 
Wakeling wrote:
which is that after some initial interest and feedback, the PR 
just got left alone with no decision to accept or reject it, 
and no indication of why.


This is why I only contribute to Phobos to be quite honest.

I count ten active reviewers with pull rights on Phobos.

The other repos,

tools: one
dmd: three
druntime: three
dlang.org: two


Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Cym13 via Digitalmars-d-learn

On Thursday, 9 February 2017 at 19:39:49 UTC, Nestor wrote:
On Thursday, 9 February 2017 at 18:34:30 UTC, Era Scarecrow 
wrote:

On Thursday, 9 February 2017 at 17:36:11 UTC, Nestor wrote:
I was trying to port C code from the article in Wikiversity 
[1] to D, but I'm not sure this implementation is the most 
efficient way to do it in D, so suggestions to optimize it 
are welcome:


import std.stdio;

static immutable char[] QG10Matrix =
  "03175986427092154863420687135917509834266123045978" ~
  "36742095815869720134894536201794386172052581436790";

char checkDigit(string str) {
  char tmpdigit = '0';
  foreach(chr; str) tmpdigit = QG10Matrix[(chr - '0') + 
(tmpdigit - '0') * 10];

  return tmpdigit;
}


Well one thing is you can probably reduce them from chars to 
just bytes, instead of having to subtract you can instead add 
at the end. Although unless you're working with a VERY large 
input you won't see a difference.


Actually since you're also multiplying by 10, you can 
incorporate that in the table too... (although a mixin might 
be better for the conversion than by hand)



 static immutable char[] QG10Matrix = [
00,30,10,70,50,90,80,60,40,20,
70,00,90,20,10,50,40,80,60,30,
40,20,00,60,80,70,10,30,50,90,
10,70,50,00,90,80,30,40,20,60,
60,10,20,30,00,40,50,90,70,80,
30,60,70,40,20,00,90,50,80,10,
50,80,60,90,70,20,00,10,30,40,
80,90,40,50,30,60,20,00,10,70,
90,40,30,80,60,10,70,20,00,50,
20,50,80,10,40,30,60,70,90,00];

 char checkDigit(string str) {
   char tmpdigit = 0;
   foreach(chr; str) tmpdigit = QG10Matrix[(chr - '0') +
 tmpdigit];
   return (tmpdigit/10) + '0';
 }




OK I changed the approach using a multidimensional array for 
the matrix so I could ditch arithmetic operations altogether, 
but curiously after measuring a few thousand runs of both 
implementations through avgtime, I see no noticeable 
difference. Why?


import std.stdio;

static immutable ubyte[][] QG10Matrix = [
  [0,3,1,7,5,9,8,6,4,2],[7,0,9,2,1,5,4,8,6,3],
  [4,2,0,6,8,7,1,3,5,9],[1,7,5,0,9,8,3,4,2,6],
  [6,1,2,3,0,4,5,9,7,8],[3,6,7,4,2,0,9,5,8,1],
  [5,8,6,9,7,2,0,1,3,4],[8,9,4,5,3,6,2,0,1,7],
  [9,4,3,8,6,1,7,2,0,5],[2,5,8,1,4,3,6,7,9,0],
];

static int charToInt(char chr) {
  scope(failure) return -1;
  return cast(int)(chr - '0');
}

ubyte checkDigit(string str) {
  ubyte tmpdigit;
  foreach(chr; str) tmpdigit = 
QG10Matrix[tmpdigit][charToInt(chr)];

  return tmpdigit;
}

enum {
  EXIT_SUCCESS = 0,
  EXIT_FAILURE = 1,
}

int main(string[] args) {
  scope(failure) {
writeln("Invalid arguments. You must pass a number.");
return EXIT_FAILURE;
  }
  assert(args.length == 2);
  ubyte digit = checkDigit(args[1]);
  if(digit == 0) writefln("%s is a valid number.", args[1]);
  else {
writefln("%s is not a valid number (but it would be, 
appending digit %s).",

  args[1], digit);
  }

  return EXIT_SUCCESS;
}


The question is, why do you expect it to be noticably faster? On 
modern hardware it the optimizations are such that so little a 
change in code is very hard to link to a difference in running 
time. If you really want to show one the following code does the 
benchmark the right way (ie: using a very long input, tens of 
thousands of runs, and avoiding I/O and load time of the program 
to compare the bare function implementations):


import std.conv;
import std.stdio;
import std.range;
import std.array;
import std.algorithm;

string testcase;

static immutable char[] QG10MatrixOne =
  "03175986427092154863420687135917509834266123045978" ~
  "36742095815869720134894536201794386172052581436790";

char checkDigitOne(string str) {
  char tmpdigit = 0;
  foreach(chr; str) tmpdigit = QG10MatrixOne[(chr - '0') + 
(tmpdigit - '0') * 10];

  return tmpdigit;
}

void testCheckDigitOne() {
checkDigitTwo(testcase);
}

static immutable ubyte[][] QG10MatrixTwo = [
  [0,3,1,7,5,9,8,6,4,2],[7,0,9,2,1,5,4,8,6,3],
  [4,2,0,6,8,7,1,3,5,9],[1,7,5,0,9,8,3,4,2,6],
  [6,1,2,3,0,4,5,9,7,8],[3,6,7,4,2,0,9,5,8,1],
  [5,8,6,9,7,2,0,1,3,4],[8,9,4,5,3,6,2,0,1,7],
  [9,4,3,8,6,1,7,2,0,5],[2,5,8,1,4,3,6,7,9,0],
];

static int charToInt(char chr) {
  scope(failure) return -1;
  return cast(int)(chr - '0');
}

ubyte checkDigitTwo(string str) {
  ubyte tmpdigit;
  foreach(chr; str) {
  tmpdigit = QG10MatrixTwo[tmpdigit][charToInt(chr)];
  }
  return tmpdigit;
}

void testCheckDigitTwo() {
checkDigitTwo(testcase);
}

void main(string[] args) {
  testcase = 
iota(10).cycle.take(10).map!(to!string).array.join;


  import std.datetime: benchmark;
  benchmark!(testCheckDigitOne, 
testCheckDigitTwo)(1).each!writeln;

}


Yet on my machine I have the following times (note that the time 
itself depends on my hardware, what's important is the 
difference):


TickDuration(15785255852)
TickDuration(15784826803)

So it seems that the first version is slower than the second one, 
but by so little that it's hard to link to the actual 
implementation. If anything it shows the futility of 

Re: two points

2017-02-09 Thread Daniel Kozak via Digitalmars-d-announce

Dne 9.2.2017 v 21:43 Walter Bright via Digitalmars-d-announce napsal(a):


On 2/9/2017 12:29 PM, Joseph Rushton Wakeling wrote:
Yes, but it could be good to examine what can be done to more 
pro-actively look

at open PRs that have had no recent follow-up.


*Anyone* in this community can step up and do that.

This obviously does not work :(



Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread Daniel Kozak via Digitalmars-d-learn

Dne 9.2.2017 v 21:10 berni via Digitalmars-d-learn napsal(a):


On Thursday, 9 February 2017 at 19:10:55 UTC, Daniel Kozak wrote:

Dne 9.2.2017 v 17:20 berni via Digitalmars-d-learn napsal(a):


[...]


Ah ok, I understand. So calling with "dmd Special/special.d 
Common/common.d" works.


But when I compile common.d to common.o (with dmd -c common.d) and 
remove common.d after that is there still a possibility to link? The 
obvious doesn't work:



[...]



Thats ok too, you still need to add -ICommon
dmd -ICommon Special/special.d Common/common.o


Doesn't work here:


$> dmd -ICommon Special/special.d Common/common.o
Special/special.d(4): Error: module common is in file 'common.d' 
which cannot be read

import path[0] = Common
import path[1] = /usr/include/dmd/phobos
import path[2] = /usr/include/dmd/druntime/import

Which version of dmd you have?
It should work, you probably do something wrong, I have use your example 
files so do you change them somehow?


Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Daniel Kozak via Digitalmars-d-learn

Dne 9.2.2017 v 20:39 Nestor via Digitalmars-d-learn napsal(a):


On Thursday, 9 February 2017 at 18:34:30 UTC, Era Scarecrow wrote:

On Thursday, 9 February 2017 at 17:36:11 UTC, Nestor wrote:
I was trying to port C code from the article in Wikiversity [1] to 
D, but I'm not sure this implementation is the most efficient way to 
do it in D, so suggestions to optimize it are welcome:


import std.stdio;

static immutable char[] QG10Matrix =
  "03175986427092154863420687135917509834266123045978" ~
  "36742095815869720134894536201794386172052581436790";

char checkDigit(string str) {
  char tmpdigit = '0';
  foreach(chr; str) tmpdigit = QG10Matrix[(chr - '0') + (tmpdigit - 
'0') * 10];

  return tmpdigit;
}


Well one thing is you can probably reduce them from chars to just 
bytes, instead of having to subtract you can instead add at the end. 
Although unless you're working with a VERY large input you won't see 
a difference.


Actually since you're also multiplying by 10, you can incorporate 
that in the table too... (although a mixin might be better for the 
conversion than by hand)



 static immutable char[] QG10Matrix = [
00,30,10,70,50,90,80,60,40,20,
70,00,90,20,10,50,40,80,60,30,
40,20,00,60,80,70,10,30,50,90,
10,70,50,00,90,80,30,40,20,60,
60,10,20,30,00,40,50,90,70,80,
30,60,70,40,20,00,90,50,80,10,
50,80,60,90,70,20,00,10,30,40,
80,90,40,50,30,60,20,00,10,70,
90,40,30,80,60,10,70,20,00,50,
20,50,80,10,40,30,60,70,90,00];

 char checkDigit(string str) {
   char tmpdigit = 0;
   foreach(chr; str) tmpdigit = QG10Matrix[(chr - '0') +
 tmpdigit];
   return (tmpdigit/10) + '0';
 }




OK I changed the approach using a multidimensional array for the 
matrix so I could ditch arithmetic operations altogether, but 
curiously after measuring a few thousand runs of both implementations 
through avgtime, I see no noticeable difference. Why?


import std.stdio;

static immutable ubyte[][] QG10Matrix = [
  [0,3,1,7,5,9,8,6,4,2],[7,0,9,2,1,5,4,8,6,3],
  [4,2,0,6,8,7,1,3,5,9],[1,7,5,0,9,8,3,4,2,6],
  [6,1,2,3,0,4,5,9,7,8],[3,6,7,4,2,0,9,5,8,1],
  [5,8,6,9,7,2,0,1,3,4],[8,9,4,5,3,6,2,0,1,7],
  [9,4,3,8,6,1,7,2,0,5],[2,5,8,1,4,3,6,7,9,0],
];

static int charToInt(char chr) {
  scope(failure) return -1;
  return cast(int)(chr - '0');
}

ubyte checkDigit(string str) {
  ubyte tmpdigit;
  foreach(chr; str) tmpdigit = QG10Matrix[tmpdigit][charToInt(chr)];
  return tmpdigit;
}

enum {
  EXIT_SUCCESS = 0,
  EXIT_FAILURE = 1,
}

int main(string[] args) {
  scope(failure) {
writeln("Invalid arguments. You must pass a number.");
return EXIT_FAILURE;
  }
  assert(args.length == 2);
  ubyte digit = checkDigit(args[1]);
  if(digit == 0) writefln("%s is a valid number.", args[1]);
  else {
writefln("%s is not a valid number (but it would be, appending 
digit %s).",

  args[1], digit);
  }

  return EXIT_SUCCESS;
}


Maybe you can try use static array instead of dynamic
static immutable ubyte[10][10] QG10Matrix = ...


Re: two points

2017-02-09 Thread Walter Bright via Digitalmars-d-announce

On 2/9/2017 12:29 PM, Joseph Rushton Wakeling wrote:

Yes, but it could be good to examine what can be done to more pro-actively look
at open PRs that have had no recent follow-up.


*Anyone* in this community can step up and do that.



Getting familiar with std.process

2017-02-09 Thread jmh530 via Digitalmars-d-learn
I haven't used std.process before and am trying to play around 
with it.


In the code below, the first file writes some text to an output 
file. My goal is to be able to read what is written to that file 
without creating the file itself. I'm not sure it's possible, but 
the second file is my attempt.


The second file compiles the first (for the sake of simplicity), 
then creates a pipe with program it compiles, piping the result 
to stdout, then it saves the result to an output string, which I 
then print (or potentially manipulate in some other way in the 
future). But it doesn't print anything (why I'm posting here).


I think the issue is that create_file doesn't write to stdout, it 
writes to file. Other than reading the file and then deleting it, 
I don't know what else to try.


//create_file.d

import std.stdio : toFile;

void main()
{
toFile("test", "output.txt");
}

//read_file.d
//read_file.d

import std.process;
import std.stdio;

void main()
{
auto command1 = execute(["dmd", "create_file.d"]);
//auto command2 = execute(["create_file.exe"]);

auto pipes = pipeProcess("create_file.exe", Redirect.stdout);
scope(exit) wait(pipes.pid);

foreach (line; pipes.stdout.byLine) writeln(line);
}


[Issue 17161] [REG 2.072.2] Massive Regex Slowdown

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17161

--- Comment #2 from Jack Stouffer  ---
Bad news: I see a similar performance decrease for run-time regex as well.

# 2.073.0
$ dmd -O -inline -release test2.d && cat input500.txt | time ./test2
./test2  4.44s user 0.09s system 98% cpu 4.591 total

# 2.072.2
~/digger/result/bin/dmd -O -inline -release test2.d && cat input500.txt |
time ./test2
./test2  3.20s user 0.09s system 98% cpu 3.344 total

I consistently get around a second and a half longer run time with 2.073.

Code

import std.algorithm;
import std.array;
import std.range;
import std.regex;
import std.stdio;
import std.typecons;
import std.utf;

static variants = [
"agggtaaa|tttaccct",
"[cgt]gggtaaa|tttaccc[acg]",
"a[act]ggtaaa|tttacc[agt]t",
"ag[act]gtaaa|tttac[agt]ct",
"agg[act]taaa|ttta[agt]cct",
"aggg[acg]aaa|ttt[cgt]ccct",
"agggt[cgt]aa|tt[acg]accct",
"agggta[cgt]a|t[acg]taccct",
"agggtaa[cgt]|[acg]ttaccct",
];

void main()
{
auto app = appender!string;
app.reserve(5_000_000);
app.put(stdin
.byLineCopy(KeepTerminator.yes)
.joiner
.byChar);

auto seq = app.data;

auto regexLineFeeds = regex(">.*\n|\n");
seq = seq.replaceAll(regexLineFeeds, "");

foreach (pattern; variants)
{
writeln(pattern, " ", seq.matchAll(pattern).walkLength);
}
}

--


Re: two points

2017-02-09 Thread Joseph Rushton Wakeling via Digitalmars-d-announce

On Thursday, 9 February 2017 at 19:53:37 UTC, Walter Bright wrote:
There's a lot going on needing attention, and sometimes a bit 
of championing is needed by their proponents.


Yes, but it could be good to examine what can be done to more 
pro-actively look at open PRs that have had no recent follow-up.  
It's not really going to work that well if attention gets given 
substantially on the basis of who's most eagerly seeking it.


People like that metaphor "It's the squeaky wheel that gets the 
grease", but as a first aid trainer once pointed out to me, the 
quieter patient may be the one more in need of immediate 
attention.


Also, please keep in mind that the smaller and more focussed a 
PR is, the more likely it'll have a quick resolution.


Unfortunately my current one is large with good reason.  But I 
think you'll find I also provided very detailed commit messages 
to explain and justify all my changes ;-)


Re: two points

2017-02-09 Thread Joseph Rushton Wakeling via Digitalmars-d-announce

On Thursday, 9 February 2017 at 19:58:57 UTC, Seb wrote:
We gave this a try a couple of months ago with Facebook's 
mention-bot:


Example: 
https://github.com/dlang/phobos/pull/4318#issuecomment-241817191

Repo: https://github.com/dlang-bots/mention-bot

Eventually I disabled it because people complained about the 
added noise.


It's great that you gave this a go.  Seriously, people considered 
one small informative post in the PR to be "added noise"? :-(


Out of curiosity: is it typical that it would not post until some 
way into the discussion (as in that example)?  I could see why it 
would be irritating if it popped up once discussion and review 
had already started happening.


Assuming that the bot can be relied on to be 'first responder' to 
any PR, I'm happy to try to draft an alternative text for it to 
post (and maybe also look at what texts it can link to).


Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread berni via Digitalmars-d-learn

On Thursday, 9 February 2017 at 19:10:55 UTC, Daniel Kozak wrote:

Dne 9.2.2017 v 17:20 berni via Digitalmars-d-learn napsal(a):


[...]


Ah ok, I understand. So calling with "dmd Special/special.d 
Common/common.d" works.


But when I compile common.d to common.o (with dmd -c common.d) 
and remove common.d after that is there still a possibility to 
link? The obvious doesn't work:



[...]



Thats ok too, you still need to add -ICommon
dmd -ICommon Special/special.d Common/common.o


Doesn't work here:


$> dmd -ICommon Special/special.d Common/common.o
Special/special.d(4): Error: module common is in file 'common.d' 
which cannot be read

import path[0] = Common
import path[1] = /usr/include/dmd/phobos
import path[2] = /usr/include/dmd/druntime/import


Re: two points

2017-02-09 Thread Seb via Digitalmars-d-announce

On Thursday, 9 February 2017 at 19:42:03 UTC, Jack Stouffer wrote:
On Thursday, 9 February 2017 at 19:36:52 UTC, Walter Bright 
wrote:
Good idea! Please investigate how to get github to generate 
such emails. In the meantime, the PR guidelines are here:


We gave this a try a couple of months ago with Facebook's 
mention-bot:


Example: 
https://github.com/dlang/phobos/pull/4318#issuecomment-241817191

Repo: https://github.com/dlang-bots/mention-bot

Eventually I disabled it because people complained about the 
added noise.


This is already somewhat done with the PR bot we have. The 
DlangBot notifies reviewers on the DMD repo, but not Phobos for 
some reason. All it does on Phobos is auto close bugzilla 
issues when a bug fix PR is pulled into master.


It does a bit more (e.g. since a couple of weeks it can also 
automatically merge PR once all CI status checks pass)


I say enable the bot for Phobos. It would be a small task to 
also have the bot post the PR guidelines.


As mentioned above, the bot is already enabled and it receives 
all interesting hook events from Phobos, see e.g.:


https://github.com/dlang-bots/dlang-bot/blob/master/source/dlangbot/app.d#L124


I think Martin is the maintainer of the bot.


You can find the code here:

https://github.com/dlang-bots/dlang-bot



Re: two points

2017-02-09 Thread Walter Bright via Digitalmars-d-announce

On 2/9/2017 8:55 AM, Joseph Rushton Wakeling wrote:

On Thursday, 9 February 2017 at 09:49:53 UTC, Walter Bright wrote:

In any case, shouldn't it be an uphill battle to merge things? There are a lot
of things that need to be satisfied to merge something. Being too hasty leads
to legacy code that we come to regret, angry people whose code was broken, and
technical debt.


There's a difference between it being an uphill battle because review and
feedback are careful, cautious, in-depth and strict (as they should be!), versus
it being an uphill battle because no feedback or interest is being offered and
PRs are left to bitrot. :-(


That certainly does happen, but it isn't quite the case with Nick's PRs.



I accept that there are a lot of things that need to be satisfied to merge
something.  Personally speaking, I'm willing to endure any number of rebases and
conflict-fixes, so long as I'm getting feedback and engagement that allows my PR
to become better code.  It's when I'm _not_ getting any indicators as to what
needs to be satisfied that things become problematic.


There's a lot going on needing attention, and sometimes a bit of championing is 
needed by their proponents.


Also, please keep in mind that the smaller and more focussed a PR is, the more 
likely it'll have a quick resolution.


[Issue 17168] Shift left operator causes segfault when compiling with -O flag

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17168

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

   What|Removed |Added

 CC||b2.t...@gmx.com
   Hardware|x86 |All
 OS|Mac OS X|All

--


Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Nestor via Digitalmars-d-learn

On Thursday, 9 February 2017 at 18:34:30 UTC, Era Scarecrow wrote:

...
Actually since you're also multiplying by 10, you can 
incorporate that in the table too...


I forgot to comment that what is multiplied by ten is not the 
value but the starting position in the array (a way to emulate a 
matrix), but anyway see my comments in previous post.


Re: two points

2017-02-09 Thread Jack Stouffer via Digitalmars-d-announce

On Thursday, 9 February 2017 at 19:36:52 UTC, Walter Bright wrote:
Good idea! Please investigate how to get github to generate 
such emails. In the meantime, the PR guidelines are here:


This is already somewhat done with the PR bot we have. The 
DlangBot notifies reviewers on the DMD repo, but not Phobos for 
some reason. All it does on Phobos is auto close bugzilla issues 
when a bug fix PR is pulled into master.


I say enable the bot for Phobos. It would be a small task to also 
have the bot post the PR guidelines.


I think Martin is the maintainer of the bot.


Re: vibe.d 0.8.0 and 0.7.31 beta releases

2017-02-09 Thread Sönke Ludwig via Digitalmars-d-announce

Am 09.02.2017 um 18:00 schrieb Kagamin:

On Wednesday, 8 February 2017 at 15:18:34 UTC, Sönke Ludwig wrote:

The problem is that there are two affected call stacks - the @system
API function that registers the @system callback, wrapping/casting it
as @trusted, and the event handler that later on actually calls the
callback. The latter place is where the hidden violation of the @safe
guarantees happens.


Hidden from whom? Since it's user, who supplies @system code to vibe, he
knows that the resulting program doesn't provide @safe guarantees.
It can be communicated at the API level:

int f(@safe void delegate() dg) @safe
{ code }
int f(@system void delegate() dg) @system
{ return f(cast(@safe void delegate())dg); }

So that unsafe overload would be only callable from unsafe code.


Hidden from the code that calls the callback. This may be an acceptable 
trade off in this particular case, because this is crossing a library 
border, but in general this is just misuse of the safety system, since 
the effects of the cast leave the scope of @system/@trusted.


I don't know, I don't really like this, but maybe I should just postpone 
the `deprecated` attribute to be added for 0.8.1 to leave more room for 
a final decision.


Re: two points

2017-02-09 Thread Walter Bright via Digitalmars-d-announce

On 2/9/2017 8:48 AM, Joseph Rushton Wakeling wrote:

Contrast this with the experience I had the one time I submitted a (tiny,
trivial) patch to rust: immediately after submitting the PR I got a message from
their 'highfive' robot that included:

  * a friendly thank you for the PR;

  * the GitHub ID of a contact who I could expect to be taking responsibility
for the PR, who was also assigned as a reviewer;

  * some helpful notes on how to add changes to the PR if requested;

  * a link to the contributor guidelines.

By contrast with a Phobos PR it's not clear who to contact if review or
decision-making is not forthcoming.


Good idea! Please investigate how to get github to generate such emails. In the 
meantime, the PR guidelines are here:


  http://wiki.dlang.org/Starting_as_a_Contributor#Create_a_pull_request

The teams can be found here:

  https://github.com/orgs/dlang/teams

Please help improve the guidelines.



Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Nestor via Digitalmars-d-learn

On Thursday, 9 February 2017 at 18:34:30 UTC, Era Scarecrow wrote:

On Thursday, 9 February 2017 at 17:36:11 UTC, Nestor wrote:
I was trying to port C code from the article in Wikiversity 
[1] to D, but I'm not sure this implementation is the most 
efficient way to do it in D, so suggestions to optimize it are 
welcome:


import std.stdio;

static immutable char[] QG10Matrix =
  "03175986427092154863420687135917509834266123045978" ~
  "36742095815869720134894536201794386172052581436790";

char checkDigit(string str) {
  char tmpdigit = '0';
  foreach(chr; str) tmpdigit = QG10Matrix[(chr - '0') + 
(tmpdigit - '0') * 10];

  return tmpdigit;
}


Well one thing is you can probably reduce them from chars to 
just bytes, instead of having to subtract you can instead add 
at the end. Although unless you're working with a VERY large 
input you won't see a difference.


Actually since you're also multiplying by 10, you can 
incorporate that in the table too... (although a mixin might be 
better for the conversion than by hand)



 static immutable char[] QG10Matrix = [
00,30,10,70,50,90,80,60,40,20,
70,00,90,20,10,50,40,80,60,30,
40,20,00,60,80,70,10,30,50,90,
10,70,50,00,90,80,30,40,20,60,
60,10,20,30,00,40,50,90,70,80,
30,60,70,40,20,00,90,50,80,10,
50,80,60,90,70,20,00,10,30,40,
80,90,40,50,30,60,20,00,10,70,
90,40,30,80,60,10,70,20,00,50,
20,50,80,10,40,30,60,70,90,00];

 char checkDigit(string str) {
   char tmpdigit = 0;
   foreach(chr; str) tmpdigit = QG10Matrix[(chr - '0') +
 tmpdigit];
   return (tmpdigit/10) + '0';
 }




OK I changed the approach using a multidimensional array for the 
matrix so I could ditch arithmetic operations altogether, but 
curiously after measuring a few thousand runs of both 
implementations through avgtime, I see no noticeable difference. 
Why?


import std.stdio;

static immutable ubyte[][] QG10Matrix = [
  [0,3,1,7,5,9,8,6,4,2],[7,0,9,2,1,5,4,8,6,3],
  [4,2,0,6,8,7,1,3,5,9],[1,7,5,0,9,8,3,4,2,6],
  [6,1,2,3,0,4,5,9,7,8],[3,6,7,4,2,0,9,5,8,1],
  [5,8,6,9,7,2,0,1,3,4],[8,9,4,5,3,6,2,0,1,7],
  [9,4,3,8,6,1,7,2,0,5],[2,5,8,1,4,3,6,7,9,0],
];

static int charToInt(char chr) {
  scope(failure) return -1;
  return cast(int)(chr - '0');
}

ubyte checkDigit(string str) {
  ubyte tmpdigit;
  foreach(chr; str) tmpdigit = 
QG10Matrix[tmpdigit][charToInt(chr)];

  return tmpdigit;
}

enum {
  EXIT_SUCCESS = 0,
  EXIT_FAILURE = 1,
}

int main(string[] args) {
  scope(failure) {
writeln("Invalid arguments. You must pass a number.");
return EXIT_FAILURE;
  }
  assert(args.length == 2);
  ubyte digit = checkDigit(args[1]);
  if(digit == 0) writefln("%s is a valid number.", args[1]);
  else {
writefln("%s is not a valid number (but it would be, 
appending digit %s).",

  args[1], digit);
  }

  return EXIT_SUCCESS;
}



Re: Request for conference talk

2017-02-09 Thread Chris Engelbert via Digitalmars-d

On Monday, 6 February 2017 at 16:50:00 UTC, Stefan Koch wrote:

Hmm I could talk about the various compile-time mechanics of D.
Using Sqlite-D[1] as an example, and tie into the compiler 
implementations, which explain why I wrote a particular piece 
of code the way I did.


That way it could still be focusing the application side of 
things.


Please submit, I'm not deciding alone, therefore I can't give a 
final answer here but to me it sounds interesting :)


Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread Daniel Kozak via Digitalmars-d-learn

Dne 9.2.2017 v 17:20 berni via Digitalmars-d-learn napsal(a):

dmd only compiles in the files you actually pass to it. rdmd will try 
to find the required files automatically.


Since you didn't pass the file with the function to dmd, it knows it 
exists, but leaves it out of the final link (it assumes it might come 
from a library or something). That's why you see the error.


Ah ok, I understand. So calling with "dmd Special/special.d 
Common/common.d" works.


But when I compile common.d to common.o (with dmd -c common.d) and 
remove common.d after that is there still a possibility to link? The 
obvious doesn't work:


$> dmd Special/special.d Common/common.o Special/special.d(4): Error: 
module common is in file 'common.d' which cannot be read

import path[0] = /usr/include/dmd/phobos
import path[1] = /usr/include/dmd/druntime/import



Thats ok too, you still need to add -ICommon
dmd -ICommon Special/special.d Common/common.o


Re: Questionnaire

2017-02-09 Thread bachmeier via Digitalmars-d-announce

On Thursday, 9 February 2017 at 18:38:32 UTC, John Colvin wrote:

On Thursday, 9 February 2017 at 18:34:44 UTC, bachmeier wrote:

On Thursday, 9 February 2017 at 17:28:47 UTC, jmh530 wrote:


Other stuff I would find useful:
1) R integration (I know someone's done work on this, but 
it's hard to find and I don't remember if it works on 
Windows. Really just needs a champion)


Me. The latest version is here: 
https://bitbucket.org/bachmeil/embedr


It's Linux-only because that's all I know or use. Others that 
I work with use it on Windows and OS X trivially with Docker, 
but for someone that understands development on those OSes, it 
shouldn't take much to get it working natively. Everything is 
handled internally by the R package manager, and the package 
itself has functions to take care of all steps for compilation.


I don't promote it because I don't have time to run an open 
source project properly. However, I am happy to help in any 
way if someone else wants to use it. I am flexible on the 
license, so that's not an issue.


There's a possibility of some commercial need for R <-> D where 
I'm working, so hopefully we'll be able to help here.


I believe you have my email address. Send me a message if 
something comes up.


I redid everything a few months ago, so if you looked at an 
earlier version, this is much improved. Getting it to work on 
Windows/OS X or integrating Dub is something that can be done in 
an afternoon by someone with the appropriate background.


Re: Questionnaire

2017-02-09 Thread John Colvin via Digitalmars-d-announce

On Thursday, 9 February 2017 at 18:34:44 UTC, bachmeier wrote:

On Thursday, 9 February 2017 at 17:28:47 UTC, jmh530 wrote:


Other stuff I would find useful:
1) R integration (I know someone's done work on this, but it's 
hard to find and I don't remember if it works on Windows. 
Really just needs a champion)


Me. The latest version is here: 
https://bitbucket.org/bachmeil/embedr


It's Linux-only because that's all I know or use. Others that I 
work with use it on Windows and OS X trivially with Docker, but 
for someone that understands development on those OSes, it 
shouldn't take much to get it working natively. Everything is 
handled internally by the R package manager, and the package 
itself has functions to take care of all steps for compilation.


I don't promote it because I don't have time to run an open 
source project properly. However, I am happy to help in any way 
if someone else wants to use it. I am flexible on the license, 
so that's not an issue.


There's a possibility of some commercial need for R <-> D where 
I'm working, so hopefully we'll be able to help here.


Re: Questionnaire

2017-02-09 Thread bachmeier via Digitalmars-d-announce

On Thursday, 9 February 2017 at 17:28:47 UTC, jmh530 wrote:


Other stuff I would find useful:
1) R integration (I know someone's done work on this, but it's 
hard to find and I don't remember if it works on Windows. 
Really just needs a champion)


Me. The latest version is here: 
https://bitbucket.org/bachmeil/embedr


It's Linux-only because that's all I know or use. Others that I 
work with use it on Windows and OS X trivially with Docker, but 
for someone that understands development on those OSes, it 
shouldn't take much to get it working natively. Everything is 
handled internally by the R package manager, and the package 
itself has functions to take care of all steps for compilation.


I don't promote it because I don't have time to run an open 
source project properly. However, I am happy to help in any way 
if someone else wants to use it. I am flexible on the license, so 
that's not an issue.


Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Era Scarecrow via Digitalmars-d-learn

On Thursday, 9 February 2017 at 17:36:11 UTC, Nestor wrote:
I was trying to port C code from the article in Wikiversity [1] 
to D, but I'm not sure this implementation is the most 
efficient way to do it in D, so suggestions to optimize it are 
welcome:


import std.stdio;

static immutable char[] QG10Matrix =
  "03175986427092154863420687135917509834266123045978" ~
  "36742095815869720134894536201794386172052581436790";

char checkDigit(string str) {
  char tmpdigit = '0';
  foreach(chr; str) tmpdigit = QG10Matrix[(chr - '0') + 
(tmpdigit - '0') * 10];

  return tmpdigit;
}


Well one thing is you can probably reduce them from chars to just 
bytes, instead of having to subtract you can instead add at the 
end. Although unless you're working with a VERY large input you 
won't see a difference.


Actually since you're also multiplying by 10, you can incorporate 
that in the table too... (although a mixin might be better for 
the conversion than by hand)



 static immutable char[] QG10Matrix = [
00,30,10,70,50,90,80,60,40,20,
70,00,90,20,10,50,40,80,60,30,
40,20,00,60,80,70,10,30,50,90,
10,70,50,00,90,80,30,40,20,60,
60,10,20,30,00,40,50,90,70,80,
30,60,70,40,20,00,90,50,80,10,
50,80,60,90,70,20,00,10,30,40,
80,90,40,50,30,60,20,00,10,70,
90,40,30,80,60,10,70,20,00,50,
20,50,80,10,40,30,60,70,90,00];

 char checkDigit(string str) {
   char tmpdigit = 0;
   foreach(chr; str) tmpdigit = QG10Matrix[(chr - '0') +
 tmpdigit];
   return (tmpdigit/10) + '0';
 }


Re: Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Cym13 via Digitalmars-d-learn

On Thursday, 9 February 2017 at 17:36:11 UTC, Nestor wrote:

Hi,

I was trying to port C code from the article in Wikiversity [1] 
to D, but I'm not sure this implementation is the most 
efficient way to do it in D, so suggestions to optimize it are 
welcome:


import std.stdio;

static immutable char[] QG10Matrix =
  "03175986427092154863420687135917509834266123045978" ~
  "36742095815869720134894536201794386172052581436790";

char checkDigit(string str) {
  char tmpdigit = '0';
  foreach(chr; str) tmpdigit = QG10Matrix[(chr - '0') + 
(tmpdigit - '0') * 10];

  return tmpdigit;
}

enum {
  EXIT_SUCCESS = 0,
  EXIT_FAILURE = 1,
}

int main(string[] args) {
  scope(failure) {
writeln("Invalid arguments. You must pass a number.");
return EXIT_FAILURE;
  }
  assert(args.length == 2);
  char digit = checkDigit(args[1]);
  if(digit == '0') writefln("%s is a valid number.", args[1]);
  else {
writefln("%s is not a valid number (but it would be, 
appending digit %s).",

  args[1], digit);
  }

  return EXIT_SUCCESS;
}

[1] https://en.wikiversity.org/wiki/Damm_algorithm


I can't see how to make it more efficient than it is (aside from 
finding a better algorithm which isn't a language concern). You 
are using C style and will get the same machine code as if you'd 
written it with C. The only difference would be boundchecking 
that you can disable by using the -boundscheck=off compiler 
switch.


By the way note that you can use the -profile switch to see where 
the bottlenecks are, in your case writting the result to stdout 
is *by far* what takes the most time (and I'm quite certain the 
bottleneck is the same in the C version for it's a fact that I/O 
is slow).


Re: Multiplayer Game Project

2017-02-09 Thread Suliman via Digitalmars-d

Do you have skype?
I familiar with vibed and vue.js


[Issue 17168] Shift left operator causes segfault when compiling with -O flag

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17168

--- Comment #1 from Sophie  ---
Actually this occurs with the -O flag, independent of -inline

--


[Issue 17168] Shift left operator causes segfault when compiling with -O flag

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17168

Sophie  changed:

   What|Removed |Added

Summary|Shift left operator causes  |Shift left operator causes
   |segfault when compiling |segfault when compiling
   |with -O -inline flags   |with -O flag

--


[Issue 17168] New: Shift left operator causes segfault when compiling with -O -inline flags

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17168

  Issue ID: 17168
   Summary: Shift left operator causes segfault when compiling
with -O -inline flags
   Product: D
   Version: D2
  Hardware: x86
OS: Mac OS X
Status: NEW
  Severity: major
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: meapineap...@gmail.com

Where test.d contains:

void fn(uint x){uint a = 0 << x;}

This works fine:

> dmd test.d -main

This does not:

> dmd test.d -main -O -inline
Segmentation fault: 11

This bug seems to only occur when both the -O and -inline compilation flags are
present.

--


[Issue 17167] New: dmd fails to write to file with 6 or more ".." in the path

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17167

  Issue ID: 17167
   Summary: dmd fails to write to file with 6 or more ".." in the
path
   Product: D
   Version: D2
  Hardware: x86_64
OS: Windows
Status: NEW
  Severity: major
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: atila.ne...@gmail.com

I saw this while running dub on Windows:

Error: Error writing file
'..\..\..\..\..\..\AppData\Roaming\dub\packages\taggedalgebraic-0.10.5\taggedalgebraic\.dub\build\library-debug-windows-x86-dmd_2073-20BD164B4B4CA7B99E316352127B8128\taggedalgebraic.lib'

If I move the source directory up one directory this stops happening (i.e., dmd
would write the output library to
'..\..\..\..\..\AppData\Roaming\dub\packages\taggedalgebraic-0.10.5\taggedalgebraic\.dub\build\library-debug-windows-x86-dmd_2073-20BD164B4B4CA7B99E316352127B8128\taggedalgebraic.lib'
instead, and successfully)

--


Re: two points

2017-02-09 Thread Nick Sabalausky via Digitalmars-d-announce

On 02/09/2017 04:49 AM, Walter Bright wrote:

On 2/8/2017 11:09 PM, Nick Sabalausky wrote:

And any PRs I have managed to get through were all uphill battles the
whole way.


You have contributed 5 PRs to dmd:

   https://github.com/dlang/dmd/pulls?q=is%3Apr+author%3Aabscissa

 1 is open (it's controversial)

 1 closed (today by me)


Well, I suppose I brought that one on myself by complaining about it 
being ignored :/




 3 merged
 1 in 6 days
 2 in 1 day

Overall, I think you've done well.


Note that those quickly merged ones were several years ago, back before 
the battles to get anything accepted reached ridiculous levels.




In any case, shouldn't it be an uphill battle to merge things?


No. There should be appropriate checks and reviews, yes. But, no, every 
little fix and improvement shouldn't feel like trying to get somewhere 
in a year-long tabs vs spaces debate or making a big-budget sales pitch 
to Indecisives Anonymous.




Re: Codecov and CyberShadow failure

2017-02-09 Thread Jack Stouffer via Digitalmars-d
On Wednesday, 8 February 2017 at 21:05:45 UTC, Jack Stouffer 
wrote:

...


Still can't find the root cause. I'm also unable to recreate the 
problem locally using the same commands as the doc builder.


We currently have nine PRs in the pipe ready to be merged once 
this error is nailed down. If anyone could lend a hand here, it 
would be very helpful.


Re: GSoC Project Idea's Part 2

2017-02-09 Thread jmh530 via Digitalmars-d
On Friday, 3 February 2017 at 04:12:10 UTC, Craig Dillabaugh 
wrote:


So new project ideas are welcome, and feel free to post any 
ideas you have here for comment.  Also we need mentors so if 
you post a new project, or see one on the existing ideas page 
please feel free to offer your services as a mentor.




I had some time to think about this a little more.

The one thing I keep coming back to is better support for R 
integration. I remember something about R integration for D, but 
it's hard to find the project. I had asked about it before, so I 
could probably find it again if I needed to. My recollection is 
that it only works on linux. Perhaps someone else can take it 
over and run with it? It seems like if you're trying to get more 
numerical computing people to use D, then being able to say you 
can run any R or Python (from pyd) function would be a big 
positive. Getting everything robust across major platforms, 
publicizing it, and making it easier for users would be an 
attractive project to me.


And if they have time they can do Matlab/Octave, while they're at 
it.


Can this implementation of Damm algorithm be optimized?

2017-02-09 Thread Nestor via Digitalmars-d-learn

Hi,

I was trying to port C code from the article in Wikiversity [1] 
to D, but I'm not sure this implementation is the most efficient 
way to do it in D, so suggestions to optimize it are welcome:


import std.stdio;

static immutable char[] QG10Matrix =
  "03175986427092154863420687135917509834266123045978" ~
  "36742095815869720134894536201794386172052581436790";

char checkDigit(string str) {
  char tmpdigit = '0';
  foreach(chr; str) tmpdigit = QG10Matrix[(chr - '0') + (tmpdigit 
- '0') * 10];

  return tmpdigit;
}

enum {
  EXIT_SUCCESS = 0,
  EXIT_FAILURE = 1,
}

int main(string[] args) {
  scope(failure) {
writeln("Invalid arguments. You must pass a number.");
return EXIT_FAILURE;
  }
  assert(args.length == 2);
  char digit = checkDigit(args[1]);
  if(digit == '0') writefln("%s is a valid number.", args[1]);
  else {
writefln("%s is not a valid number (but it would be, 
appending digit %s).",

  args[1], digit);
  }

  return EXIT_SUCCESS;
}

[1] https://en.wikiversity.org/wiki/Damm_algorithm


Re: Questionnaire

2017-02-09 Thread jmh530 via Digitalmars-d-announce

On Thursday, 9 February 2017 at 16:33:18 UTC, bachmeier wrote:
Make extensions that others can use within their current 
workflow, and they will use it. Leave it as a Dub package and 
they won't touch it. You've done a lot of good work, but it's 
kind of a dead end to target the standalone D program market 
right now.


+1!




fix for sample mandelbrot code from documentation -- latest gdc has no lockingBinaryWriter

2017-02-09 Thread Oasiq via Digitalmars-d-learn

Hi,

I was trying to run the example code from

https://dlang.org/phobos/std_stdio.html#.File.lockingBinaryWriter

which is very short, as follows.

===

import std.algorithm, std.range, std.stdio;
void main()
{
enum size = 500;
writef("P5\n%d %d %d\n", size, size, ubyte.max);

iota(-1, 3, 2.0/size).map!(y =>
iota(-1.5, 0.5, 2.0/size).map!(x =>
cast(ubyte)(1+
recurrence!((a, n) => x + y*1i + a[n-1]^^2)(0+0i)
.take(ubyte.max)
.countUntil!(z => z.re^^2 + z.im^^2 > 4))
)
)
.copy(stdout.lockingBinaryWriter);
}

===

Unfortunately, my compiler fails with

$ gdc -Wall -o m1 m1.d m2.d:14:17: error: no property 
'lockingBinaryWriter' for type 'File'

 .copy(stdout.lockingBinaryWriter);


It looks like the latest in the repository isn't recent enough, 
since the source code online to stdio.d on github has 
lockingBinaryWriter in it, but my copy installed via ubuntu apt 
does not.


I tried


$ gdc --version


and got


gdc (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005


but that doesn't say what version the frontend compiler or 
standard library is.  After searching on the web, I found a 
pragma that I added to the file



pragma(msg, __VERSION__);


which gave the version "2068L" when I compiled it. According to

https://gdcproject.org/downloads

the latest gdc(1) uses the DMDFE version 2.068.2 which isn't new 
enough I guess, since the DMD version appears to be 2.073.0 which 
includes lockingBinaryWriter.


This fixes the problem:

===

import std.range, std.array, std.stdio;

void main()
{
auto buf = appender!(ubyte[])();
enum size = 500;
writef("P5\n%d %d %d\n", size, size, ubyte.max);
iota(-1, 3, 2.0/size).map!(y =>
iota(-1.5, 0.5, 2.0/size).map!(x =>
cast(ubyte)(1+
recurrence!((a, n) => x + y*1i + a[n-1]^^2)(0+0i)
.take(ubyte.max)
.countUntil!(z => z.re^^2 + z.im^^2 > 4))
)
)
.copy(buf);
stdout.rawWrite(buf.data);
}

===

And running it


$ gdc -Wall -o m2 m2.d && ./m1 > aaa.pnm && display aaa.pnm


produces the expected result.

I'm posting this in case anyone else encounters this problem.  I 
don't know D at all, and perhaps this will save someone else from 
some head scratching and going down output iterator rabbit holes.


Best regards,

Oasiq.


Re: Questionnaire

2017-02-09 Thread jmh530 via Digitalmars-d-announce
On Wednesday, 8 February 2017 at 18:27:57 UTC, Ilya Yaroshenko 
wrote:

1. Why your company uses  D?

  a. D is the best
  b. We like D
  c. I like D and my company allowed me to use D
  d. My head like D
  e. Because marketing reasons
  f. Because my company can be more efficient with D for some 
tasks then with any other system language




I'm the only person I personally know who uses D. I mainly use it 
for personal projects. I like it because the other languages I 
more often use, like R or Python, are just not sufficient for 
some purposes. I've tried C++, but I like D a lot more.



2. Does your company uses C/C++, Java, Scala, Go, Rust?



Not my group, but I imagine other parts.


3. If yes, what the reasons to do not use D instead?

2. Have you use one of the following Mir projects in production:

  a. https://github.com/libmir/mir
  b. https://github.com/libmir/mir-algorithm
  c. https://github.com/libmir/mir-cpuid
  d. https://github.com/libmir/mir-random
  e. https://github.com/libmir/dcv - D Computer Vision Library
  f. std.experimental.ndslice



Not in production, but in personal projects.



5. What D misses to be commercially successful languages?



I would probably say libraries is most important. Mir is a great 
advance. I've been applauding your work all the way through. 
There are two things that I think Mir needs most (and we've 
talked about them before as things you were thinking about) and 
then a third is a nice-to-have

1) A higher level layer with more convenient syntax for Mir-Glas
2) Lapack support (eigenvalues, svd, & cholesky/qr decompositions)
3) D compute support (would be nice to easily offload big 
computations to GPU)


Other stuff I would find useful:
1) R integration (I know someone's done work on this, but it's 
hard to find and I don't remember if it works on Windows. Really 
just needs a champion)

2) Stan (http://mc-stan.org/) interface


=

All my current D project are finished. Probably I will use 
other languages for production this year, Java/Go/whatever. Mir 
libraries are amazing and good quality. If you use them this 
would be a good motivation for us to improve the docs and 
provide regular updates. Plus, it can be enchanted during the 
GSoC 2017.




I agree on GSOC 2017, but you should provide some sort of 
guidance or support. I hope Mir gets more attention!


[Issue 17166] New: [internals] Frontend AST is littered with DMD-specific fields

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17166

  Issue ID: 17166
   Summary: [internals] Frontend AST is littered with DMD-specific
fields
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: ibuc...@gdcproject.org

There should be a way to move these out, while at the same time allowing other
users of the dfrontend-as-a-library to add their own information into the AST
classes.

See https://github.com/dlang/dmd/pull/5501

--


Updated LDC snap package with link-time optimization (LTO) support

2017-02-09 Thread Joseph Rushton Wakeling via Digitalmars-d-announce
Revision 3 of the ldc2 snap package is now available in the 
'edge' channel of the snap store.  This still provides LDC 1.1.0, 
but with the following important changes:


  * the backend is provided by LLVM 3.9.1

  * support for LDC's experimental link-time optimization
(the -flto={full,thin} flag) has been included

I would be very grateful if people could try out these new 
features and report back on whether or not they work (and if any 
problems are encountered, on which distro and version).



-- to install --

This package should be possible to install on Ubuntu 16.04 or 
later, or Ubuntu 14.04, as well as any other distro making 
available a recent version of snapd (2.21 or later):

https://snapcraft.io/docs/core/install

Once snapd is installed (on Ubuntu or Debian, `sudo apt install 
snapd`), the ldc2 snap can be installed with:


sudo snap install --classic --edge ldc2

If you already have a version installed, you can upgrade it with:

sudo snap refresh --classic --edge ldc2

Note, if this version breaks something for you, you can downgrade 
to revision 2 with:


sudo snap refresh --classic --edge --revision=2 ldc2


Re: vibe.d 0.8.0 and 0.7.31 beta releases

2017-02-09 Thread Kagamin via Digitalmars-d-announce

On Wednesday, 8 February 2017 at 15:18:34 UTC, Sönke Ludwig wrote:
The problem is that there are two affected call stacks - the 
@system API function that registers the @system callback, 
wrapping/casting it as @trusted, and the event handler that 
later on actually calls the callback. The latter place is where 
the hidden violation of the @safe guarantees happens.


Hidden from whom? Since it's user, who supplies @system code to 
vibe, he knows that the resulting program doesn't provide @safe 
guarantees.

It can be communicated at the API level:

int f(@safe void delegate() dg) @safe
{ code }
int f(@system void delegate() dg) @system
{ return f(cast(@safe void delegate())dg); }

So that unsafe overload would be only callable from unsafe code.


Re: two points

2017-02-09 Thread Joseph Rushton Wakeling via Digitalmars-d-announce

On Thursday, 9 February 2017 at 09:49:53 UTC, Walter Bright wrote:
In any case, shouldn't it be an uphill battle to merge things? 
There are a lot of things that need to be satisfied to merge 
something. Being too hasty leads to legacy code that we come to 
regret, angry people whose code was broken, and technical debt.


There's a difference between it being an uphill battle because 
review and feedback are careful, cautious, in-depth and strict 
(as they should be!), versus it being an uphill battle because no 
feedback or interest is being offered and PRs are left to bitrot. 
:-(


I accept that there are a lot of things that need to be satisfied 
to merge something.  Personally speaking, I'm willing to endure 
any number of rebases and conflict-fixes, so long as I'm getting 
feedback and engagement that allows my PR to become better code.  
It's when I'm _not_ getting any indicators as to what needs to be 
satisfied that things become problematic.


Re: two points

2017-02-09 Thread Joseph Rushton Wakeling via Digitalmars-d-announce

On Thursday, 9 February 2017 at 08:02:23 UTC, Walter Bright wrote:

The PR in question:

  https://github.com/dlang/dmd/pull/4745

It took me a while to find it, because you were using a 
pseudonym that I did not recognize. There are a number of 
frequent contributors to D using pseudonyms, and all have this 
issue with varying degrees.


This is a fair point in its own right, but it's completely 
orthogonal to the issue Nick is complaining about -- which is 
that after some initial interest and feedback, the PR just got 
left alone with no decision to accept or reject it, and no 
indication of why.


That's really a very unpleasant situation to face, regardless of 
whether the contributor in question is a well-known name or some 
complete anonymous stranger.  I have a PR of my own that's been 
in this situation for (only!) a month now, and it's distinctly 
frustrating, particularly because it was a contribution that 
Andrei specifically called for on these forums:

https://github.com/dlang/phobos/pull/5011

(... Andrei's request: 
https://forum.dlang.org/post/o1cqdb$245o$1...@digitalmars.com)


Contrast this with the experience I had the one time I submitted 
a (tiny, trivial) patch to rust: immediately after submitting the 
PR I got a message from their 'highfive' robot that included:


  * a friendly thank you for the PR;

  * the GitHub ID of a contact who I could expect to be taking 
responsibility

for the PR, who was also assigned as a reviewer;

  * some helpful notes on how to add changes to the PR if 
requested;


  * a link to the contributor guidelines.

By contrast with a Phobos PR it's not clear who to contact if 
review or decision-making is not forthcoming.


There's clearly in part a scaling problem here (in terms of how 
many people are available in general, and in terms of how many 
people have expertise on particular parts of the library) but it 
also feels like a few simple things (like making sure every PR 
author is given a reliable contact or two who they can feel 
entitled to chase up) could make a big difference.


Re: Cross-compile with LDC

2017-02-09 Thread Joakim via Digitalmars-d-learn

On Wednesday, 8 February 2017 at 17:57:49 UTC, kinke wrote:

On Wednesday, 8 February 2017 at 17:21:03 UTC, Oleg B wrote:
If I understand correctly with vanilla LDC I can't 
cross-compiling from host linux-x86_64, but with your patch I 
can. Right?


Right. Joakim Noah has worked on LDC for Android and as far as 
I know provides some prebuilt compilers, a native one and a 
cross-compiler (Linux x86_64 host) including that patch.
There's also a pre-built Windows -> ARM cross-compiler; see 
http://forum.dlang.org/thread/xzzzfvahuwvgsluli...@forum.dlang.org and more ARM-related threads in our subforum.


That's not really a Windows build of ldc, he just used the new 
linux support in Windows 10.  There is a build of ldc 1.1.0 for 
native linux/ARM, if you want to compile D code on the ARM device 
itself:


https://github.com/ldc-developers/ldc/releases/tag/v1.1.0

If not, it's pretty straight forward to build a cross-compiler 
for ARM, take a look at my patches and instructions for Android:


https://github.com/joakim-noah/android/releases

If I use your patch must I use in my programs only double or I 
can stay real in existing code?


Don't worry, the reals can stay.


The patch will make reals the same as double, ie they're all 
64-bit, so it is irrelevant which one you use.  If you're writing 
cross-platform code and care about that difference on other 
platforms, you may need to check for it.  Take a look at std.math 
for examples of this, where it checks the length of the mantissa 
sometimes for reals.


Game Website Server Side

2017-02-09 Thread Orkhan via Digitalmars-d-announce

Hello All!

We have a multiplayer game website which uses D programming 
language for server side instant interactions. I need someone 
professional who is able to make some changes on request. We are 
the company and we will allocate money for these tasks. It is not 
only one time task , we are seeking person who is able to work 
with us for a long time. Please contact or type on this thread 
who interested.


KinD Regards
Orkhan


Re: Questionnaire

2017-02-09 Thread bachmeier via Digitalmars-d-announce
On Wednesday, 8 February 2017 at 18:27:57 UTC, Ilya Yaroshenko 
wrote:

2. Have you use one of the following Mir projects in production:

  a. https://github.com/libmir/mir
  b. https://github.com/libmir/mir-algorithm
  c. https://github.com/libmir/mir-cpuid
  d. https://github.com/libmir/mir-random
  e. https://github.com/libmir/dcv - D Computer Vision Library
  f. std.experimental.ndslice


I wasn't going to comment, since I'm not part of the target 
group, but I have enough familiarity with commercial usage to 
give you an answer to this question.


Why would someone in an "enterprise" situation want to use Mir? 
If you create a nice R package to make Mir functionality 
available to Rcpp users, and you provide new functionality not 
currently available in other R packages (with good performance to 
boot), you will see commercial usage. But it has to be a package 
they can install from CRAN/Github/Bitbucket using the R package 
manager. They're not going to mess around with Dub.


The same is true for Matlab/Octave/Python. Make extensions that 
others can use within their current workflow, and they will use 
it. Leave it as a Dub package and they won't touch it. You've 
done a lot of good work, but it's kind of a dead end to target 
the standalone D program market right now.


Multiplayer Game Project

2017-02-09 Thread Orkhan via Digitalmars-d

Hello All!

We have a multiplayer game website which uses D programming 
language for server side instant interactions. I need someone 
professional who is able to make some changes on request. We are 
the company and we will allocate money for these tasks. It is not 
only one time task , we are seeking person who is able to work 
with us for a long time. Please contact or type on this thread 
who interested.


KinD Regards
Orkhan


Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread berni via Digitalmars-d-learn
dmd only compiles in the files you actually pass to it. rdmd 
will try to find the required files automatically.


Since you didn't pass the file with the function to dmd, it 
knows it exists, but leaves it out of the final link (it 
assumes it might come from a library or something). That's why 
you see the error.


Ah ok, I understand. So calling with "dmd Special/special.d 
Common/common.d" works.


But when I compile common.d to common.o (with dmd -c common.d) 
and remove common.d after that is there still a possibility to 
link? The obvious doesn't work:


$> dmd Special/special.d Common/common.o Special/special.d(4): 
Error: module common is in file 'common.d' which cannot be read

import path[0] = /usr/include/dmd/phobos
import path[1] = /usr/include/dmd/druntime/import




Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread via Digitalmars-d-learn
On Thu, Feb 09, 2017 at 03:39:18PM +, berni via Digitalmars-d-learn wrote:
> Now I try to run it with rdmd and dmd and get quite different results:

dmd only compiles in the files you actually pass to it. rdmd
will try to find the required files automatically.

Since you didn't pass the file with the function to dmd, it knows
it exists, but leaves it out of the final link (it assumes it might
come from a library or something). That's why you see the error.

rdmd exists because it handles it more automatically.



[Issue 17161] [REG 2.072.2] Massive Regex Slowdown

2017-02-09 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17161

--- Comment #1 from Jack Stouffer  ---
Introduced here: https://github.com/dlang/phobos/pull/4995

--


Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread berni via Digitalmars-d-learn

I've got two source files in two directories:

Common/common.d


module common;

import std.stdio;

int main(string[] args)
{
   Foo foo = cast(Foo)Object.factory("special.Bar");

   foo.do_something();

   return 0;
}

abstract class Foo {
   abstract void do_something();
}


Special/special.d


module special;

import std.stdio;
import common;

class Bar : Foo {
   override void do_something()
   {
   writeln("works");
   }
}


Now I try to run it with rdmd and dmd and get quite different 
results:



$> rdmd -ICommon Special/special.d
works
$> dmd -ICommon Special/special.d
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: In function 
`_start':
(.text+0x20): undefined reference to `main'
special.o:(.data.rel.ro+0x18): undefined reference to 
`_D6common12__ModuleInfoZ'
special.o:(.data._D7special3Bar7__ClassZ+0x50): undefined 
reference to `_D6common3Foo7__ClassZ'

collect2: error: ld returned 1 exit status
Error: linker exited with status 1


I encountered this, when I was curious if I can move the main 
function to a diffent module, because it will be the same in 
several modules anyway. When testing with rdmd, everything 
worked. Later, I found out, that with dmd it doesn't. (And with 
gdc and ldc2 it doesn't work too.)


For me, this looks like a bug in either rdmd or dmd. But maybe 
there is something about it that I do not understand.


Re: Factory using an alias template parameter to set a member of the new tool ?

2017-02-09 Thread jkpl via Digitalmars-d-learn

On Thursday, 9 February 2017 at 15:00:21 UTC, angel wrote:

On Thursday, 9 February 2017 at 14:39:41 UTC, angel wrote:

On Thursday, 9 February 2017 at 13:30:07 UTC, jkpl wrote:

I'm looking for a better way to do this, if possible:


Or actually, maybe this will suite your case better:
```
template namedTool(T, alias Variable)
{
enum namedTool = T.stringof ~ " " ~ Variable ~ " = new " ~ 
T.stringof ~ ";" ~

 Variable ~ ".name = \"" ~ Variable ~ "\";";
}

void main()
{
mixin(namedTool!(Tool, "grep"));
assert(grep.name == "grep");
}
```


Thanks for trying. I know that it doesn't make much sense but it 
would have been a cool sugar for the tool class.


Mixins are not good for me because of completion in the IDE.


  1   2   >