Assert and undefined behavior

2017-10-11 Thread John Burton via Digitalmars-d-learn
The spec says this :- "As a contract, an assert represents a guarantee that the code must uphold. Any failure of this expression represents a logic error in the code that must be fixed in the source code. A program for which the assert contract is false is, by definition, invalid, and

Re: Huge increase in UT compile time

2017-10-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, October 11, 2017 06:25:19 Dhananjay via Digitalmars-d-learn wrote: > Hello, > > I am upgrading to DMD 2.076.1 from DMD 2.069.2 (similar results > on 2.075.1), and seeing a huge increase in unittest compilation > time when the -deps parameter is also passed to dmd. This is on > both

Re: Assert and undefined behavior

2017-10-11 Thread user1234 via Digitalmars-d-learn
On Wednesday, 11 October 2017 at 09:27:49 UTC, John Burton wrote: [...] I therefore feel like I ought to not use assert and should instead validate my assumptions with an if statement and a throw or exit or something. Yes, that's the way of doing. assert() are just used to test the program.

Re: Assert and undefined behavior

2017-10-11 Thread rikki cattermole via Digitalmars-d-learn
On 11/10/2017 10:27 AM, John Burton wrote: The spec says this :- "As a contract, an assert represents a guarantee that the code must uphold. Any failure of this expression represents a logic error in the code that must be fixed in the source code. A program for which the assert contract is

Re: Why do I have to cast arguments from int to byte?

2017-10-11 Thread Daniel Kozak via Digitalmars-d-learn
You can avoid cast: void foo(T)(T bar){...} byte bar = 9; foo!byte(bar + byte(1)); or byte bar = 9; byte num = 1; foo!byte(bar + num); On Tue, Oct 10, 2017 at 9:55 PM, Chirs Forest via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > I keep having to make casts like the

Re: struct/class generation

2017-10-11 Thread rikki cattermole via Digitalmars-d-learn
On 11/10/2017 12:37 PM, ANtlord wrote: Hello dear community! I've met a little issue. How can I generate struct or class copying some fields and methods from another struct or class? I've found methods to get fields. They are std.traits.FieldNameTuple and std.traits.FieldTypeTuple but I

Re: std.concurrency.setMaxMailboxSize

2017-10-11 Thread rikki cattermole via Digitalmars-d-learn
On 11/10/2017 12:09 PM, RazvanN wrote: Hi all, I have seen that the concurrency api has this method specified in $title [1] and I was wondering what is the use of it? Enabling threads to modify the message box of other threads doesn't seem to be a good idea and I can't think of any real use

struct/class generation

2017-10-11 Thread ANtlord via Digitalmars-d-learn
Hello dear community! I've met a little issue. How can I generate struct or class copying some fields and methods from another struct or class? I've found methods to get fields. They are std.traits.FieldNameTuple and std.traits.FieldTypeTuple but I can't find a method allows getting methods

Re: struct/class generation

2017-10-11 Thread drug via Digitalmars-d-learn
11.10.2017 14:37, ANtlord пишет: Hello dear community! I've met a little issue. How can I generate struct or class copying some fields and methods from another struct or class? I've found methods to get fields. They are std.traits.FieldNameTuple and std.traits.FieldTypeTuple but I can't find

Re: Assert and undefined behavior

2017-10-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, October 11, 2017 09:27:49 John Burton via Digitalmars-d-learn wrote: > The spec says this :- > > "As a contract, an assert represents a guarantee that the code > must uphold. Any failure of this expression represents a logic > error in the code that must be fixed in the source code.

Re: std.concurrency.setMaxMailboxSize

2017-10-11 Thread rikki cattermole via Digitalmars-d-learn
On 11/10/2017 12:43 PM, RazvanN wrote: On Wednesday, 11 October 2017 at 11:26:11 UTC, rikki cattermole wrote: On 11/10/2017 12:09 PM, RazvanN wrote: Hi all, I have seen that the concurrency api has this method specified in $title [1] and I was wondering what is the use of it? Enabling

Two way struct wrapper

2017-10-11 Thread drug via Digitalmars-d-learn
Using `alias this` it's easy to make wrapper for structure that calls wrapped structure methods like its own. This is one way - from wrapper to wrapped transformation. Is it possible to create the opposite way from wrapped to wrapper? https://run.dlang.io/is/Avyu3I All calls to Bar is

Re: Fast removal of character

2017-10-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/11/17 7:06 PM, Johan Engelen wrote: On Wednesday, 11 October 2017 at 22:45:14 UTC, Jonathan M Davis wrote: On Wednesday, October 11, 2017 22:22:43 Johan Engelen via Digitalmars-d- learn wrote: std.string.removechars is now deprecated.

Re: How to call function with variable arguments at runtime?

2017-10-11 Thread Mr. Jonse via Digitalmars-d-learn
On Tuesday, 10 October 2017 at 08:26:37 UTC, Marc Schütz wrote: On Tuesday, 10 October 2017 at 02:58:45 UTC, Mr. Jonse wrote: I need to store a hetrogeneous array of delegates. How can I do this but still call the function with the appropriate number of parameters at run time? I have the

