On Friday, 26 January 2018 at 21:17:14 UTC, Oleksii Skidan wrote:
struct Game {
Triangle player = new Triangle;
When you initialize a struct member like this, compiler tries to
calculate the initial value and remember it as data, so each time
such struct is constructed the data is just c
On Saturday, 27 January 2018 at 08:18:07 UTC, thedeemon wrote:
On Friday, 26 January 2018 at 21:17:14 UTC, Oleksii Skidan
wrote:
struct Game {
Triangle player = new Triangle;
When you initialize a struct member like this, compiler tries
to calculate the initial value and remember it as
Hi All,
Is there a way to rewrite this
```
import std.parallelism;
auto pool = new TaskPool(options.threadCount);
foreach (_; 0 .. options.iterationCount) {
switch (options.operation) {
case Operation.a:
pool.put(task!a(options));
break;
On Saturday, 27 January 2018 at 10:28:10 UTC, Arun Chandrasekaran
wrote:
Hi All,
Is there a way to rewrite this
[...]
Damn! The subject should've been something else.. naming is
surely hard..
On Saturday, 27 January 2018 at 10:28:10 UTC, Arun Chandrasekaran
wrote:
```
import std.parallelism;
auto pool = new TaskPool(options.threadCount);
foreach (_; 0 .. options.iterationCount) {
switch (options.operation) {
static foreach(e; EnumMembers!Operation) {
On Saturday, 27 January 2018 at 10:38:25 UTC, Nicholas Wilson
wrote:
On Saturday, 27 January 2018 at 10:28:10 UTC, Arun
Chandrasekaran wrote:
```
import std.parallelism;
auto pool = new TaskPool(options.threadCount);
foreach (_; 0 .. options.iterationCount) {
switch (options.
On Saturday, 27 January 2018 at 10:49:45 UTC, Arun Chandrasekaran
wrote:
On Saturday, 27 January 2018 at 10:38:25 UTC, Nicholas Wilson
wrote:
...
[snip]
Simplified test case that still errors:
```
enum Operation {
a,
b
}
import std.traits;
import std.conv;
void main(string[] args) {
On Friday, 26 January 2018 at 20:13:14 UTC, Simen Kjærås wrote:
I can't reproduce the problem. Could you give us some more code
- preferably a compilable segment that gives the same problem?
--
Simen
https://github.com/Dechcaudron/dserialize/tree/6c67e44dedf81d9cb8c0d9d80cf4eb85e9abecd0
Th
https://dlang.org/phobos/std_exception.html#enforce and also
https://dlang.org/library/std/exception/enforce.html present this
example:
---
auto f = enforce(fopen("data.txt"));
auto line = readln(f);
enforce(line.length, "Expected a non-empty line.");
---
fopen, readln and enforce need imports
https://dlang.org/phobos/std_exception.html#enforce states:
| Also, do not use enforce inside of contracts (i.e. inside of in
and out blocks
| and invariants), because they will be compiled out when
compiling with -release.
| Use assert in contracts.
But assert is also ignored in release mode
I would expect this code
enforce3.d
---
import std.exception;
void main ()
{
int i = int.min;
enforce (i > 0);
}
---
to throw an "Enforcement failed" exception, but it doesn't:
$ dmd enforce3.d
$ ./enforce3
[nothing]
On Sat, 27 Jan 2018 13:52:47 +, kdevel wrote:
> https://dlang.org/phobos/std_exception.html#enforce states:
>
> | Also, do not use enforce inside of contracts (i.e. inside of in and
> out blocks | and invariants), because they will be compiled out when
> compiling with -release.
> | Use asser
On 01/27/2018 05:52 AM, kdevel wrote:
> https://dlang.org/phobos/std_exception.html#enforce states:
>
> | Also, do not use enforce inside of contracts (i.e. inside of in and
> out blocks
> | and invariants), because they will be compiled out when compiling with
> -release.
> | Use assert in contra
On Saturday, 27 January 2018 at 14:31:13 UTC, Ali Çehreli wrote:
> But assert is also ignored in release mode:
The documentation is not clear. "they will be compiled out"
means "contracts are compiled out". So, an enforce() would
disappear if it's inside such a block, which should not be what
On 01/27/2018 06:13 AM, kdevel wrote:
I would expect this code
enforce3.d
---
import std.exception;
void main ()
{
int i = int.min;
enforce (i > 0);
}
---
to throw an "Enforcement failed" exception, but it doesn't:
$ dmd enforce3.d
$ ./enforce3
[nothing]
Looks like a major issue t
On 01/27/2018 06:36 AM, kdevel wrote:
On Saturday, 27 January 2018 at 14:31:13 UTC, Ali Çehreli wrote:
> But assert is also ignored in release mode:
The documentation is not clear. "they will be compiled out" means
"contracts are compiled out". So, an enforce() would disappear if it's
inside
On 01/27/2018 03:13 PM, kdevel wrote:
I would expect this code
enforce3.d
---
import std.exception;
void main ()
{
int i = int.min;
enforce (i > 0);
}
---
to throw an "Enforcement failed" exception, but it doesn't:
$ dmd enforce3.d
$ ./enforce3
[nothing]
Wow, that looks really bad
On Saturday, 27 January 2018 at 14:51:23 UTC, Ali Çehreli wrote:
On 01/27/2018 06:36 AM, kdevel wrote:
On Saturday, 27 January 2018 at 14:31:13 UTC, Ali Çehreli
wrote:
> But assert is also ignored in release mode:
The documentation is not clear. "they will be compiled out"
means "contracts ar
On Saturday, 27 January 2018 at 14:49:52 UTC, Ali Çehreli wrote:
But enforce is a red herring there. This prints true with 2.078
as well:
import std.stdio;
void main ()
{
int i = int.min;
writeln(i > 0);// prints 'true' with 2.078
}
test.d
---
import std.stdio;
void main ()
{
On Saturday, January 27, 2018 09:35:05 Oleksii Skidan via Digitalmars-d-
learn wrote:
> On Saturday, 27 January 2018 at 08:18:07 UTC, thedeemon wrote:
> > On Friday, 26 January 2018 at 21:17:14 UTC, Oleksii Skidan
> >
> > wrote:
> >> struct Game {
> >>
> >> Triangle player = new Triangle;
> >
>
On Saturday, January 27, 2018 13:29:00 kdevel via Digitalmars-d-learn wrote:
> What's wrong here? And why is the "selective import" of enforce
> necessary?
Because you named your module enforce. As such, by default, referring to
enforce inside of the module refers to the module. Having the selecti
On Saturday, January 27, 2018 14:59:50 kdevel via Digitalmars-d-learn wrote:
> On Saturday, 27 January 2018 at 14:51:23 UTC, Ali Çehreli wrote:
> > On 01/27/2018 06:36 AM, kdevel wrote:
> >> On Saturday, 27 January 2018 at 14:31:13 UTC, Ali Çehreli
> >>
> >> wrote:
> >>> > But assert is also ignore
On Saturday, 27 January 2018 at 16:19:30 UTC, Jonathan M Davis
wrote:
On Saturday, January 27, 2018 14:59:50 kdevel via
Digitalmars-d-learn wrote:
>>> https://github.com/dlang/phobos/blob/master/std/exception.d
>>
>> "Use $(D assert) in contracts." is still in there.
>
> What's wrong with that?
On Saturday, 27 January 2018 at 05:49:00 UTC, ChrisPiker wrote:
On Saturday, 27 January 2018 at 03:08:29 UTC, Seb wrote:
[...]
Well now libevent_pthreads is missing. Anyway, don't worry
about it we're (finally) switching over to RedHat 7 soon
anyway, deployment is underway, that should bring
On Saturday, 27 January 2018 at 11:19:37 UTC, Arun Chandrasekaran
wrote:
Simplified test case that still errors:
You got really close here. Here's a working version:
enum Operation {
a,
b
}
import std.traits, std.conv, std.stdio;
void main(string[] args) {
auto op = Operation.a;
On Saturday, 27 January 2018 at 16:10:29 UTC, Jonathan M Davis
wrote:
On Saturday, January 27, 2018 13:29:00 kdevel via
Digitalmars-d-learn wrote:
What's wrong here? And why is the "selective import" of
enforce necessary?
Because you named your module enforce. As such, by default,
referring t
On Sat, 27 Jan 2018 17:12:25 +, kdevel wrote:
> This is not a problem, because this is perfectly legal. The problem is
> the wording of this phrase on the docs:
>
> | Also, do not use enforce inside of contracts (i.e. inside of in and
> out blocks | and invariants), because they will be com
On Saturday, January 27, 2018 17:12:25 kdevel via Digitalmars-d-learn wrote:
> Then please explain to me, in which respect the advice to "Use
> assert[s] in contracs" makes sense if the contracts are to be
> compiled out. I don't get it.
The entire point of contracts is to be asserting pre or post
On Saturday, January 27, 2018 17:57:54 kdevel via Digitalmars-d-learn wrote:
> On Saturday, 27 January 2018 at 16:10:29 UTC, Jonathan M Davis
>
> wrote:
> > On Saturday, January 27, 2018 13:29:00 kdevel via
> >
> > Digitalmars-d-learn wrote:
> >> What's wrong here? And why is the "selective import"
On Saturday, 27 January 2018 at 18:00:32 UTC, rjframe wrote:
I think I see what you mean; you interpret "use asserts,
because enforce will be compiled out" to imply that asserts
wouldn't be compiled out, correct?
Is there any other meaningful interpretation?
Since, in reality, both would be c
On Friday, 26 January 2018 at 23:15:41 UTC, Simen Kjærås wrote:
The function is called fill, and assigns a value to every
element in the range. If a[0] = false compiles, we also want
a.fill(false) to compile. It's simply testing that, rather than
caring about the exact type of the elements.
On Saturday, 27 January 2018 at 19:42:01 UTC, Matt wrote:
Godbolt link: https://godbolt.org/g/t5S976
The actual code is :
imul edi, edi
mov eax, edi
ret
The rest is runtime initialization.
which you can remove using an undocumented -betterC switch.
Playing around with Godbolt, D seems to generate an embarassing
amount of assembly for a simple function (50ish for squaring an
int vs 4 for C++ and 7 for Rust). Even Go compiles to less
assembly.
Is there something I'm missing?
Godbolt link: https://godbolt.org/g/t5S976
On Saturday, 27 January 2018 at 19:43:50 UTC, Stefan Koch wrote:
On Saturday, 27 January 2018 at 19:42:01 UTC, Matt wrote:
Godbolt link: https://godbolt.org/g/t5S976
The actual code is :
imul edi, edi
mov eax, edi
ret
The rest is runtime initialization.
which you can remove using an undocu
On Saturday, 27 January 2018 at 18:34:35 UTC, Jonathan M Davis
wrote:
The example still does not compile.
That has nothing to do with enforce. std.stdio.readln does not
take a FILE*. In general, you shouldn't mix core.stdc.stdio and
std.stdio.
The code is from the official documentation:
-
On Saturday, 27 January 2018 at 19:43:50 UTC, Stefan Koch wrote:
On Saturday, 27 January 2018 at 19:42:01 UTC, Matt wrote:
Godbolt link: https://godbolt.org/g/t5S976
The actual code is :
imul edi, edi
mov eax, edi
ret
Could you please paste the source code? I mean in say 5 years
when ther
On Saturday, January 27, 2018 20:11:29 kdevel via Digitalmars-d-learn wrote:
> On Saturday, 27 January 2018 at 18:34:35 UTC, Jonathan M Davis
>
> wrote:
> >> The example still does not compile.
> >
> > That has nothing to do with enforce. std.stdio.readln does not
> > take a FILE*. In general, you
On Saturday, 27 January 2018 at 19:45:35 UTC, Stefan Koch wrote:
ah ... -betterC is only for dmd.
`-betterC` works from LDC 1.1.0.
- Johan
On Saturday, 27 January 2018 at 17:54:53 UTC, thedeemon wrote:
On Saturday, 27 January 2018 at 11:19:37 UTC, Arun
Chandrasekaran wrote:
Simplified test case that still errors:
You got really close here. Here's a working version:
enum Operation {
a,
b
}
import std.traits, std.conv, st
On Friday, 26 January 2018 at 22:40:29 UTC, Timoses wrote:
Program received signal SIGSEGV, Segmentation fault.
0x00432e04 in _d_dso_registry ()
(gdb) bt
#0 0x00432e04 in _d_dso_registry ()
#1 0x00431c63 in ?? ()
#2 0x0045c08b in __libc_csu_init ()
#3 0xb7d8e206 in __libc_start_main (main=0x4
On Saturday, 27 January 2018 at 20:33:46 UTC, Jonathan M Davis
wrote:
Shall I file a bug report?
Yes.
https://issues.dlang.org/show_bug.cgi?id=18319
On 01/27/2018 10:33 AM, kdevel wrote:
I suggest the deletion of the sentence "Use assert in contracts."
Done.
Ali
On Sat, Jan 27, 2018 at 07:41:21PM +, Matt via Digitalmars-d-learn wrote:
> Playing around with Godbolt, D seems to generate an embarassing amount
> of assembly for a simple function (50ish for squaring an int vs 4 for
> C++ and 7 for Rust). Even Go compiles to less assembly.
>
> Is there some
On Saturday, 27 January 2018 at 22:53:37 UTC, Ali Çehreli wrote:
On 01/27/2018 10:33 AM, kdevel wrote:
I suggest the deletion of the sentence "Use assert in
contracts."
Done.
Ali
Wait, no this isn't right, is it? Enforce should not be used in
contracts so the "Use assert in contracts" sta
On Saturday, 27 January 2018 at 19:43:50 UTC, Stefan Koch wrote:
On Saturday, 27 January 2018 at 19:42:01 UTC, Matt wrote:
Godbolt link: https://godbolt.org/g/t5S976
The actual code is :
imul edi, edi
mov eax, edi
ret
The rest is runtime initialization.
which you can remove using an undocu
On 01/27/2018 04:59 PM, lobo wrote:
> On Saturday, 27 January 2018 at 22:53:37 UTC, Ali Çehreli wrote:
>> On 01/27/2018 10:33 AM, kdevel wrote:
>>
>>> I suggest the deletion of the sentence "Use assert in contracts."
>>
>> Done.
>>
>> Ali
>
> Wait, no this isn't right, is it?
It is right because
On Saturday, 27 January 2018 at 19:43:50 UTC, Stefan Koch wrote:
On Saturday, 27 January 2018 at 19:42:01 UTC, Matt wrote:
Godbolt link: https://godbolt.org/g/t5S976
The actual code is :
imul edi, edi
mov eax, edi
ret
The rest is runtime initialization.
which you can remove using an undocu
On 01/27/2018 11:42 AM, Matt wrote:
Godbolt link: https://godbolt.org/g/t5S976
According to that link D and C++ both produce 4 lines of assembly, Rust
7, and Go 38 (for that function).
Ali
On Saturday, 27 January 2018 at 20:49:43 UTC, Arun Chandrasekaran
wrote:
Error: must use labeled break within static foreach
Just follow the compiler suggestion:
void main(string[] args) {
auto op = Operation.a;
foreach (_; 0 .. args.length) {
ops: final switch (op) {
50 matches
Mail list logo