Re: What's the proper way to use std.getopt?

2017-12-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, December 13, 2017 06:55:46 bauss via Digitalmars-d-learn wrote: > On Tuesday, 12 December 2017 at 18:34:26 UTC, Mike Wey wrote: > > On 12-12-17 00:35, Seb wrote: > >> D style would be to use sth. like this (instead of try/catch): > >> > >> ``` > >> scope(failure) { > >> > >>e.msg

Re: Date Formating

2017-12-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, December 13, 2017 02:34:12 codephantom via Digitalmars-d-learn wrote: > On Tuesday, 12 December 2017 at 15:56:59 UTC, Vino wrote: > > Hi All, > > > > Request out help on date formatting, I have code which output > > > > the date and time as below , i we need it without the last few

Re: What's the proper way to use std.getopt?

2017-12-12 Thread bauss via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 18:34:26 UTC, Mike Wey wrote: On 12-12-17 00:35, Seb wrote: D style would be to use sth. like this (instead of try/catch): ``` scope(failure) {   e.msg.writeln;   1.exit; } ``` I might have missed something, but where is `e` defined in this case? I was thi

Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Ali Çehreli via Digitalmars-d-learn
On 12/12/2017 10:21 PM, bauss wrote: > On Tuesday, 12 December 2017 at 22:11:37 UTC, Adam D. Ruppe wrote: >> On Tuesday, 12 December 2017 at 21:52:57 UTC, Ali Çehreli wrote: >>> The same buffer is used for all segments and socket.receive should be >>> inside while. >> >> The buffer is copied by th

Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread bauss via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 22:11:37 UTC, Adam D. Ruppe wrote: On Tuesday, 12 December 2017 at 21:52:57 UTC, Ali Çehreli wrote: The same buffer is used for all segments and socket.receive should be inside while. The buffer is copied by the ~= operator, but indeed you're right that I forgo

Re: Understanding how dub works

2017-12-12 Thread codephantom via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 22:20:41 UTC, datboi wrote: Hi, I'm learning D (obliviously) learning D in an oblivious manner can be difficult ;-)

Re: Date Formating

2017-12-12 Thread codephantom via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 15:56:59 UTC, Vino wrote: Hi All, Request out help on date formatting, I have code which output the date and time as below , i we need it without the last few numbers.,ie "-MMM-DD HH:MM:SI" Output : 2017-Sep-06 16:06:42.7223837 Required Output : 2017-Sep

Re: Date Formating

2017-12-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 12, 2017 15:56:59 Vino via Digitalmars-d-learn wrote: > Hi All, > >Request out help on date formatting, I have code which output > the date and time as below , i we need it without the last few > numbers.,ie "-MMM-DD HH:MM:SI" > > Output : 2017-Sep-06 16:06:42.7223837 >

Re: Understanding how dub works

2017-12-12 Thread timotheecour via Digitalmars-d-learn
On Wednesday, 13 December 2017 at 00:43:31 UTC, rikki cattermole wrote: You don't need to change this and if you think you do, you're wrong :) Except when you need to: https://github.com/dlang/dub/issues/1305 dub build --compiler=ldmd2 overwrites files in ~/.dub written by dub build #1305

Re: Understanding how dub works

2017-12-12 Thread rikki cattermole via Digitalmars-d-learn
On 12/12/2017 10:20 PM, datboi wrote: Hi, I'm learning D (obliviously) and I can't understand how exactly dependencies work. I haven't found answers to my questions in documentation (or i did't understand it), so can someone answer to mine questions? 1. Does dub compile dependencies as separa

Re: What's the proper way to use std.getopt?

2017-12-12 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 20:57:28 UTC, Jon Degenhardt wrote: On Monday, 11 December 2017 at 20:58:25 UTC, Jordi Gutiérrez Hermoso wrote: What's the proper style, then? Can someone show me a good example of how to use getopt and the docstring it automatically generates? [snip] See: ht

Understanding how dub works

2017-12-12 Thread datboi via Digitalmars-d-learn
Hi, I'm learning D (obliviously) and I can't understand how exactly dependencies work. I haven't found answers to my questions in documentation (or i did't understand it), so can someone answer to mine questions? 1. Does dub compile dependencies as separate binaries? And if yes how to specify

Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 21:52:57 UTC, Ali Çehreli wrote: The same buffer is used for all segments and socket.receive should be inside while. The buffer is copied by the ~= operator, but indeed you're right that I forgot to receive again inside the loop! That would just spin until it r

Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Ali Çehreli via Digitalmars-d-learn
On 12/12/2017 01:52 PM, Ali Çehreli wrote: > > ubyte[] result; > > ubyte[1024] buffer; > > result ~= buffer[0 .. got]; > The same buffer is used for all segments Not! Ok, I better go take a nap. :) Ali

Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Ali Çehreli via Digitalmars-d-learn
On 12/12/2017 01:14 PM, Adam D. Ruppe wrote: > On Tuesday, 12 December 2017 at 21:03:54 UTC, Unazed Spectaculum wrote: >> I've decided to go for the run-time approach to this, it works fine >> with all of my tests so you have my greatest gratitude. > > the way I'd do it btw is simply: I know you

Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Unazed Spectaculum via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 21:14:30 UTC, Adam D. Ruppe wrote: On Tuesday, 12 December 2017 at 21:03:54 UTC, Unazed Spectaculum wrote: I've decided to go for the run-time approach to this, it works fine with all of my tests so you have my greatest gratitude. the way I'd do it btw is simply

Re: AssocArray to string is ok,but how to get the AssocArray from string? Thanks

2017-12-12 Thread Azi Hassan via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 17:32:15 UTC, Frank Like wrote: Hi,everyone, who can help me,about the "AssocArray to string is ok,but how to get the AssocArray from string? ". For example: SysTime[][string] AATimes; AATimes["a1"] =[SysTime(DateTime(2017, 1, 1, 12, 33, 33)),SysTime(DateTime(

Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 21:03:54 UTC, Unazed Spectaculum wrote: I've decided to go for the run-time approach to this, it works fine with all of my tests so you have my greatest gratitude. the way I'd do it btw is simply: ubyte[] result; ubyte[1024] buffer; auto got = socket.receive(buf

Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Unazed Spectaculum via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 20:27:04 UTC, Ali Çehreli wrote: On 12/12/2017 12:10 PM, Unazed Spectaculum wrote: > string receiveAll(T)(T socket, int segment_size = 1024) > { > char[segment_size][] data; Unrelated, you most likely want to use ubyte. (char is for UTF-8.) The problem is,

Re: What's the proper way to use std.getopt?

2017-12-12 Thread Jon Degenhardt via Digitalmars-d-learn
On Monday, 11 December 2017 at 20:58:25 UTC, Jordi Gutiérrez Hermoso wrote: What's the proper style, then? Can someone show me a good example of how to use getopt and the docstring it automatically generates? The command line tools I published use the approach described in a number of the rep

Re: Why is there no std.stream anymore?

2017-12-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/11/17 6:33 PM, Seb wrote: Though if you need superb performance, iopipe or similar will be faster. Since iopipe was mentioned several times, I will say a couple things: 1. iopipe is not made for processing one element at a time, it focuses on buffers. The reason for this is because certa

Re: Date Formating

2017-12-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/12/17 10:56 AM, Vino wrote: Hi All,   Request out help on date formatting, I have code which output the date and time as below , i we need it without the last few numbers.,ie "-MMM-DD HH:MM:SI" Output : 2017-Sep-06 16:06:42.7223837 Required Output : 2017-Sep-06 16:06:42 You nee

Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Ali Çehreli via Digitalmars-d-learn
On 12/12/2017 12:10 PM, Unazed Spectaculum wrote: > string receiveAll(T)(T socket, int segment_size = 1024) > { > char[segment_size][] data; Unrelated, you most likely want to use ubyte. (char is for UTF-8.) The problem is, char[segment_size] is a static array, where the length must be kno

how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Unazed Spectaculum via Digitalmars-d-learn
string receiveAll(T)(T socket, int segment_size = 1024) { char[segment_size][] data; int cnt = 0; while(true) { auto received = socket.receive(data[cnt]); if (received < segment_size) break; /* early exit */

Re: operator overload

2017-12-12 Thread dark777 via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 17:13:55 UTC, Biotronic wrote: On Tuesday, 12 December 2017 at 16:54:17 UTC, Biotronic wrote: There is no way in C++ to set the format the way you want it. If you want binary output, you need to call a function like your binario function. Of course this is not

Re: Static array as immutable

2017-12-12 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 12, 2017 at 06:06:48PM +, Ivan Trombley via Digitalmars-d-learn wrote: > On Tuesday, 12 December 2017 at 15:30:01 UTC, Nathan S. wrote: > > While what you're saying is true, exponentiation not being runnable > > at compile-time is a defect and I would assume a regression. [...] > F

Re: Tuple Array Sorting

2017-12-12 Thread Biotronic via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 15:19:35 UTC, Vino wrote: import std.algorithm: filter, map, sort; import std.container.array; import std.file: SpanMode, dirEntries, isDir ; import std.stdio: writefln; import std.typecons: Tuple, tuple; import std.datetime.systime: SysTime; void main () { auto F

Re: operator overload

2017-12-12 Thread dark777 via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 17:13:55 UTC, Biotronic wrote: On Tuesday, 12 December 2017 at 16:54:17 UTC, Biotronic wrote: There is no way in C++ to set the format the way you want it. If you want binary output, you need to call a function like your binario function. Of course this is not

Re: What's the proper way to use std.getopt?

2017-12-12 Thread Mike Wey via Digitalmars-d-learn
On 12-12-17 00:35, Seb wrote: D style would be to use sth. like this (instead of try/catch): ``` scope(failure) {   e.msg.writeln;   1.exit; } ``` I might have missed something, but where is `e` defined in this case? -- Mike Wey

Re: Static array as immutable

2017-12-12 Thread Ivan Trombley via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 15:30:01 UTC, Nathan S. wrote: While what you're saying is true, exponentiation not being runnable at compile-time is a defect and I would assume a regression. I'll file a bug report. FWIW when trying to run the following with DMD v2.077.1 I get: ``` void main(

AssocArray to string is ok, but how to get the AssocArray from string? Thanks

2017-12-12 Thread Frank Like via Digitalmars-d-learn
Hi,everyone, who can help me,about the "AssocArray to string is ok,but how to get the AssocArray from string? ". For example: SysTime[][string] AATimes; AATimes["a1"] =[SysTime(DateTime(2017, 1, 1, 12, 33, 33)),SysTime(DateTime(2017, 1, 2, 12, 33, 33))]; AATimes["a2"] =[SysTime(DateTime(2017,

Re: operator overload

2017-12-12 Thread Biotronic via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 16:54:17 UTC, Biotronic wrote: There is no way in C++ to set the format the way you want it. If you want binary output, you need to call a function like your binario function. Of course this is not entirely true - there is a way, but it's ugly and probably not

Re: operator overload

2017-12-12 Thread Biotronic via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 15:52:09 UTC, dark777 wrote: I know that this community is not of c ++, but some time I have been studying how to do overload of ostream operators in c ++ and I even managed to get to this result but the same is not converting to binary only presents zeros as out

Re: Date Formating

2017-12-12 Thread Vino via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 16:01:49 UTC, Adam D. Ruppe wrote: On Tuesday, 12 December 2017 at 15:56:59 UTC, Vino wrote: Request out help on date formatting, I have code which output the date and time as below , i we need it without the last few numbers.,ie "-MMM-DD HH:MM:SI" Just s

Re: Date Formating

2017-12-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 15:56:59 UTC, Vino wrote: Request out help on date formatting, I have code which output the date and time as below , i we need it without the last few numbers.,ie "-MMM-DD HH:MM:SI" Just slice it off. x[0 .. x.lastIndexOf("."];

Date Formating

2017-12-12 Thread Vino via Digitalmars-d-learn
Hi All, Request out help on date formatting, I have code which output the date and time as below , i we need it without the last few numbers.,ie "-MMM-DD HH:MM:SI" Output : 2017-Sep-06 16:06:42.7223837 Required Output : 2017-Sep-06 16:06:42 From, Vino.B

operator overload

2017-12-12 Thread dark777 via Digitalmars-d-learn
I know that this community is not of c ++, but some time I have been studying how to do overload of ostream operators in c ++ and I even managed to get to this result but the same is not converting to binary only presents zeros as output to any number already tried to pass parameter of variable

Re: Processing Function of return type(Real and SysTime)

2017-12-12 Thread Vino via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 14:25:22 UTC, Vino wrote: Hi All, Request your help on the below code, as i ma getting the below error message [...] Hi All, Was able to resolve this issue, it was my mistake, sorry. From, Vino.B

Re: Static array as immutable

2017-12-12 Thread Nathan S. via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 11:37:40 UTC, Jonathan M Davis wrote: On Tuesday, December 12, 2017 10:35:15 Ivan Trombley via Digitalmars-d-learn wrote: On Tuesday, 12 December 2017 at 09:48:09 UTC, Jonathan M Davis wrote: > On Tuesday, December 12, 2017 07:33:47 Ivan Trombley via > > Digitalm

Re: Tuple Array Sorting

2017-12-12 Thread Vino via Digitalmars-d-learn
On Monday, 11 December 2017 at 20:58:31 UTC, Biotronic wrote: On Monday, 11 December 2017 at 19:46:04 UTC, Vino wrote: import std.algorithm; import std.container.array; import std.file: SpanMode, dirEntries, isDir ; import std.stdio: writefln, writeln; import std.typecons: Tuple, tuple; import

Processing Function of return type(Real and SysTime)

2017-12-12 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on the below code, as i ma getting the below error message Error: C:\D\dmd2\windows\bin\..\..\src\phobos\std\container\array.d(739): Error: template std.container.array.Array!(Tuple!(string, real)).Array.insertBack cannot dedu ce function from argument types !()(Ra

Re: No line numbers in stack trace (again)

2017-12-12 Thread Mike Franklin via Digitalmars-d-learn
On Tuesday, 5 December 2017 at 13:43:38 UTC, Nordlöw wrote: If I get the following stack trace ___without line numbers___ (instead ??:?) what's missing? and using DMD 2.077.1 https://issues.dlang.org/show_bug.cgi?id=18068

Re: Static array as immutable

2017-12-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 12, 2017 10:35:15 Ivan Trombley via Digitalmars-d-learn wrote: > On Tuesday, 12 December 2017 at 09:48:09 UTC, Jonathan M Davis > > wrote: > > On Tuesday, December 12, 2017 07:33:47 Ivan Trombley via > > > > Digitalmars-d-learn wrote: > >> Is there some way that I can make thi

Re: Static array as immutable

2017-12-12 Thread Ivan Trombley via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 09:48:09 UTC, Jonathan M Davis wrote: On Tuesday, December 12, 2017 07:33:47 Ivan Trombley via Digitalmars-d-learn wrote: Is there some way that I can make this array immutable? static float[256] ga = void; static foreach (i; 0 .. 256) ga[i] = (i / 2

Re: Static array as immutable

2017-12-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 12, 2017 07:33:47 Ivan Trombley via Digitalmars-d-learn wrote: > Is there some way that I can make this array immutable? > >static float[256] ga = void; >static foreach (i; 0 .. 256) >ga[i] = (i / 255.0f) ^^ (1 / 2.2f); If you want anything to be immutable, yo

Re: No line numbers in stack trace (again)

2017-12-12 Thread Nick Sabalausky (Abscissa) via Digitalmars-d-learn
On 12/05/2017 08:43 AM, Nordlöw wrote: If I get the following stack trace ___without line numbers___ (instead ??:?) what's missing? Linux stack trace line numbers have disappeard for me, too. Used to work. Very frustrating, and a royal PITA when dealing with unittests. Help would be appreci

Re: Static array as immutable

2017-12-12 Thread Ivan Trombley via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 07:44:55 UTC, Radu wrote: On Tuesday, 12 December 2017 at 07:33:47 UTC, Ivan Trombley wrote: Is there some way that I can make this array immutable? static float[256] ga = void; static foreach (i; 0 .. 256) ga[i] = (i / 255.0f) ^^ (1 / 2.2f); Check ht

Re: Debugging a druntime issue found by AutoTester

2017-12-12 Thread Daniel Kozak via Digitalmars-d-learn
I would go with some VM and install 32bit system on it. Dne 12. 12. 2017 8:55 dop. napsal uživatel "Ali Çehreli via Digitalmars-d-learn" : > The automatic tests for a PR failed for a target that I could not test > myself: 32-bit build on Darwin_64_32. > > > https://auto-tester.puremagic.com/show-