Re: [Starting with D] d2html.d issues an error

2017-05-25 Thread Basile B. via Digitalmars-d-learn
On Thursday, 25 May 2017 at 15:02:33 UTC, Oleksii wrote: Hi everyone, Could you please help me? I'm get the following error from all.sh: $ /e/D/dmd2/windows/bin/shell.exe all.sh shell 1.05 ..\..\windows\bin\dmd d2html d2html.d(18): Error: module stream is in file 'std\stream.d'

Re: Code improvement for DNA reverse complement?

2017-05-25 Thread aberba via Digitalmars-d-learn
On Friday, 19 May 2017 at 07:46:13 UTC, Stefan Koch wrote: On Friday, 19 May 2017 at 07:29:44 UTC, biocyberman wrote: I am solving this problem http://rosalind.info/problems/revc/ as an exercise to learn D. This is my solution: https://dpaste.dzfl.pl/8aa667f962b7 Is there some D tricks I can

Re: Code improvement for DNA reverse complement?

2017-05-25 Thread ag0aep6g via Digitalmars-d-learn
On 05/25/2017 10:41 PM, Ali Çehreli wrote: I would like to acknowledge you in the book hopefully with your real name but if you don't want or care, I will use ag0aep6g. :) Thanks, but I don't really care for the recognition. If anything, please use ag0aep6g.

Re: Code improvement for DNA reverse complement?

2017-05-25 Thread Ali Çehreli via Digitalmars-d-learn
On 05/22/2017 03:35 AM, ag0aep6g wrote: > But Ali Çehreli covers it in his book on the "immutability" page (I > would have expected to find it on the "enum" page): > > http://ddili.org/ders/d.en/const_and_immutable.html#ix_const_and_immutable.enum Thank you for your feedback. I'm inserting a

Re: Any way to reproduce Dart style constructors?

2017-05-25 Thread ag0aep6g via Digitalmars-d-learn
On 05/25/2017 09:15 PM, Moritz Maxeiner wrote: Ok, you are right. Open a bug report? Sure. https://issues.dlang.org/show_bug.cgi?id=17435

Re: Searching strings with indexOf vs countUntil

2017-05-25 Thread Stanislav Blinov via Digitalmars-d-learn
On Thursday, 25 May 2017 at 18:13:15 UTC, Anonymouse wrote: Part of the strings I'm working with can be assumed to be only ASCII, yes. indexOf only wants strings or char[]s, but interestingly if I use the same benchmark but have countUntil work on raw ubyte[]s, it is faster. See

Re: Any way to reproduce Dart style constructors?

