On Tuesday, 14 November 2017 at 19:57:54 UTC, ade90036 wrote:
socket.send("HTTP/1.1 200 OK
Server:
dland:v2.076.1
Date: Tue, 11
Nov 2017 15:56:02 GMT
On Tuesday, 14 November 2017 at 19:57:54 UTC, ade90036 wrote:
while(true) {
listeningSet.add(listener);
if (Socket.select(listeningSet, null, null,
dur!"nsecs"(150)) > 0) {
Why do you ever timeout? This loop consumes 100 % (a single core)
when idle on my machi
On Wednesday, 15 November 2017 at 14:22:51 UTC, Daniel Kozak
wrote:
And this one
https://paste.ofcode.org/KNqxcrmACLZLseB45MvwC
I thrash your code with two shell processes
```
while true; do curl 127.0.0.1: -o /dev/null; done
```
running parallel. Using strace -fFeclose on the binary
On Wednesday, 15 November 2017 at 13:31:46 UTC, Daniel Kozak
wrote:
This one works ok for me, but I am on linux:
https://dpaste.dzfl.pl/f54decee45bc
It works, but it does not handle two connects in parallel. STR:
1. start the binary in console 1
2. telnet localhost in console 2
3. telnet
On Thursday, 16 November 2017 at 19:37:31 UTC, ade90036 wrote:
Can we enable some sort of profiling to see what is going on?
You may compile the code with dmd -g -O -profile -profile=gc
I currently struggle getting meaningful output. I want to
terminate the program after a number (say 400) ha
On Friday, 17 November 2017 at 14:28:38 UTC, kdevel wrote:
On Thursday, 16 November 2017 at 19:37:31 UTC, ade90036 wrote:
Can we enable some sort of profiling to see what is going on?
You may compile the code with dmd -g -O -profile -profile=gc
I currently struggle getting meaningful output.
This program
```
void aa_stat(T, U) (T[U] aa)
{
import std.stdio;
writefln ("aa: %s", aa);
writefln ("aa.length : %d", aa.length);
writefln ("aa.keys : %s", aa.keys);
writefln ("aa.values : %s", aa.values);
foreach (k, v; aa)
writeln (k, ": ", v);
}
void main ()
On Friday, 1 December 2017 at 00:42:00 UTC, H. S. Teoh wrote:
Here's the fix:
https://github.com/dlang/druntime/pull/1980
Great. By the way: It it true, that there cannot be more than
2^32 keys in an associative array (due to the use of uint)?
On Friday, 1 December 2017 at 00:42:00 UTC, H. S. Teoh wrote:
Here's the fix:
https://github.com/dlang/druntime/pull/1980
And wouldn't it be reasonable to add
assert(aa.values == [ "b" ]);
to the unittest?
On Friday, 1 December 2017 at 16:23:33 UTC, H. S. Teoh wrote:
On Fri, Dec 01, 2017 at 04:06:50PM +, kdevel via
Digitalmars-d-learn wrote:
On Friday, 1 December 2017 at 00:42:00 UTC, H. S. Teoh wrote:
> Here's the fix:
>
> https://github.com/dlang/druntime/pull/1980
And
On Friday, 1 December 2017 at 17:02:48 UTC, H. S. Teoh wrote:
[...]
There is at least 1 use case in the bugzilla issue that
justifies AA literals with (possibly) duplicated keys:
https://issues.dlang.org/show_bug.cgi?id=15290#c1
Code snippet:
---
foreach (i; 0..10)
foreach (j;
On Saturday, 2 December 2017 at 00:41:19 UTC, Wanderer wrote:
I wonder why `scope(exit)` code is not executed when the
program is terminated with Ctrl-C.
Which OS?
For example:
```
import std.stdio;
import core.thread;
void main()
{
scope (exit)
{
writeln("Cleanup");
}
On Sunday, 3 December 2017 at 05:49:54 UTC, Fra Mecca wrote:
I have this code:
Configuration conf = void ;
try {
conf = parse_config("config.sdl");
} catch (Exception e) {
std.stdio.stderr.writeln("Error reading configuration
file: ", e.msg);
exit(1);
}
On Sunday, 3 December 2017 at 14:16:42 UTC, kdevel wrote:
int main ()
{
try {
real_main ();
}
catch (Exception e) {
std.stdio.stderr.writeln(e.msg);
return 1;
}
return 0;
}
```
This is better:
int main ()
{
try {
return real_main ();
}
catch (Exc
On Sunday, 3 December 2017 at 14:58:03 UTC, Basile B. wrote:
In this case i'd go for a typed pointer, e.g
---
immutable struct Configuration
{
this(string){/*load some file...*/}
int value;
}
Configuration* config;
void main()
{
try config = new Configuration("config.sdl");
cat
On Sunday, 3 December 2017 at 23:29:01 UTC, Basile B. wrote:
On Sunday, 3 December 2017 at 22:33:40 UTC, kdevel wrote:
On Sunday, 3 December 2017 at 14:58:03 UTC, Basile B. wrote:
In this case i'd go for a typed pointer, e.g
---
immutable struct Configuration
{
this(string){/*load some fil
On Monday, 4 December 2017 at 11:05:22 UTC, Vino wrote:
On Monday, 4 December 2017 at 10:46:03 UTC, rikki cattermole
wrote:
FunTest.d(52): Error: template FunTest.ptProcessFiles cannot
deduce function from argument types !()(string,
Array!(Tuple!(string, string)) function(string FFs,
string
On Tuesday, 5 December 2017 at 17:25:57 UTC, Steven Schveighoffer
wrote:
[...]
struct LowerCaseFirst(R) // if(isSomeString!R)
{
R src;
bool notFirst; // terrible name, but I want default false
dchar front() {
import std.uni: toLower;
return notFirst ? src.front : src.front.t
Given the functions void foo() and void bar() in their source
files mymod/foo.d and mymod/bar.d. Also I have a
mymod/package.d
```
module mymod;
public import foo : foo;
public import bar : bar;
```
and a client to the library:
main.d
```
import mymod;
void main ()
{
foo;
bar;
}
```
I
On Thursday, 7 December 2017 at 17:36:22 UTC, Neia Neutuladh
wrote:
If you have a source tree like:
pierce/
db/
core.d
controllers/
feed.d
then feed.d can have `import pierce.db.core;` instead of people
being confused about how to refer to the parent directory in a
relative import
On Thursday, 7 December 2017 at 17:58:38 UTC, ag0aep6g wrote:
On 12/07/2017 06:53 PM, kdevel wrote:
Does that mean, that though the code is bundled in one library
(libmymod.a) for the prototypes one has as many .di files as
there
were source files?
yes
Gosh! So in my example I need the fol
On Tuesday, 19 September 2017 at 06:32:52 UTC, Nordlöw wrote:
I want something straight forward without allot of plumbing on
my end.
https://github.com/msgpack/msgpack-d
I can't unittest my 32-bit code:
$ MODEL=32 make -f posix.mak unittest
[...]
src/msgpack/packer.d(1139): Error: function
crash.d
```
import std.stdio;
union U {
float f;
int i;
string toString ()
{
string s;
return s;
}
}
void main ()
{
U u;
writeln (u);
}
```
$ dmd crash.d
$ ./crash
std.exception.ErrnoException@/.../dmd2/linux/bin64/../../src/phobos/std/stdio.d(2776):
(Bad add
Thanks for the quick answer!
On Friday, 12 January 2018 at 02:16:39 UTC, Adam D. Ruppe wrote:
On Friday, 12 January 2018 at 00:54:03 UTC, kdevel wrote:
$ dmd crash.d
$ ./crash
Nicholas Wilson is right that you can use = "" to work around
it, but with strings, null is supposed to behave the s
suffix.d
```
void main ()
{
real r = 1.L;
float f = 1.f;
}
```
$ dmd suffix.d
suffix.d(3): Error: no property 'L' for type 'int'
suffix.d(4): Error: no property 'f' for type 'int'
According to the grammar in dmd2/html/d/spec/lex.html both are
valid FloatLiterals. Any comments?
On Friday, 12 January 2018 at 12:45:59 UTC, kdevel wrote:
suffix.d
```
void main ()
{
real r = 1.L;
float f = 1.f;
}
```
$ dmd suffix.d
suffix.d(3): Error: no property 'L' for type 'int'
suffix.d(4): Error: no property 'f' for type 'int'
According to the grammar in dmd2/html/d/spec/lex.ht
occasion:
http://forum.dlang.org/thread/mutegviphsjwqzqfo...@forum.dlang.org?page=3#post-mailman.2136.1515709204.9493.digitalmars-d-announce:40puremagic.com
dmd checks the types but does not count the arguments.
ctcfs.d
```
import std.stdio;
import std.math;
void unit (T) ()
{
auto pi = 4 *
On Saturday, 13 January 2018 at 19:40:09 UTC, Adam D. Ruppe wrote:
For ints, it catches all that, but for float, it just bails out
of the check as soon as it actually *succeeds* - because that
kills CTFE.
Confirmed. Thanks!
args.d
```
import std.stdio;
void main ()
{
// writefln!"%2.2d %2.
fusp.d
```
import std.stdio;
import std.typecons;
void foo (T) ()
{
writeln ("(1) foo T = ", T.stringof);
}
void foo (T : float) ()
{
writeln ("(2) foo T = ", T.stringof);
}
// void foo (T : double) ()
// {
//writeln ("(2) foo T = ", T.stringof);
// }
void main ()
{
foo!float;
On Sunday, 14 January 2018 at 00:30:37 UTC, Nicholas Wilson wrote:
The usual way to do what you are trying to do is with template
constraints.
void foo(T)() if (is(T== float)) { ...}
Thanks. That works but looks a bit ugly. Am I right that I have
to leave out the primary (unconstrained) temp
On Sunday, 14 January 2018 at 02:24:52 UTC, Adam D. Ruppe wrote:
On Sunday, 14 January 2018 at 02:14:50 UTC, Jonathan M Davis
wrote:
If you're using template constraints rather than template
specializations, then you can't have any unconstrained
templates.
Not true: see the tip of the week he
vartmpl.d
```
import std.stdio : writeln;
import decimal : decimal32;
template F(T) {
immutable T c = 3;
}
void foo (T) ()
{
immutable T t = 1;
}
void main ()
{
// immutable decimal32 i = 1; // Error: none of the overloads
of '__ctor' are
callable using a immutable object
// foo!dec
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 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 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, 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 th
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 defa
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 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, 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 Sunday, 28 January 2018 at 19:17:49 UTC, Steven Schveighoffer
wrote:
This is insane. i > 0 is used in so many places. The only
saving grace appears to be that int.min is just so uncommonly
seen in the wild.
And another one that it does not happen when compiled with
optimization (-O) and al
Is there a D equivalent of the C++ at method? I would like to
reformulate
repro2.d
---
void main ()
{
import std.stdio;
import std.container;
import std.range;
auto z = Array!char();
z.reserve(0xC000_);
z.capacity.writeln;
z.length.writeln;
for (uint u = 0; u < 0xC000
I don't get the point of the deprecation message:
--- intprom.d
import std.stdio;
void main ()
{
short s, t;
t = -s;
}
---
$ dmd intprom.d
intprom.d(6): Deprecation: integral promotion not done for -s,
use '-transition=intpromote' switch or -cast(int)(s)
What shall I do in order to get
On Saturday, 24 February 2018 at 20:17:12 UTC, Steven
Schveighoffer wrote:
On 2/24/18 3:07 PM, kdevel wrote:
I don't get the point of the deprecation message:
--- intprom.d
import std.stdio;
void main ()
{
short s, t;
t = -s;
}
---
https://dlang.org/changelog/2.078.0.html#fix16997
On Saturday, 24 February 2018 at 22:30:09 UTC, Steven
Schveighoffer wrote:
The prime example is this:
byte b = -128;
int x = -b;
What would you expect x to be?
a) 128
b) -128
Neither nor. I would prefer the codomain of "-" be the range of
byte
and hence an exception thrown in that case.
A code fragment using static foreach
https://forum.dlang.org/thread/jiefcxwqbjzqnmtaz...@forum.dlang.org#post-beruryblsptnunsowjph:40forum.dlang.org
does not compile with the current GDC (GCC 4.9.4 and 5.5.0). I
tried to encapsulate this code into a version block but GDC still
checks the synta
On Thursday, 29 March 2018 at 15:16:07 UTC, Ivan Kazmenko wrote:
import std.stdio;
void main () {
int delegate () [] funs;
funs ~= () => 0;
funs ~= () => 1;
foreach (i; 0..2) writeln (funs[i] ()); // 0 and 1 as expected
int delegate () [] guns;
fo
On Thursday, 29 March 2018 at 20:05:35 UTC, ag0aep6g wrote:
On Thursday, 29 March 2018 at 19:02:51 UTC, kdevel wrote:
On Thursday, 29 March 2018 at 15:16:07 UTC, Ivan Kazmenko
wrote:
[...]
int delegate () [] guns;
foreach (i; 0..2) guns ~= () => i;
foreach (i; 0..2) wri
Why are people writing
import std.stdio;
void main ()
{
S s;
s.foo;
}
struct S {
void foo ()
{
writeln ("a");
}
}
but not
void main ()
{
S s;
s.foo;
}
struct S {
void foo ()
{
writeln ("a");
On Wednesday, 4 April 2018 at 19:19:30 UTC, Ali wrote:
On Wednesday, 4 April 2018 at 18:57:27 UTC, kdevel wrote:
[...]
I think the rules should have been the same everywhere
and if there was an exception to be made, it could be made for
the main function
since the main function is special anywa
On Saturday, 1 October 2016 at 15:00:29 UTC, pineapple wrote:
Though I don't currently have any need for this feature I'd
imagine that if I did I'd want the time in UTC, not locally
You may invoke the compiler with TZ= prepended. (Linux)
On Thursday, 19 September 2024 at 14:30:08 UTC, Gerardo Cahn
wrote:
I am using the code listed here.
It should be left to posterity that the code presented in this
thread cannot properly escape
```
"A\xfeZ"
```
```
BV's escape: cast(char) 0x41, cast(char) 0xFE, cast(char) 0x5A
steve's: c
On Friday, 8 November 2024 at 21:55:53 UTC, Liam McGillivray
wrote:
I am working on a library for making types representing units
of measurement. Base units [...]
```
[...]
enum Milligrams : BaseUnit!Milligrams;
enum Millimoles : BaseUnit!Millimoles;
[...]
```
Shouldn't (base) units be named
On Wednesday, 18 December 2024 at 22:16:45 UTC, John Dougan wrote:
[...]
which isn't what I want. The case for `test(1)` is fine. For
`test(2))` I want the `scope exit 2` to come after the `F`.
```
int test(int val)
{
writeln("A");
if (val % 2 == 0)
{
writeln("b");
On Wednesday, 9 April 2025 at 01:23:01 UTC, Salih Dincer wrote:
On Tuesday, 8 April 2025 at 20:14:56 UTC, Andy Valencia wrote:
p.s. Ironically, I could probably have coded a getopt in less
time than I've spent on std.getopt...
:)
Please try the following example with the parameters -h, -e,
```d
//
// bs3.d
// 2025-05-05 stvo
//
// $ dmd -g -checkaction=context -unittest -main -run bs3.d
// bs3.d(25): [unittest] [4, 3, 3, 4] != [4, 3, 2, 1]
// 1/1 modules FAILED unittests
//
auto foo (ubyte [4] s)
{
auto u = s;
ubyte [4] tmp = u;
u[0] = tmp [3];
u[1] = tmp [2];
u[2] =
On Tuesday, 6 May 2025 at 01:29:35 UTC, Steven Schveighoffer
wrote:
On Monday, 5 May 2025 at 17:15:57 UTC, kdevel wrote:
```d
//
// bs3.d
// 2025-05-05 stvo
//
// $ dmd -g -checkaction=context -unittest -main -run bs3.d
// bs3.d(25): [unittest] [4, 3, 3, 4] != [4, 3, 2, 1]
```
This is a bug, p
On Thursday, 24 April 2025 at 14:04:03 UTC, Andy Valencia wrote:
[...]
Phobos appears to try and inhibit this on some BSD systems,
How does it do that?
but on Linux if the recipient has closed the socket and [the
OPs process running his progam] write[s]--SIGPIPE.
"the whole point of the sig
On Wednesday, 5 March 2025 at 16:58:18 UTC, Kirill Kryukov wrote:
Is this a bug, or am I misunderstanding something?
Compiled with "gdc -Og -o repro repro.d", using gdc (GCC)
14.2.1 20240912 (Red Hat 14.2.1-3), on Linux.
Compiled your code with DMD v2.109.1, gdc (GCC) 11.3.0 and gdc
(GCC) 12
On Friday, 16 May 2025 at 19:19:41 UTC, H. S. Teoh wrote:
For example, how do you negate a ubyte?
Mathematically this is only defined for 0 over the range of
ubyte.
Obviously, you can't do this:
```
ubyte a;
a -=;
```
But writing it as `a = -a;` runs into the same error, for
On Monday, 5 May 2025 at 17:15:57 UTC, kdevel wrote:
```
auto foo (ubyte [4] s)
{
auto u = s;
ubyte [4] tmp = u;
```
When I put `shared` in front of that definition the unittest
passes.
```
u[0] = tmp [3];
u[1] = tmp [2];
u[2] = tmp [1];
u[3] = tmp [0];
return u;
}
```
```D
import std;
import core.sys.posix.unistd : sleep;
void foo (size_t i)
{
writeln (i);
sleep (1);
writefln ("thread %d end", i);
}
void main (string [] args)
{
auto nthreads = args [1].to!size_t;
Tid [] threads;
foreach (i; 0 .. nthreads)
threads ~= spawn (&foo, i);
On Wednesday, 17 September 2025 at 22:16:50 UTC, Brother Bill
wrote:
return value => increment + value; // ← compilation ERROR
```d
void main()
{
auto calc = makeCalculator;
writeln (calc (1));
}
alias Calculator = int function(int);
Calculator makeCalculator()
{
301 - 367 of 367 matches
Mail list logo