Re: File Input

2017-05-13 Thread JV via Digitalmars-d-learn
On Monday, 8 May 2017 at 10:34:42 UTC, k-five wrote: On Monday, 8 May 2017 at 10:22:53 UTC, JV wrote: On Monday, 8 May 2017 at 09:26:48 UTC, k-five wrote: On Monday, 8 May 2017 at 08:54:50 UTC, JV wrote: --- If I continue to learn D I will do b

Re: Do array literals still always allocate?

2017-05-13 Thread Lewis via Digitalmars-d-learn
On Saturday, 13 May 2017 at 19:22:09 UTC, Steven Schveighoffer wrote: It's just out of date. Can't remember the version, but this did use to allocate. It doesn't any more. But only for this case. In most cases it does allocate. Okay cool, that's good to hear. For reference the most recent pla

Re: Do array literals still always allocate?

2017-05-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 13 May 2017 at 18:32:16 UTC, Lewis wrote: import std.random; import std.stdio; int[4] testfunc(int num) @nogc { return [0, 1, num, 3]; } int main() { int[4] arr = testfunc(uniform(0, 15)); writeln(arr); return 0; } I've read a bunch of stuff that seems to indicate

code.demangle can't demangle a type.

2017-05-13 Thread Yuxuan Shui via Digitalmars-d-learn
So in this document: http://yshui.gitlab.io/sdpc/sdpc/parsers/whitespace.html Part of the type name is still mangled. I found ddox use core.demangle.demangleType internally. So I guess code.demangle is following behind dmd? Is there a better way to demangle a name?

Re: Do array literals still always allocate?

2017-05-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 13 May 2017 at 18:32:16 UTC, Lewis wrote: import std.random; import std.stdio; int[4] testfunc(int num) @nogc { return [0, 1, num, 3]; } int main() { int[4] arr = testfunc(uniform(0, 15)); writeln(arr); return 0; } I've read a bunch of stuff that seems to indicate

Re: Do array literals still always allocate?

2017-05-13 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 13 May 2017 at 18:32:16 UTC, Lewis wrote: import std.random; import std.stdio; int[4] testfunc(int num) @nogc { return [0, 1, num, 3]; } int main() { int[4] arr = testfunc(uniform(0, 15)); writeln(arr); return 0; } I've read a bunch of stuff that seems to indicate

Do array literals still always allocate?

2017-05-13 Thread Lewis via Digitalmars-d-learn
import std.random; import std.stdio; int[4] testfunc(int num) @nogc { return [0, 1, num, 3]; } int main() { int[4] arr = testfunc(uniform(0, 15)); writeln(arr); return 0; } I've read a bunch of stuff that seems to indicate that array literals are always heap-allocated, even whe

Re: Lookahead in unittest