2017-05-25 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 25 May 2017 at 19:09:06 UTC, ag0aep6g wrote: [...] Also, simply instantiating a function template inside a class doesn't result in a method. If it did, the function/method should be able to access class members. But it can't: int ft()() { return age; } /* Error: undefined

Re: Any way to reproduce Dart style constructors?

2017-05-25 Thread ag0aep6g via Digitalmars-d-learn
On 05/25/2017 08:14 PM, Moritz Maxeiner wrote: Well, then I guess we need a compiler guy to clear this up, because from my point of view, the template is instantiated within the scope of the class (way before we reach the mixin), nesting the template's scope within the class' scope, which

Re: Any way to reproduce Dart style constructors?

2017-05-25 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 25 May 2017 at 13:53:01 UTC, ag0aep6g wrote: On 05/25/2017 03:13 PM, Moritz Maxeiner wrote: After thinking about this a bit I think I know why it doesn't work without static and it's not a compiler bug. Since --- string AutoConstructor(fields ...)() {} --- is just syntax sugar

Re: Searching strings with indexOf vs countUntil

2017-05-25 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 25 May 2017 at 11:55:21 UTC, Kagamin wrote: I would guess indexOf returns a value suitable for indexing, therefore it counts code units, while countUntil counts range elements - code points in case of a string. Also number of code points is not suitable for indexing an utf8

Re: Mutiple AliasSeq as input to template

2017-05-25 Thread jmh530 via Digitalmars-d-learn
On Thursday, 25 May 2017 at 16:36:45 UTC, jmh530 wrote: [snip] I haven't played around with it fully, but it seems like the following resolves my issue in a sort of manual way: template Process1(A, B) { static if (!isIndex!B) alias Process1 = A; else

Re: site examples

2017-05-25 Thread Seb via Digitalmars-d-learn
On Thursday, 25 May 2017 at 16:07:34 UTC, bachmeier wrote: On Thursday, 25 May 2017 at 15:41:47 UTC, crimaniak wrote: I tried to run an example from the site. Example from https://dlang.org/phobos/std_regex.html#replaceAllInto section. And this is problem number 0: I can't give a link to the

Mutiple AliasSeq as input to template

2017-05-25 Thread jmh530 via Digitalmars-d-learn
I'm trying to process one AliasSeq based on the types in another. I've tried to sketch it out below. However, it doesn't work because when you combine together two AliasSeq's in the template, then it creates one AliasSeq. The only other thing I considered was a staticMap with isIndex, but I

Re: site examples

2017-05-25 Thread bachmeier via Digitalmars-d-learn
On Thursday, 25 May 2017 at 15:41:47 UTC, crimaniak wrote: I tried to run an example from the site. Example from https://dlang.org/phobos/std_regex.html#replaceAllInto section. And this is problem number 0: I can't give a link to the example, only to section. The section can be long, there can

Re: site examples

2017-05-25 Thread Stanislav Blinov via Digitalmars-d-learn
On Thursday, 25 May 2017 at 15:41:47 UTC, crimaniak wrote: It seems to me that examples on the site require additional work and in the current form are counterproductive in terms of attracting new users. https://github.com/dlang/phobos

site examples

2017-05-25 Thread crimaniak via Digitalmars-d-learn
I tried to run an example from the site. Example from https://dlang.org/phobos/std_regex.html#replaceAllInto section. And this is problem number 0: I can't give a link to the example, only to section. The section can be long, there can be more than one example, so it's good to have an anchor

Re: [Starting with D] d2html.d issues an error

2017-05-25 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 25 May 2017 at 15:02:33 UTC, Oleksii wrote: Hi everyone, Could you please help me? I'm get the following error from all.sh: $ /e/D/dmd2/windows/bin/shell.exe all.sh shell 1.05 ..\..\windows\bin\dmd d2html d2html.d(18): Error: module stream is in file 'std\stream.d'

[Starting with D] d2html.d issues an error

2017-05-25 Thread Oleksii via Digitalmars-d-learn
Hi everyone, Could you please help me? I'm get the following error from all.sh: $ /e/D/dmd2/windows/bin/shell.exe all.sh shell 1.05 ..\..\windows\bin\dmd d2html d2html.d(18): Error: module stream is in file 'std\stream.d' which cannot be read import path[0] =

Re: Any way to reproduce Dart style constructors?

2017-05-25 Thread ag0aep6g via Digitalmars-d-learn
On 05/25/2017 03:13 PM, Moritz Maxeiner wrote: After thinking about this a bit I think I know why it doesn't work without static and it's not a compiler bug. Since --- string AutoConstructor(fields ...)() {} --- is just syntax sugar for --- template AutoConstructor(fields ...) { string

Re: Any way to reproduce Dart style constructors?

2017-05-25 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 25 May 2017 at 12:35:57 UTC, Moritz Maxeiner wrote: On Thursday, 25 May 2017 at 11:31:43 UTC, ag0aep6g wrote: On 05/25/2017 12:52 PM, Moritz Maxeiner wrote: Be aware, though, that constructors mixed in via a mixin template behave differently with regards to overloading[1]. [1]

Re: Sorted sequences

2017-05-25 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 25 May 2017 at 10:39:01 UTC, Russel Winder wrote: C++ has std:priority_queue as a wrapper around a heap to create a sorted queue. Am I right in thinking that D has no direct equivalent, that you have to build you own wrapper around a heap? Do you even need a wrapper? Glancing

Re: Searching strings with indexOf vs countUntil

2017-05-25 Thread Basile B. via Digitalmars-d-learn
On Thursday, 25 May 2017 at 11:55:21 UTC, Kagamin wrote: I would guess indexOf returns a value suitable for indexing, therefore it counts code units, while countUntil counts range elements - code points in case of a string. Also number of code points is not suitable for indexing an utf8

Re: Any way to reproduce Dart style constructors?

2017-05-25 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 25 May 2017 at 11:31:43 UTC, ag0aep6g wrote: On 05/25/2017 12:52 PM, Moritz Maxeiner wrote: Be aware, though, that constructors mixed in via a mixin template behave differently with regards to overloading[1]. [1] https://issues.dlang.org/show_bug.cgi?id=11500 Of course it

Re: Any way to reproduce Dart style constructors?

2017-05-25 Thread Seb via Digitalmars-d-learn
On Thursday, 25 May 2017 at 11:31:43 UTC, ag0aep6g wrote: On 05/25/2017 12:52 PM, Moritz Maxeiner wrote: [...] Of course it couldn't be that simple :( Adam's workaround (`alias __ctor = mixin_thing.__ctor;`) might be workable, though. [...] FWIW if this is properly working (e.g. with

Re: Searching strings with indexOf vs countUntil

2017-05-25 Thread Kagamin via Digitalmars-d-learn
I would guess indexOf returns a value suitable for indexing, therefore it counts code units, while countUntil counts range elements - code points in case of a string. Also number of code points is not suitable for indexing an utf8 string, it can be used to allocate a dstring, but not so much

Re: Any way to reproduce Dart style constructors?

2017-05-25 Thread ag0aep6g via Digitalmars-d-learn
On 05/25/2017 12:52 PM, Moritz Maxeiner wrote: Be aware, though, that constructors mixed in via a mixin template behave differently with regards to overloading[1]. [1] https://issues.dlang.org/show_bug.cgi?id=11500 Of course it couldn't be that simple :( Adam's workaround (`alias __ctor =

Re: Any way to reproduce Dart style constructors?

2017-05-25 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 25 May 2017 at 10:42:00 UTC, ag0aep6g wrote: On 05/25/2017 10:34 AM, JN wrote: class Person { string name; int age; mixin(AutoConstructor!(age, name)); } [...] I am not looking for code, I can try that myself, just asking if such things are possible? I know you're not

Re: Any way to reproduce Dart style constructors?

2017-05-25 Thread ag0aep6g via Digitalmars-d-learn
On 05/25/2017 10:34 AM, JN wrote: class Person { string name; int age; mixin(AutoConstructor!(age, name)); } [...] I am not looking for code, I can try that myself, just asking if such things are possible? I know you're not asking for code, but without experimenting I wouldn't have

Sorted sequences

2017-05-25 Thread Russel Winder via Digitalmars-d-learn
C++ has std:priority_queue as a wrapper around a heap to create a sorted queue. Am I right in thinking that D has no direct equivalent, that you have to build you own wrapper around a heap? -- Russel. = Dr Russel Winder

Re: Any way to reproduce Dart style constructors?

2017-05-25 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 25 May 2017 at 08:34:54 UTC, JN wrote: One of my favourite language features of Dart (other one being factory constructors) are auto-assign constructors, for example (writing it in pseudo-D): class Person { string name; int age; this(this.age, this.name); } would translate

Searching strings with indexOf vs countUntil

2017-05-25 Thread Anonymouse via Digitalmars-d-learn
I was profiling my program with callgrind and saw that a lot of time was spent in countUntil (std.algorithm.searching) on strings. I had chosen to use it instead of indexOf (std.string), with the plain assumption that countUntil wouldn't decode, while indexOf would. Comparing microbenchmarks

Re: Any way to reproduce Dart style constructors?

2017-05-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 25 May 2017 at 08:34:54 UTC, JN wrote: One of my favourite language features of Dart (other one being factory constructors) are auto-assign constructors, for example (writing it in pseudo-D): class Person { string name; int age; this(this.age, this.name); } would translate

Any way to reproduce Dart style constructors?

2017-05-25 Thread JN via Digitalmars-d-learn
One of my favourite language features of Dart (other one being factory constructors) are auto-assign constructors, for example (writing it in pseudo-D): class Person { string name; int age; this(this.age, this.name); } would translate to class Person { string name; int age;