Re: How can I set Timeout of Socket?

2020-11-14 Thread FreeSlave via Digitalmars-d-learn
On Sunday, 15 November 2020 at 00:05:08 UTC, Marcone wrote: Socket s = new Socket(AddressFamily.INET, SocketType.STREAM); s.connect(new InternetAddress("domain.com", 80)); I want that program raise an error if reach for example 30 seconds of timeout. Perhaps using Socket.select and

Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Marcone via Digitalmars-d-learn
On Sunday, 15 November 2020 at 03:15:29 UTC, Anonymouse wrote: On Sunday, 15 November 2020 at 03:08:48 UTC, Marcone wrote: On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote: On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote: auto mytime = Clock.currTime().toUnixTime()

Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Marcone via Digitalmars-d-learn
On Sunday, 15 November 2020 at 03:15:29 UTC, Anonymouse wrote: On Sunday, 15 November 2020 at 03:08:48 UTC, Marcone wrote: On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote: On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote: auto mytime = Clock.currTime().toUnixTime()

Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 15 November 2020 at 03:08:48 UTC, Marcone wrote: On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote: On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote: auto mytime = Clock.currTime().toUnixTime() writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some

Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Marcone via Digitalmars-d-learn
On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote: On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote: auto mytime = Clock.currTime().toUnixTime() writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some like this in D? auto mytime = Clock.currTime;

Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Marcone via Digitalmars-d-learn
On Sunday, 15 November 2020 at 02:29:20 UTC, Anonymouse wrote: On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote: auto mytime = Clock.currTime().toUnixTime() writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some like this in D? auto mytime = Clock.currTime;

Re: How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 15 November 2020 at 01:04:41 UTC, Marcone wrote: auto mytime = Clock.currTime().toUnixTime() writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some like this in D? auto mytime = Clock.currTime; writefln("%02dh:%02dm:%02ds", mytime.hour, mytime.minute, mytime.second);

How format UnixTime to "%Hh:%Mm:%Ss" ?

2020-11-14 Thread Marcone via Digitalmars-d-learn
auto mytime = Clock.currTime().toUnixTime() writeln(strftime("%Hh:%Mm:%Ss", mytime)); How can I make some like this in D?

Re: magically a static member on init?

2020-11-14 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Nov 14, 2020 at 11:20:55PM +, Martin via Digitalmars-d-learn wrote: > Hi, i do no know if this is intended - but imo this is weird: > https://run.dlang.io/is/eBje3A > > I expected that `c.a.str == ""` (just like `c.str` is). But instead > `c.a.str` keeps the value of `b.a.str`. > >

How can I set Timeout of Socket?

2020-11-14 Thread Marcone via Digitalmars-d-learn
Socket s = new Socket(AddressFamily.INET, SocketType.STREAM); s.connect(new InternetAddress("domain.com", 80)); I want that program raise an error if reach for example 30 seconds of timeout.

Re: magically a static member on init?

2020-11-14 Thread Martin via Digitalmars-d-learn
On Saturday, 14 November 2020 at 23:30:58 UTC, Adam D. Ruppe wrote: On Saturday, 14 November 2020 at 23:20:55 UTC, Martin wrote: Is this intentional? [...] alright, thank you! :)

Re: magically a static member on init?

2020-11-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 14 November 2020 at 23:20:55 UTC, Martin wrote: Is this intentional? In the current language design, yes. For the many users who ask this, no. All static initializers are run at compile time and refer to the static data segment - this is consistent across the language.

magically a static member on init?

2020-11-14 Thread Martin via Digitalmars-d-learn
Hi, i do no know if this is intended - but imo this is weird: https://run.dlang.io/is/eBje3A I expected that `c.a.str == ""` (just like `c.str` is). But instead `c.a.str` keeps the value of `b.a.str`. Is this intentional? IMO this feels not consistent and its weird when a reference leaks

presence of function template prevents diagnostic

2020-11-14 Thread kdevel via Digitalmars-d-learn
~~~A.d module A; import std.stdio; void bar (int s) { __PRETTY_FUNCTION__.writeln; } ~~~ ~~~foo.d import std.stdio; import A; alias bar = A.bar; version (X) { void bar (T) (T t) { __PRETTY_FUNCTION__.writeln; } } void bar (int s) { __PRETTY_FUNCTION__.writeln; } void main () { bar (1);

Re: .d files without a module statement? Required to be absent?

2020-11-14 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Nov 14, 2020 at 05:55:13PM +, WhatMeWorry via Digitalmars-d-learn wrote: > > I was poking around the dmd code just to "learn from the best" IMNSHO, Phobos is more representative of typical D code than dmd; dmd code was automatically translated from C++, so a lot of it may still have

Re: .d files without a module statement? Required to be absent?

2020-11-14 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 14 November 2020 at 17:55:13 UTC, WhatMeWorry wrote: I was poking around the dmd code just to "learn from the best" and I came across some files that ended with the .d extension which did not have the module statement. (I was under the naive impression that all .d files must

.d files without a module statement? Required to be absent?

2020-11-14 Thread WhatMeWorry via Digitalmars-d-learn
I was poking around the dmd code just to "learn from the best" and I came across some files that ended with the .d extension which did not have the module statement. (I was under the naive impression that all .d files must have a module statement) However, in the directory:

How can execute method in new Thread?

2020-11-14 Thread Marcone via Digitalmars-d-learn
My simple example code: import std; struct Fruit { string name; this(string name){ this.name = name; } void printmyname(){ writeln(this.name); } void showname(){ task!this.printmyname().executeInNewThread(); //