Re: Fast removal of character

2017-10-11 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 11 October 2017 at 22:45:14 UTC, Jonathan M Davis wrote: On Wednesday, October 11, 2017 22:22:43 Johan Engelen via Digitalmars-d- learn wrote: std.string.removechars is now deprecated. https://dlang.org/changelog/2.075.0.html#pattern-deprecate What is now the most efficient way

Re: Fast removal of character

2017-10-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, October 11, 2017 23:06:13 Johan Engelen via Digitalmars-d- learn wrote: > I am disappointed to see functions being deprecated, without an > extensive documentation of how to rewrite them for different > usage of the deprecated function. It makes me feel that no deep > thought went

Fast removal of character

2017-10-11 Thread Johan Engelen via Digitalmars-d-learn
std.string.removechars is now deprecated. https://dlang.org/changelog/2.075.0.html#pattern-deprecate What is now the most efficient way to remove characters from a string, if only one type of character needs to be removed? ``` // old auto old(string s) { return s.removechars(",").to!int;

Re: Fast removal of character

2017-10-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, October 11, 2017 22:22:43 Johan Engelen via Digitalmars-d- learn wrote: > std.string.removechars is now deprecated. > https://dlang.org/changelog/2.075.0.html#pattern-deprecate > > What is now the most efficient way to remove characters from a > string, if only one type of character

Dustmite always reduced to empty set after two iterations

2017-10-11 Thread Nordlöw via Digitalmars-d-learn
Once again I need to pick up Dustmite to track down a DMD and LDC ICE in release mode for my project. But I can't figure out how call Dustmite correctly: When I build https://github.com/nordlow/phobos-next as /usr/bin/dub build --compiler=dmd --build=release it prints Performing

Re: Undo?

2017-10-11 Thread Mr. Jonse via Digitalmars-d-learn
A simple(incomplete) undo system. I'm curious about the overhead. The idea is to wrap any system changes using the Add function. This function stores both the forward and backward state changes using delegates. By using forward, we call the action passed to set the data and backward will

Re: Dustmite always reduced to empty set after two iterations

2017-10-11 Thread Vladimir Panteleev via Digitalmars-d-learn
On Wednesday, 11 October 2017 at 20:36:58 UTC, Nordlöw wrote: What am I doing wrong? Invoking dub from dustmite probably isn't going to work well. Instead, try using dub's dustmite command: https://code.dlang.org/docs/commandline#dustmite

Re: struct/class generation

2017-10-11 Thread Daniel Kozak via Digitalmars-d-learn
If you just want to not repeat fields and methods you can use alias this or mixins: https://run.dlang.io/is/0UkjTe On Wed, Oct 11, 2017 at 2:07 PM, drug via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > 11.10.2017 14:37, ANtlord пишет: > > Hello dear community! >> >> I've met

Re: std.concurrency.setMaxMailboxSize

2017-10-11 Thread RazvanN via Digitalmars-d-learn
On Wednesday, 11 October 2017 at 11:26:11 UTC, rikki cattermole wrote: On 11/10/2017 12:09 PM, RazvanN wrote: Hi all, I have seen that the concurrency api has this method specified in $title [1] and I was wondering what is the use of it? Enabling threads to modify the message box of other

std.concurrency.setMaxMailboxSize

2017-10-11 Thread RazvanN via Digitalmars-d-learn
Hi all, I have seen that the concurrency api has this method specified in $title [1] and I was wondering what is the use of it? Enabling threads to modify the message box of other threads doesn't seem to be a good idea and I can't think of any real use case. Best regards, RazvanN [1]

Re: Assert and undefined behavior

2017-10-11 Thread Ali Çehreli via Digitalmars-d-learn
On 10/11/2017 02:27 AM, John Burton wrote: > The spec says this :- > > "As a contract, an assert represents a guarantee that the code must > uphold. Any failure of this expression represents a logic error in the > code that must be fixed in the source code. A program for which the > assert

Re: Assert and undefined behavior

2017-10-11 Thread Eduard Staniloiu via Digitalmars-d-learn
On Wednesday, 11 October 2017 at 09:39:04 UTC, user1234 wrote: On Wednesday, 11 October 2017 at 09:27:49 UTC, John Burton wrote: [...] I therefore feel like I ought to not use assert and should instead validate my assumptions with an if statement and a throw or exit or something. Yes,

Huge increase in UT compile time

2017-10-11 Thread Dhananjay via Digitalmars-d-learn
Hello, I am upgrading to DMD 2.076.1 from DMD 2.069.2 (similar results on 2.075.1), and seeing a huge increase in unittest compilation time when the -deps parameter is also passed to dmd. This is on both OSX and linux. What can be the cause of this? Sample program: import std.stdio:

Re: Huge increase in UT compile time

2017-10-11 Thread Dhananjay via Digitalmars-d-learn
Another observation: wc -l test.dep (for "-deps=test.dep ... -unittest -main" command): Linux 2.076.1: 41389 Linux 2.069.1: 144 Making small changes to 2.069.1 runtimes (I had run with a different program by mistake. The measurement is still of the same order) On Wednesday, 11 October 2017