Random Access I/O

2016-03-25 Thread Chris Williams via Digitalmars-d-learn
I need to be able to perform random access I/O against a file, creating a new file if it doesn't exist, or opening as-is (no truncation) if it already exists. None of the access modes for std.stdio.File seem to allow that. Any usage of the "w" mode causes my code to consider the file empty if

Static convertability testing?

2015-02-12 Thread Chris Williams via Digitalmars-d-learn
I have a template function that gets values out of a tree of variant types. My goal is to be able to write code like; node.get!string("path", "to", "leaf"); Inside get(), I would like to use std.conv to dynamically convert (where able) to the target type (T) or, if that is not possible, to re

Re: Time from timestamp?

2015-01-30 Thread Chris Williams via Digitalmars-d-learn
On Saturday, 31 January 2015 at 00:14:37 UTC, Steven Schveighoffer wrote: On 1/30/15 5:18 PM, Chris Williams wrote: I'm attempting to print a human-readable version of a timestamp. The timestamp is coming from an external service, via JSON. An example is: 1421865781342 Which I know to be: 2

Re: Time from timestamp?

2015-01-30 Thread Chris Williams via Digitalmars-d-learn
On Saturday, 31 January 2015 at 00:20:07 UTC, ketmar wrote: On Sat, 31 Jan 2015 00:03:43 +, Chris Williams wrote: since most database software probably stores birthdates (many of which are pre-1970) in this format O_O a perfectly broken software. And stdc: http://h50146.www5.hp.com/prod

Re: Time from timestamp?

2015-01-30 Thread Chris Williams via Digitalmars-d-learn
On Friday, 30 January 2015 at 23:50:53 UTC, ketmar wrote: On Fri, 30 Jan 2015 23:42:04 +, Chris Williams wrote: On Friday, 30 January 2015 at 22:38:21 UTC, Chris Williams wrote: On Friday, 30 January 2015 at 22:22:27 UTC, Rikki Cattermole wrote: On a slightly related note, I have code for

Re: Time from timestamp?

2015-01-30 Thread Chris Williams via Digitalmars-d-learn
On Friday, 30 January 2015 at 22:38:21 UTC, Chris Williams wrote: On Friday, 30 January 2015 at 22:22:27 UTC, Rikki Cattermole wrote: On a slightly related note, I have code for UTC+0 to unix time stamp. https://github.com/Devisualization/util/blob/b9ab5758e755c4e33832ac4aed0a5d7f2c728faf/sourc

Re: Time from timestamp?

2015-01-30 Thread Chris Williams via Digitalmars-d-learn
On Friday, 30 January 2015 at 22:22:27 UTC, Rikki Cattermole wrote: On a slightly related note, I have code for UTC+0 to unix time stamp. https://github.com/Devisualization/util/blob/b9ab5758e755c4e33832ac4aed0a5d7f2c728faf/source/core/devisualization/util/core/time.d Unix timestamps can be ne

Time from timestamp?

2015-01-30 Thread Chris Williams via Digitalmars-d-learn
I'm attempting to print a human-readable version of a timestamp. The timestamp is coming from an external service, via JSON. An example is: 1421865781342 Which I know to be: 2015-01-21T18:43:01.342Z The only method I see which takes an epoch-style timestamp, so that I can convert it to some

Re: Using std.net.curl to stream data

2015-01-28 Thread Chris Williams via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 14:18:38 UTC, Trollgeir wrote: I'm having some trouble trying to stream data to my plot.ly graph: https://plot.ly/62/~Trollgeir/ The API: https://plot.ly/streaming/ I am able to post messages that get recorded into the stream live, although right after curl u

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread Chris Williams via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 09:44:29 UTC, zhmt wrote: Sometime , I need to copy them: thrift.Card tc; db.Card dc; dc.id = tc.id; dc.pwd = tc.pwd; ... It is boring coding, I want a solution to copy them automatically: void copyObj(SRC,DEST)(SRC src,DEST dest) { foreach (i,

Re: how convert the range to slice ?

2015-01-28 Thread Chris Williams via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 22:43:36 UTC, bearophile wrote: Nordlöw: Is there any chance we could add logic to dmd+phobos that hints user about this? It's such a fundamental part of D+Phobos that newbies are forced to learn this quickly. On the other hand an informative error message c

Re: Russian translation of the "range" term?

2014-11-12 Thread Chris Williams via Digitalmars-d-learn
On Wednesday, 12 November 2014 at 11:38:52 UTC, thedeemon wrote: On Tuesday, 11 November 2014 at 11:50:18 UTC, Ivan Kazmenko wrote: Hi! I'm unsure what is the Russian equivalent for the term "range", as in "D range", the generalization of a pair of iterators. I think "последовательность" (s

Re: Why do some language-defined attributes have @ and some not?

2014-10-24 Thread Chris Williams via Digitalmars-d-learn
On Thursday, 23 October 2014 at 07:39:21 UTC, Gary Willoughby wrote: On Thursday, 23 October 2014 at 00:59:26 UTC, Shriramana Sharma via Digitalmars-d- I submit that the syntax for attributes should be streamlined. Shall I go and open a Bugzilla item? No need: http://wiki.dlang.org/DIP64 Be

Re: Search Engine

2014-10-08 Thread Chris Williams via Digitalmars-d-learn
On Wednesday, 8 October 2014 at 18:15:08 UTC, ANtlord wrote: It would be stable? I mean program, that will use C++ extern interface. Trying to link to C++ code will cause some work to solve build issues, but there shouldn't be any stability impacts other than recognizing that C++ won't be usi

Re: Momentary Eh?! for a Dynamic Language Programmmer. Tuples vs Arrays. Just rambling.

2014-06-25 Thread Chris Williams via Digitalmars-d-learn
On Monday, 23 June 2014 at 22:08:59 UTC, John Carter wrote: On Monday, 23 June 2014 at 21:26:19 UTC, Chris Williams wrote: More likely what you want are variants: Hmm. Interesting. Yes, Variant and VariantArray are much closer to the dynamic language semantics... But the interesting thing

Re: Momentary Eh?! for a Dynamic Language Programmmer. Tuples vs Arrays. Just rambling.

2014-06-23 Thread Chris Williams via Digitalmars-d-learn
On Monday, 23 June 2014 at 21:18:39 UTC, John Carter wrote: I guess between perl and Ruby and Scheme etc. I got used to creating hybrid containers Want a pair of [string, fileList]? Just make an Array with two items, one a string, one and array of strings. Done. D barfed... leaving me mo

Re: Separate allocation and construction?

2014-06-05 Thread Chris Williams via Digitalmars-d-learn
On Thursday, 5 June 2014 at 22:25:03 UTC, Adam D. Ruppe wrote: On Thursday, 5 June 2014 at 22:22:16 UTC, Chris Williams wrote: If I wanted to allocate memory for a class and then call its constructor as two separate steps, while still having the object be managed by the garbage collector, is th

Separate allocation and construction?

2014-06-05 Thread Chris Williams via Digitalmars-d-learn
If I wanted to allocate memory for a class and then call its constructor as two separate steps, while still having the object be managed by the garbage collector, is there any way to do that? I believe that I've figured out a way to accomplish the first step, but not the second. import std.s