Re: What does dot before method name mean?

2021-05-07 Thread Stephen Miller via Digitalmars-d-learn
On Saturday, 8 May 2021 at 02:33:44 UTC, Adam D. Ruppe wrote: On Saturday, 8 May 2021 at 02:29:18 UTC, Stephen Miller wrote: Is there an easy way to know what the system functions are? they are imported. Windows uses winsock: http://phobos.dpldocs.info/source/std.socket.d.html#L50 posix uses

Re: What does dot before method name mean?

2021-05-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 8 May 2021 at 02:29:18 UTC, Stephen Miller wrote: Is there an easy way to know what the system functions are? they are imported. Windows uses winsock: http://phobos.dpldocs.info/source/std.socket.d.html#L50 posix uses their socket thing: http://phobos.dpldocs.info/source/std.sock

Re: What does dot before method name mean?

2021-05-07 Thread Stephen Miller via Digitalmars-d-learn
On Saturday, 8 May 2021 at 01:48:22 UTC, Adam D. Ruppe wrote: On Saturday, 8 May 2021 at 01:45:49 UTC, Stephen Miller wrote: I am writing a tcp proxy server and I noticed that when a socket is in non-blocking mode, it returns -1 if it doesn't receive data, as opposed to 0. It sets the `wouldH

What does dot before method name mean?

2021-05-07 Thread Stephen Miller via Digitalmars-d-learn
I am writing a tcp proxy server and I noticed that when a socket is in non-blocking mode, it returns -1 if it doesn't receive data, as opposed to 0. I wanted to track down the documentation or figure out what might be going on, so I went to the dlang documentation page for std.socket.Socket. Th

Re: What does dot before method name mean?

2021-05-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 8 May 2021 at 01:45:49 UTC, Stephen Miller wrote: I am writing a tcp proxy server and I noticed that when a socket is in non-blocking mode, it returns -1 if it doesn't receive data, as opposed to 0. It sets the `wouldHaveBlocked` flag in that case returning -1. 0 always means con

Re: Fixed length vs dynamic arrays

2021-05-07 Thread Paul Backus via Digitalmars-d-learn
On Friday, 7 May 2021 at 22:21:09 UTC, Alain De Vos wrote: Following code compiles without errors, only errors during runtime ``` int main(){ int[2] a=new int[2]; int[] b=new int[0]; int[2] c=[1,2]; a=a~3; b=b~3; c=c~3; c=b; b=a

Re: Fixed length vs dynamic arrays

2021-05-07 Thread Alain De Vos via Digitalmars-d-learn
Following code compiles without errors, only errors during runtime ``` int main(){ int[2] a=new int[2]; int[] b=new int[0]; int[2] c=[1,2]; a=a~3; b=b~3; c=c~3; c=b; b=a; a=c; return 0; } ```

Re: class grammar

2021-05-07 Thread Nick via Digitalmars-d-learn
On Friday, 7 May 2021 at 19:33:30 UTC, Basile B. wrote: On Friday, 7 May 2021 at 18:07:45 UTC, Nick wrote: The class grammar, as defined in the D language specification ... is not clear to me how a user-defined type (such as a class or interface) is also a 'BasicType' (as defined by the grammar

Re: Measure cpu time

2021-05-07 Thread Ali Çehreli via Digitalmars-d-learn
On 5/7/21 9:46 AM, Alain De Vos wrote: I see, https://dlang.org/phobos/core_stdc_time.html does not contain the function : "clock_gettime" Weird ... stdc is about D bindings for C's std headers. I don't think clock_gettime is a standard C function. grep'ping under /usr/include/dmd reveals tha

Re: class grammar

2021-05-07 Thread Basile B. via Digitalmars-d-learn
On Friday, 7 May 2021 at 18:07:45 UTC, Nick wrote: The class grammar, as defined in the D language specification ... is not clear to me how a user-defined type (such as a class or interface) is also a 'BasicType' (as defined by the grammar). However, the compiler only accepts classes or interfa

Re: class grammar

2021-05-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 7 May 2021 at 18:07:45 UTC, Nick wrote: The class grammar, as defined in the D language specification ([Classes](https://dlang.org/spec/grammar.html#classes)), seems to imply that a class can inherit from a fundamental type. Explicitly, the specification says that a 'SuperClass' is a

class grammar

2021-05-07 Thread Nick via Digitalmars-d-learn
The class grammar, as defined in the D language specification ([Classes](https://dlang.org/spec/grammar.html#classes)), seems to imply that a class can inherit from a fundamental type. Explicitly, the specification says that a 'SuperClass' is a 'BasicType'. And a 'FundamentalType' is a 'BasicTy

Re: Measure cpu time

2021-05-07 Thread Alain De Vos via Digitalmars-d-learn
I see, https://dlang.org/phobos/core_stdc_time.html does not contain the function : "clock_gettime" Weird ...

Re: Measure cpu time

2021-05-07 Thread Alain De Vos via Digitalmars-d-learn
Probably renamed ...

Re: Measure cpu time

2021-05-07 Thread Ali Çehreli via Digitalmars-d-learn
On 5/7/21 1:25 AM, Andre Pany wrote: > get the cpu time For the sake of completeness, that kind of functionality is provided by operating systems as well. For example, on Linux, it is common to run the program through 'time' to get how much wall clock advanced, how much time was spent actuall

Re: Measure cpu time

2021-05-07 Thread Andre Pany via Digitalmars-d-learn
On Friday, 7 May 2021 at 08:58:33 UTC, Dennis wrote: On Friday, 7 May 2021 at 08:52:13 UTC, Dennis wrote: If you want to use it on Windows as well, this is a code snippet I wrote for that: For completeness, the imports it uses: ```D version(Windows) { import core.sys.windows.windows;

Re: Measure cpu time

2021-05-07 Thread Dennis via Digitalmars-d-learn
On Friday, 7 May 2021 at 08:52:13 UTC, Dennis wrote: If you want to use it on Windows as well, this is a code snippet I wrote for that: For completeness, the imports it uses: ```D version(Windows) { import core.sys.windows.windows; import core.sys.windows.psapi: PROCESS_MEMORY_COUNTERS

Re: Measure cpu time

2021-05-07 Thread Dennis via Digitalmars-d-learn
On Friday, 7 May 2021 at 08:25:43 UTC, Andre Pany wrote: Is there some equivalent function in Phobos to get the cpu time on linux? I don't think so, but you can use `core.sys.posix.sys.resource: rusage`. If you want to use it on Windows as well, this is a code snippet I wrote for that: ```

Re: Measure cpu time

2021-05-07 Thread Andre Pany via Digitalmars-d-learn
On Friday, 7 May 2021 at 08:37:47 UTC, Imperatorn wrote: On Friday, 7 May 2021 at 08:25:43 UTC, Andre Pany wrote: Hi, I try to convert some python code to D. On python I can get the cpu time for the current process using ``` python dcpu: float = time.process_time() ``` Is there some equival

Re: Measure cpu time

2021-05-07 Thread Imperatorn via Digitalmars-d-learn
On Friday, 7 May 2021 at 08:25:43 UTC, Andre Pany wrote: Hi, I try to convert some python code to D. On python I can get the cpu time for the current process using ``` python dcpu: float = time.process_time() ``` Is there some equivalent function in Phobos to get the cpu time on linux? Ki

Measure cpu time

2021-05-07 Thread Andre Pany via Digitalmars-d-learn
Hi, I try to convert some python code to D. On python I can get the cpu time for the current process using ``` python dcpu: float = time.process_time() ``` Is there some equivalent function in Phobos to get the cpu time on linux? Kind regards André