2017-05-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/12/17 5:46 PM, H. S. Teoh via Digitalmars-d-learn wrote: On Fri, May 12, 2017 at 05:23:23PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] Note, you can achieve what you want with version(unittest): version(unittest) { class A { B b; } class B { } } unittest {

Re: Access specifiers and visibility

2017-05-13 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 01:42:47 UTC, Andrew Edwards wrote: Attempting to update a git repo to current D, I encounter the following deprecation messages: src/glwtf/signals.d-mixin-256(256,2): Deprecation: glwtf.input.BaseGLFWEventHandler._on_key_down is not visible from module glwtf.sign

Re: SysTime.fromISOString

2017-05-13 Thread Russel Winder via Digitalmars-d-learn
On Sat, 2017-05-13 at 05:03 -0700, Jonathan M Davis via Digitalmars-d- learn wrote: > […] > SysTime st; > try > { > // If it's -MM-DDTHH:MM:SS.FFFZ > // If it's -MM-DDTHH:MM:SS.FFZ > // If it's -MM-DDTHH:MM:SS.FZ > // If it's -MM-DDTHH:MM:SS.Z >

Re: SysTime.fromISOString

2017-05-13 Thread Russel Winder via Digitalmars-d-learn
On Sat, 2017-05-13 at 05:30 -0700, Jonathan M Davis via Digitalmars-d- learn wrote: > > […] I can see I am not going to win the -MM discussion so I'll stand down. Until I have read the latest version of the standard – I remain sure this is a reduced accuracy not a truncated representation. Bu

Re: SysTime.fromISOString

2017-05-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 13, 2017 12:56:31 Russel Winder via Digitalmars-d-learn wrote: > On Sat, 2017-05-13 at 04:24 -0700, Jonathan M Davis via Digitalmars-d- > > learn wrote: > > […] > > > > -MM is still truncated and therefore only permitted if > > applications > > agree to it. > > But didn't that

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-13 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 13 May 2017 at 09:51:40 UTC, k-five wrote: On Saturday, 13 May 2017 at 09:05:17 UTC, Jonathan M Davis But obviously, to know what's actually happening with your code, you're going to have to profile and benchmark it - Can you please give a link or page or something to read about

Re: SysTime.fromISOString

2017-05-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 13, 2017 12:31:38 Russel Winder via Digitalmars-d-learn wrote: > And this seems awkward: > > > auto date = Clock.currTime(); > auto date_buffer = date.toISOString(); > … > try { > date = SysTime.fromISOString(date_buffer); > } catch (DateTimeException dte) { >

Re: SysTime.fromISOString

2017-05-13 Thread Russel Winder via Digitalmars-d-learn
On Sat, 2017-05-13 at 04:24 -0700, Jonathan M Davis via Digitalmars-d- learn wrote: > […] > > -MM is still truncated and therefore only permitted if > applications > agree to it. But didn't that come is as standard in the 2000 standard along with -- MM-DD for yearless date? > > For times hh:

Re: SysTime.fromISOString

2017-05-13 Thread Russel Winder via Digitalmars-d-learn
And this seems awkward: auto date = Clock.currTime(); auto date_buffer = date.toISOString(); … try { date = SysTime.fromISOString(date_buffer); } catch (DateTimeException dte) { try { date = SysTime(DateTime.f

Re: SysTime.fromISOString

2017-05-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 13, 2017 12:06:57 Russel Winder via Digitalmars-d-learn wrote: > On Sat, 2017-05-13 at 01:52 -0700, Jonathan M Davis via Digitalmars-d- > learn wrote: > My reading is that -MM is an allowed form: I was wrong to suggest > was allowed. -MM is still truncated and theref

Re: std.getopt and std.datetime

2017-05-13 Thread Russel Winder via Digitalmars-d-learn
On Sat, 2017-05-13 at 02:23 -0700, Jonathan M Davis via Digitalmars-d- learn wrote: > […] > At best, it's slang. It's not proper anything. > > https://github.com/dlang/phobos/pull/5388 > > - Jonathan M Davis Indeed. Thanks for getting a pull request in to ameliorate the difficulty. -- Russel.

Re: SysTime.fromISOString

2017-05-13 Thread Russel Winder via Digitalmars-d-learn
On Sat, 2017-05-13 at 01:52 -0700, Jonathan M Davis via Digitalmars-d- learn wrote: > […] > The ISO representation of a date is MMDD, and the extended ISO > representation is -MM-DD. would be a truncated > representation. The > standard has language such as "If, by agreement, truncated

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-13 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 13 May 2017 at 10:51:09 UTC, k-five wrote: Okay, and NOW I understood what you are trying to say. First of all I thought you got mad at me. And I became sad. My sincere apologies! Always assume the best in people :-) I am glad you asked for clarification. [...] Still I am a beg

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-13 Thread k-five via Digitalmars-d-learn
On Saturday, 13 May 2017 at 10:15:34 UTC, Bastiaan Veelo wrote: On Saturday, 13 May 2017 at 08:23:55 UTC, k-five wrote: [...] OK understood. [...] I am sorry for expressing myself poorly. What I meant to say is that it looked like you can write an interesting article about your experienc

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-13 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 13 May 2017 at 08:23:55 UTC, k-five wrote: On Friday, 12 May 2017 at 20:53:56 UTC, Bastiaan Veelo wrote: Is it safe to say that these 40 lines of D do the same as your 324 lines of C++ [1]? No. I cannot say that. Since this is not a full port of renrem in C++ to D. It was just a

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-13 Thread k-five via Digitalmars-d-learn
On Saturday, 13 May 2017 at 09:05:17 UTC, Jonathan M Davis wrote: For the most part, when parsing a string, std.conv.to's approach of just parsing the string and throwing an exception if/when it fails is the most efficient, because it's only going to parse the string once, whereas calling a fu

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-13 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 13 May 2017 at 08:50:20 UTC, k-five wrote: Way arguing when a simple code can clarify the subject? right? If am not clear so consider me as an stupid man, no problem at all. but CAN you please solve it for me? import std.stdio: writeln; import std.conv:to; void ma

Re: std.getopt and std.datetime

2017-05-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 13, 2017 06:53:25 Russel Winder via Digitalmars-d-learn wrote: > Is there a canonical, idiomatic way of processing std.datetime objects > using std.getopt? > > Currently, I am suffering: > > /usr/include/d/std/getopt.d(921): Error: static assert "Dunno how to deal > with type Sys

Re: Lookahead in unittest

2017-05-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 12, 2017 14:46:30 H. S. Teoh via Digitalmars-d-learn wrote: > On Fri, May 12, 2017 at 05:23:23PM -0400, Steven Schveighoffer via > Digitalmars-d-learn wrote: [...] > > > Note, you can achieve what you want with version(unittest): > > > > version(unittest) > > { > > > >class A { B

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 12, 2017 10:42:18 H. S. Teoh via Digitalmars-d-learn wrote: > On Fri, May 12, 2017 at 12:47:04PM +0200, ag0aep6g via Digitalmars-d-learn wrote: > > On 05/12/2017 10:32 AM, k-five wrote: > > > Interesting! I was worried about performance and for that I did not > > > want to use try-c

Re: How to avoid throwing an exceptions for a built-in function?

2017-05-13 Thread k-five via Digitalmars-d-learn
On Saturday, 13 May 2017 at 02:40:17 UTC, Mike B Johnson wrote: You are not making a lot of sense: 1. Exception do bubble up, so you don't need to "handle" exceptions at the call site if you don't want to. The whole point of exceptions is do effectively do what you want. 2. You say that you

Re: SysTime.fromISOString

2017-05-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 13, 2017 07:33:35 Russel Winder via Digitalmars-d-learn wrote: > A priori I thought 2015 was a perfectly valid ISO8601 date-time > specification. It appears that SysTime.fromISOString disagrees: > > core.time.TimeException@/usr/include/d/std/datetime.d(8553): Invalid > ISO String:

Re: As many thanks As possible to who crates D and UFCS feature

2017-05-13 Thread k-five via Digitalmars-d-learn
On Friday, 12 May 2017 at 20:53:56 UTC, Bastiaan Veelo wrote: Is it safe to say that these 40 lines of D do the same as your 324 lines of C++ [1]? No. I cannot say that. Since this is not a full port of renrem in C++ to D. It was just an example in D, nothing else. This, and your comments o