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

Re: GSOC 2015 - GNU dmd

2015-03-05 Thread Chris Williams via Digitalmars-d-announce
On Wednesday, 4 March 2015 at 22:08:44 UTC, Walter Bright wrote: On 3/3/2015 1:15 PM, notna wrote: not sure if someone should inform them about the DMD name clash... or just enjoy the popularity ;) http://www.gnu.org/software/dmd I sent them a note. I'd suggest Daemon Hurder or dhurd.

Re: Let's Play Code Golf

2015-02-24 Thread Chris Williams via Digitalmars-d
On Monday, 23 February 2015 at 22:58:22 UTC, Charles wrote: I didn't beat your score, but I did it with ranges (full character count was 174): stdin.readln(); foreach(x; stdin.byLine) writefln(%0.15f, map!(a = (a1?-1:1)/(2.0*a+1))(iota(x.to!int)).sum); I think if I didn't have to import

Re: Plan for Exceptions and @nogc?

2015-02-17 Thread Chris Williams via Digitalmars-d
On Wednesday, 18 February 2015 at 00:14:55 UTC, deadalnix wrote: On Tuesday, 17 February 2015 at 19:03:49 UTC, Chris Williams wrote: Every throwable function call could be assumed to have a typed result (even void functions) and if, after the return, the caller checks the type and detects

Re: Template constraints

2015-02-17 Thread Chris Williams via Digitalmars-d
On Saturday, 14 February 2015 at 17:00:33 UTC, Andrei Alexandrescu wrote: There's been recurring discussion about failing constraints not generating nice error messages. void fun(T)(T x) if (complicated_condition) { ... } struct Type(T)(T x) if (complicated_condition) { ... } If

Re: Plan for Exceptions and @nogc?

2015-02-17 Thread Chris Williams via Digitalmars-d
On Tuesday, 17 February 2015 at 15:54:17 UTC, Andrei Alexandrescu wrote: On 2/16/15 3:17 PM, Jonathan Marler wrote: Is there a proposal for how D will support throwing Exceptions in @nogc code in the future? Nothing definite. We will get on to that right after 2.067. This is a good time to

Re: Plan for Exceptions and @nogc?

2015-02-17 Thread Chris Williams via Digitalmars-d
On Tuesday, 17 February 2015 at 18:50:46 UTC, Tobias Pankrath wrote: Could someone give a description of the minutiae of why Exception throwing uses memory allocation as it is and why (for example) passing it back on the stack isn't an option? The stack frame of the thrower is the first one

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 return

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

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

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

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

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

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

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: 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

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

Re: D3

2014-12-09 Thread Chris Williams via Digitalmars-d
On Monday, 8 December 2014 at 20:21:51 UTC, Andrej Mitrovic via Digitalmars-d wrote: On 12/8/14, Russel Winder via Digitalmars-d digitalmars-d@puremagic.com wrote: It seems that D3 is already available: https://github.com/mbostock/d3 Guess we'll just have to skip a number and call the next D

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 последовательность

Re: DIP68: Adding @nogc to types

2014-11-10 Thread Chris Williams via Digitalmars-d
On Monday, 10 November 2014 at 12:59:14 UTC, Tomer Filiba wrote: http://wiki.dlang.org/DIP68 This DIP proposes the addition of a compiler-enforced @nogc attribute on types. I would probably suggest extending this to variables. class Foo { @nogc Bar var1; void doStuff() {

Re: Library inheritance

2014-11-05 Thread Chris Williams via Digitalmars-d
On Tuesday, 4 November 2014 at 15:03:08 UTC, Felix wrote: Hi, just wondering if it's possible, due to the lag of header files, to inherit from some class that exists within a library, that has been written in D? How did you solve that? Thanks in advance. You can run the compiler to create

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

Re: Endovena: a dependency injection framework.

2014-10-21 Thread Chris Williams via Digitalmars-d-announce
On Friday, 17 October 2014 at 22:55:24 UTC, Orfeo wrote: * [endovena] https://github.com/o3o/endovena Boost License 1.0 I would suggest naming the class something other than Container. Injector or Factory or something. Container gets confusing with std.container.

Re: example of pointer usefulness in D

2014-10-21 Thread Chris Williams via Digitalmars-d
On Tuesday, 21 October 2014 at 19:36:50 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 21 October 2014 at 19:33:14 UTC, Freddy wrote: On Tuesday, 21 October 2014 at 12:22:54 UTC, edn wrote: Could someone provide me with examples showing the usefulness of pointers in the D language? They don't

Re: RFC: std.concepts

2014-10-20 Thread Chris Williams via Digitalmars-d
On Sunday, 19 October 2014 at 21:10:12 UTC, Shammah Chancellor wrote: It was request that I create a NG thread about a module I was hoping to merge with phobos. (std.concepts) Please take a look. It seems like it might have some good use cases, but I'm not sure that it warrants a new module.

Re: Segmented stack

2014-10-17 Thread Chris Williams via Digitalmars-d
On Thursday, 16 October 2014 at 19:46:42 UTC, Shucai wrote: I am doing research on segmented stack mechanisms, and in addition to academic papers, I am surveying whether segmented stack mechanism is still useful on 64-bit machines. On 64 bit machines, why they don’t just use a big enough

Re: Worse is better?

2014-10-10 Thread Chris Williams via Digitalmars-d
On Friday, 10 October 2014 at 21:54:32 UTC, Peter Alexander wrote: (a) gives users full control over how every function allocates/manages memory (control). (b) makes the implementation of those functions easy (simple). (c) makes it easy to compose functions with different management policies

Re: Worse is better?

2014-10-10 Thread Chris Williams via Digitalmars-d
On Friday, 10 October 2014 at 22:25:10 UTC, Walter Bright wrote: So it's not that we don't care about simplicity anymore. We care about what is simple for the programmer to get complex work done quickly and accurately. I like to think of D as a fully equipped machine shop, where the programmer

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

Re: RFC: moving forward with @nogc Phobos

2014-09-29 Thread Chris Williams via Digitalmars-d
On Monday, 29 September 2014 at 12:29:33 UTC, Dicebot wrote: Any assumption that library code can go away with some set of pre-defined allocation strategies is crap. This whole discussion was about how important it is to move allocation decisions to user code (ranges are just one tool to

Re: RFC: moving forward with @nogc Phobos

2014-09-29 Thread Chris Williams via Digitalmars-d
On Monday, 29 September 2014 at 10:49:53 UTC, Andrei Alexandrescu wrote: On the caller side: auto p1 = setExtension(hello, .txt); // fine, use gc auto p2 = setExtension!gc(hello, .txt); // same auto p3 = setExtension!rc(hello, .txt); // fine, use rc So by default it's going to continue being

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

Re: Is void* compatible with function pointers?

2014-06-23 Thread Chris Williams via Digitalmars-d
On Monday, 23 June 2014 at 20:49:27 UTC, Steven Schveighoffer wrote: Since most architectures use same-size words for function addresses and object addresses, D would be fine to say it's defined and valid. I think the extreme outliers are architectures that are not equal, and D will not be

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

Re: D Logos

2014-06-13 Thread Chris Williams via Digitalmars-d
On Friday, 13 June 2014 at 03:33:41 UTC, Khaled wrote: https://drive.google.com/file/d/0B_LJS0oMStiPVzJvRzBhTC1EaXc/edit?usp=sharing Overall, I like them. I agree that it's not intuitive that it's a d, but I don't think that's a strong drawback, if all you want is something cool to put on a

Re: extern(Windows) behavior on non-Windows systems

2014-06-11 Thread Chris Williams via Digitalmars-d
On Wednesday, 11 June 2014 at 22:20:27 UTC, Walter Bright wrote: I've got an enhancement request to have it behave like extern(C): https://issues.dlang.org/show_bug.cgi?id=12894 Thoughts? Anyone use extern(Windows) on non-Windows systems? No, but if I had a 3rd party .lib that had been

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

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

Re: Performance of std.json

2014-06-02 Thread Chris Williams via Digitalmars-d
On Monday, 2 June 2014 at 00:39:48 UTC, Jonathan M Davis via Digitalmars-d wrote: I know that vibe.d uses its own json implementation, but I don't know how much of that is part of its public API and how much of that is simply used internally: http://vibed.org In general, I've been pretty

Re: Performance of std.json

2014-06-02 Thread Chris Williams via Digitalmars-d
On Monday, 2 June 2014 at 20:10:52 UTC, David Soria Parra wrote: I think the main question is, given that std.json is close to be unusable for anything serious due to it's poor performance, can we come up with something faster that has the same API. I am not sure what phobos take on backwards

Re: std.experimental – DConf?

2014-05-30 Thread Chris Williams via Digitalmars-d
On Friday, 30 May 2014 at 01:39:26 UTC, Jonathan M Davis via Digitalmars-d wrote: On Thu, 29 May 2014 20:55:32 + Dicebot via Digitalmars-d digitalmars-d@puremagic.com wrote: I have discussed this with Andrei shortly after he has merged PR that adds `std.experimental` to Phobos. Looks like

Re: std.experimental – DConf?

2014-05-30 Thread Chris Williams via Digitalmars-d
On Friday, 30 May 2014 at 16:33:06 UTC, H. S. Teoh via Digitalmars-d wrote: Maybe we should call it std.broken_in_next_release. ;-) T import std.heretherebedragons.all;

Re: std.experimental – DConf?

2014-05-30 Thread Chris Williams via Digitalmars-d
On Friday, 30 May 2014 at 17:35:39 UTC, Steven Schveighoffer wrote: You mean like http://dlang.org/attribute#deprecated ? Yes, except named experimental. I had been intending (should I ever have free time...) to add some features to std.concurrency, but I don't think there's any way to

DConf Recommendation

2014-05-28 Thread Chris Williams via Digitalmars-d
My first day at DConf, during lunch, I ended up sitting next to the CTO/CEO of a startup company that was considering D as their language of choice. He commented to me, and which makes sense to me, that the format of the conference wasn't very well geared to people who are just interested in

Re: DConf Recommendation

2014-05-28 Thread Chris Williams via Digitalmars-d
On Wednesday, 28 May 2014 at 22:04:47 UTC, Andrej Mitrovic via Digitalmars-d wrote: Personally I think there were too many talks *per day*, it was hard not getting tired and all the talks were extremely interesting. But I understand that it's hard for people to take more free days for dconf

Re: two questions on enums

2014-04-04 Thread Chris Williams
On Thursday, 3 April 2014 at 23:16:14 UTC, Eric wrote: Okay - I'm new to D, and I'm comming from a java background. Suppose you are designing an API, and you want the user to supply arguments as an enum. But the user needs to define the enum, so how can the API know in advance what enum to

Re: Formal review of dtoh

2014-03-27 Thread Chris Williams
On Tuesday, 25 March 2014 at 20:38:40 UTC, Jacob Carlborg wrote: Code: https://github.com/adamdruppe/tools/blob/dtoh/dtoh.d The author might consider using an associative array of functions to handle the various keywords, rather than switches. I would suggest adding a jsonutils.d or

Re: Portability Function Attribute: @portable

2014-03-25 Thread Chris Williams
On Tuesday, 25 March 2014 at 20:16:49 UTC, Nordlöw wrote: Just by curiosity: What more than forbidding pointer-dribbling (casting and arithmetic) and unions with members smaller than word size should we require to be @portable? Your two are all that I can think of that are definitely

Re: Musings on infinite loops and not reachable returns

2014-03-25 Thread Chris Williams
On Tuesday, 25 March 2014 at 20:49:57 UTC, bearophile wrote: Note how the opApply() of Foo should not end with a return, while the opApply() of Bar is required by the D compiler to end with a return. Yet, Foo is contains an infinite loop, so the result of Bar will not be reached. But the

Re: Challenge: write a really really small front() for UTF8

2014-03-24 Thread Chris Williams
On Sunday, 23 March 2014 at 21:23:18 UTC, Andrei Alexandrescu wrote: Here's a baseline: http://goo.gl/91vIGc. Destroy! Andrei http://goo.gl/TaZTNB

Re: A division problem

2014-03-24 Thread Chris Williams
On Monday, 24 March 2014 at 03:55:41 UTC, bearophile wrote: Can D help the programmer reduce the frequency of similar bugs? And do we want to? When doing math, I always use parentheses and casts to force a single possible outcome of the

Re: Challenge: write a really really small front() for UTF8

2014-03-24 Thread Chris Williams
On Monday, 24 March 2014 at 09:02:19 UTC, monarch_dodra wrote: On Sunday, 23 March 2014 at 21:23:18 UTC, Andrei Alexandrescu wrote: Here's a baseline: http://goo.gl/91vIGc. Destroy! Andrei Before we roll this out, could we discuss a strategy/guideline in regards to detecting and handling

Re: Challenge: write a really really small front() for UTF8

2014-03-24 Thread Chris Williams
On Monday, 24 March 2014 at 16:17:52 UTC, Andrei Alexandrescu wrote: On 3/24/14, 12:53 AM, Chris Williams wrote: On Sunday, 23 March 2014 at 21:23:18 UTC, Andrei Alexandrescu wrote: Here's a baseline: http://goo.gl/91vIGc. Destroy! Andrei http://goo.gl/TaZTNB Nice! Why assert(ret != 0

Re: Walter's DConf 2014 Talks - Topics in Finance

2014-03-21 Thread Chris Williams
On Friday, 21 March 2014 at 22:28:36 UTC, Walter Bright wrote: It's a good thought, but I have zero knowledge of how C++ is used for high frequency trading. Reading through the Wikipedia article on Computational Finance, it looks like it's basically performing simulations where some data is

Re: Alias template param - Undefined Identifier

2014-03-21 Thread Chris Williams
On Wednesday, 19 March 2014 at 00:07:04 UTC, Chris Williams wrote: ...probably something along the lines of making all of my functions a static function in a struct, which I then pass into a template which processes UDAs to generate functions

Re: 1st draft of complete class-based std.random successor

2014-03-20 Thread Chris Williams
On Thursday, 20 March 2014 at 08:22:37 UTC, monarch_dodra wrote: The issue isn't class vs struct, but rather value semantic vs reference semantic (classes are always ref, but structs can be either). That's only completely true if structs are referred to by pointer. ref parameters/returns

Re: 1st draft of complete class-based std.random successor

2014-03-20 Thread Chris Williams
On Thursday, 20 March 2014 at 21:16:27 UTC, Joseph Rushton Wakeling wrote: I think there's a good case for a std.random2.crypto module that contains RNGs that are specifically suitable for cryptography. That said I think the bar here has to be set VERY high, which is why I didn't even begin

Re: Handling invalid UTF sequences

2014-03-20 Thread Chris Williams
To the extent possible, it should try to retain the data. But if ever the character is actually needed for something (like parsing JSON or displaying a glyph), the bad region should be replaced with a series of replacement characters:

Re: bool Associative Array Synchronized

2014-03-20 Thread Chris Williams
On Thursday, 20 March 2014 at 18:06:18 UTC, Etienne wrote: Right, I was assuming it was always ordered, but modern processor pipelines are different I guess. Even without rearranging the order of your code, your bit exists in RAM but all the logic takes place in a CPU register, meaning that

Re: Function to print a diamond shape

2014-03-20 Thread Chris Williams
On Thursday, 20 March 2014 at 21:25:03 UTC, Ali Çehreli wrote: What interesting, boring, efficient, slow, etc. ways are there? Ali Well one of the more convoluted methods that I can think of would be to define a square as a set of four vectors, rotate 45 degrees, and then create a

Re: 1st draft of complete class-based std.random successor

2014-03-19 Thread Chris Williams
On Wednesday, 19 March 2014 at 23:49:41 UTC, Joseph Rushton Wakeling wrote: Hello all, As some of you may already know, monarch_dodra and I have spent quite a lot of time over the last year discussing the state of std.random. To cut a long story short, there are significant problems that

Re: A simple sieve in Phobos?

2014-03-19 Thread Chris Williams
On Wednesday, 19 March 2014 at 01:44:16 UTC, bearophile wrote: Chris Williams: Yeah, several methods work just fine if you change their declaration to isIntegral!T || is(typeof(T) == BigInt). gcd() is one of them. Unfortunately, I don't trust rewriting isIntegral, so this sort of change

Re: A simple sieve in Phobos?

2014-03-19 Thread Chris Williams
On Tuesday, 18 March 2014 at 14:23:32 UTC, bearophile wrote: There is a efficient Sieve implementation in C++ here: http://code.activestate.com/recipes/577966-even-faster-prime-generator/?in=lang-cpp There are of course far faster implementations, but its performance is not bad, while being

Re: A simple sieve in Phobos?

2014-03-19 Thread Chris Williams
On Wednesday, 19 March 2014 at 18:40:49 UTC, Chris Williams wrote: enum uint MAX_N = 10_000_000U; void calcPrimes() pure nothrow { uint[][uint] markers; for (uint L = 2; L MAX_N; L++) { uint[]* pList = (L in markers); if (pList is null) { markers[L + L

Re: A simple sieve in Phobos?

2014-03-18 Thread Chris Williams
On Tuesday, 18 March 2014 at 14:23:32 UTC, bearophile wrote: Is it a good idea to add a simple but reasonably fast Sieve implementation to Phobos? I have needed a prime numbers lazy range, and a isPrime() function numerous times. (And as for std.numeric.fft, people that need even more

Re: A simple sieve in Phobos?

2014-03-18 Thread Chris Williams
On Wednesday, 19 March 2014 at 01:29:16 UTC, bearophile wrote: - A function to compute the GCD on ulongs/longs/bigints is useful. (Issues 4125 and 7102). Yeah, several methods work just fine if you change their declaration to isIntegral!T || is(typeof(T) == BigInt). gcd() is one of them.

Alias template param - Undefined Identifier

2014-03-18 Thread Chris Williams
I have a series of functions that each needs to change directory, perform an action, and then revert to the original working directory. I could put a wrapper around the calls to these functions that performs this action, but I figured a little macro would be sufficient for my needs (it's

Re: Alias template param - Undefined Identifier

2014-03-18 Thread Chris Williams
On Tuesday, 18 March 2014 at 22:42:20 UTC, anonymous wrote: You can pass the variable name as a string: Or you can get the variable name from the alias parameter: import std.string: format; template gotoPath(alias path) { enum gotoPath = format(q{ ...

Re: Alias template param - Undefined Identifier

2014-03-18 Thread Chris Williams
On Tuesday, 18 March 2014 at 23:05:51 UTC, bearophile wrote: Chris Williams: I could put a wrapper around the calls to these functions that performs this action, but I figured a little macro would be sufficient for my needs (it's just a little script.) I suggest to keep the code simpler

Re: Alias template param - Undefined Identifier

2014-03-18 Thread Chris Williams
On Tuesday, 18 March 2014 at 23:33:12 UTC, bearophile wrote: Chris Williams: But I also like to know how most-effectively to write a C-style macro in D, so it seemed worth checking what the state of the art is. This is an antipattern :-) Bye, bearophile As are goto, pointers

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread Chris Williams
On Monday, 17 March 2014 at 19:07:45 UTC, Mason McGill wrote: On Monday, 17 March 2014 at 17:41:16 UTC, bearophile wrote: Mason McGill: http://wiki.dlang.org/DIP58 Seems nice. Thanks. There are a few awkward parts to maintain compatibility, but that seems to be the only way to go.

Re: DIP58: .. as a Binary Operator

2014-03-17 Thread Chris Williams
On Monday, 17 March 2014 at 20:13:20 UTC, Mason McGill wrote: Interesting, though I feel like operator syntax really shines when either 1) It's significantly shorter/simpler than the equivalent function calls. 2) It appeals to domain-specific intuitions. In general, I agree. Though I

Re: inlining...

2014-03-14 Thread Chris Williams
On Friday, 14 March 2014 at 22:12:38 UTC, Nick Sabalausky wrote: On 3/14/2014 8:37 AM, Manu wrote: On 14 March 2014 22:02, John Colvin john.loughran.col...@gmail.com wrote: I don't know how good compilers are at taking this sort of thing into account already. I don't know if they try or

Re: to! converting 1D to 2D array

2014-03-14 Thread Chris Williams
On Friday, 14 March 2014 at 04:36:27 UTC, ed wrote: As to whether or not this should work: int[4] a=[1,2,3,4]; int[2][2] b; b=a; is up to the D language gurus. I think it should... but I'm no language developer, there may be other side-effects I haven't thought about. Cheers, ed In C,

Re: Regarding fixed size arrays

2014-03-14 Thread Chris Williams
On Saturday, 15 March 2014 at 00:11:22 UTC, bearophile wrote: Do you think it's useful/worth supporting code like that? My expectation would be that your code is implicitly the same as: int[5] foo(int[2] a, int[3] b) { int[5] staticArray; int[] dynamicArray = a ~ b; staticArray =

Re: Get Compile Errors - Command Line

2014-03-14 Thread Chris Williams
On Friday, 14 March 2014 at 17:10:46 UTC, Bauss wrote: I'm using dmd.exe and not cmd.exe dmd.exe doesn't have a GUI. You're probably running dmd.exe inside cmd.exe. dmd foo.d mylog.txt

Re: GC high level overview/documentation?

2014-03-13 Thread Chris Williams
On Thursday, 13 March 2014 at 13:14:03 UTC, Ethan wrote: Is there a high level overview of how the runtime expects the garbage collector to behave anywhere, or any kind of documentation outside of the core.memory and garbage collection documentation on dlang.org? There was a presentation at

Re: Bountysource: Facebook offers additional funding for D issues

2014-03-13 Thread Chris Williams
On Thursday, 13 March 2014 at 20:10:34 UTC, Andrei Alexandrescu wrote: On 3/13/14, 1:09 PM, Steven Schveighoffer wrote: On Thu, 13 Mar 2014 16:03:54 -0400, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On Thursday, 13 March 2014 at 19:52:05 UTC, Andrei Alexandrescu wrote: For example, I'm

Re: to! converting 1D to 2D array

2014-03-13 Thread Chris Williams
On Thursday, 13 March 2014 at 03:31:09 UTC, ed wrote: On Thursday, 13 March 2014 at 00:15:19 UTC, Chris Williams wrote: [snip] It shouldn't and probably isn't working. It is working and in fact it is in a const pure @safe function. So I will trust it :-) Well it's like a broken watch

Re: Restriction on interface function types

2014-03-12 Thread Chris Williams
On Wednesday, 12 March 2014 at 11:56:43 UTC, Steven Schveighoffer wrote: What you want simply isn't possible. An interface binds at runtime, and you need to declare types at compile-time. You can't use an interface method to define the type of y. Here's the method that is used in Phobos:

Re: Plan 9 support

2014-03-12 Thread Chris Williams
On Wednesday, 12 March 2014 at 13:42:49 UTC, Jonathan Dunlap wrote: Just out of curiosity.,. Is there any way to use D with it? http://plan9.bell-labs.com/wiki/plan9/Porting_alien_software_to_Plan_9/index.html http://en.wikipedia.org/wiki/ANSI/POSIX_Environment It might take some work, but I

Re: Final by default?

2014-03-12 Thread Chris Williams
On Wednesday, 12 March 2014 at 22:50:00 UTC, Walter Bright wrote: But we nearly lost a major client over it. We're past the point where we can break everyone's code. As someone who would like to be able to use D as a language, professionally, it's more important to me that D gain future

Re: Final by default?

2014-03-12 Thread Chris Williams
On Thursday, 13 March 2014 at 00:15:50 UTC, Walter Bright wrote: On 3/12/2014 5:02 PM, Chris Williams wrote: As someone who would like to be able to use D as a language, professionally, it's more important to me that D gain future clients than that it maintains the ones that it has. Even more

Re: Final by default?

2014-03-12 Thread Chris Williams
On Thursday, 13 March 2014 at 00:18:06 UTC, Andrei Alexandrescu wrote: Sorry, no. We are opposed to having compiler flags define language semantics. If done excessively, I could certainly see that. But outside of new languages that haven't gotten to that point yet, I don't know of any that

Re: Final by default?

2014-03-12 Thread Chris Williams
On Thursday, 13 March 2014 at 00:48:15 UTC, Walter Bright wrote: On 3/12/2014 5:18 PM, Andrei Alexandrescu wrote: We are opposed to having compiler flags define language semantics. Yeah, that's one of those things that always seems like a reasonable idea, but experience with it isn't happy.

Re: to! converting 1D to 2D array

2014-03-12 Thread Chris Williams
On Wednesday, 12 March 2014 at 03:37:49 UTC, ed wrote: My understanding of your explanation is that it shouldn't work. It shouldn't and probably isn't working. If nothing else, when you use to!(x)(y), x should be the type that you're trying to convert into. So I would expect your code to be

Re: Proposal for fixing dchar ranges

2014-03-11 Thread Chris Williams
On Tuesday, 11 March 2014 at 14:16:31 UTC, Steven Schveighoffer wrote: But I would never expect any kind of indexing or slicing to use number of code points, which clearly requires O(n) decoding to determine it's position. That would be disastrous. If the indexes put into the slice aren't by

Re: Maybe in D3...

2014-03-10 Thread Chris Williams
On Monday, 10 March 2014 at 14:50:27 UTC, Vladimir Panteleev wrote: From time to time, there are discussions concerning ideas which would impact the language, as it is now, too drastically to be implemented (it would break too much code or require a significant reengineering effort). These

Re: Proposal for fixing dchar ranges

2014-03-10 Thread Chris Williams
On Monday, 10 March 2014 at 18:13:14 UTC, Steven Schveighoffer wrote: Indexing is rarely a feature one needs or should use, especially with encoded strings. If I was writing something like a chat or terminal window, I would want to be able to jump to chunks of text based on some sort of

Any way to print compile-time generated code?

2014-03-10 Thread Chris Williams
I'm toying with the dproto library and have encountered an issue where I can't remove items from a repeated list of items. I'd like to see what the mixins are producing in terms of actual D code, so that I can figure out how I can correctly try to delete an entry or find the code that's

Re: Any way to print compile-time generated code?

2014-03-10 Thread Chris Williams
On Monday, 10 March 2014 at 18:25:10 UTC, Adam D. Ruppe wrote: Change the mixin(x) line to pragma(msg, x);. It will then print out the generated string at compile time instead of mixing it in so you can take a look at it. That just gives me an error: source/app.d(29): Error: Cannot interpret

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Chris Williams
On Thursday, 27 February 2014 at 13:27:14 UTC, Remo wrote: Apparently C# will get it in the next version. http://blogs.msdn.com/b/jerrynixon/archive/2014/02/26/at-last-c-is-getting-sometimes-called-the-safe-navigation-operator.aspx What do you think how well would this work in D2 ? I like

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Chris Williams
On Thursday, 27 February 2014 at 16:08:26 UTC, Robert Clipsham wrote: D doesn't need this, you can implement monadic null checking in the library: By that argument, I can implement anything that D can do in assembler, hence I don't need D.

Re: Safe Navigation Operator “?.” for D2 ?

2014-02-27 Thread Chris Williams
On Thursday, 27 February 2014 at 17:02:02 UTC, Robert Clipsham wrote: On Thursday, 27 February 2014 at 16:32:18 UTC, Chris Williams wrote: On Thursday, 27 February 2014 at 16:08:26 UTC, Robert Clipsham wrote: D doesn't need this, you can implement monadic null checking in the library

Re: Portability Function Attribute: @portable

2014-02-25 Thread Chris Williams
On Tuesday, 25 February 2014 at 23:06:46 UTC, Adam D. Ruppe wrote: I think the problem here is there's too many functions that would need to be marked it to be useful and it isn't a big enough deal for most libs to bother. I think the larger issue would be that the same people who understand

Re: Implement the unum representation in D ?

2014-02-21 Thread Chris Williams
On Friday, 21 February 2014 at 09:04:40 UTC, Ivan Kazmenko wrote: I believe that the repeating decimals, or better, repeating binary fractions, will hardly be more useful than a rational representation like p/q. Yeah, in retrospect I would say that a binary layout like: numberator length |

Re: convert int[][] to int**

2014-02-21 Thread Chris Williams
On Thursday, 20 February 2014 at 17:02:15 UTC, Dicebot wrote: You can't do it without allocation because memory layout is different for int** and int[][] in D - are.ptr in latter points to slice struct (pointer+length) as opposed to raw pointer in former. You should only have to copy the top

Re: convert int[][] to int**

2014-02-21 Thread Chris Williams
On Friday, 21 February 2014 at 19:13:13 UTC, Chris Williams wrote: On Thursday, 20 February 2014 at 17:02:15 UTC, Dicebot wrote: You can't do it without allocation because memory layout is different for int** and int[][] in D - are.ptr in latter points to slice struct (pointer+length

Re: Implement the unum representation in D ?

2014-02-20 Thread Chris Williams
On Thursday, 20 February 2014 at 23:13:20 UTC, Francesco Cattoglio wrote: On Thursday, 20 February 2014 at 10:10:13 UTC, Nick B wrote: The abstract is here: http://openparallel.com/multicore-world-2014/speakers/john-gustafson/ The pursuit of exascale floating point is ridiculous, since we

Re: Why function template 'among' is of complexity O(1) and not O(n)?

2014-02-19 Thread Chris Williams
On Wednesday, 19 February 2014 at 22:05:49 UTC, Peter Alexander wrote: If you want to get even more anal about it, searching an array is technically O(1) because an array cannot be bigger than size_t.max, and since size_t.max is a constant, O(size_t.max) is O(1). Again, completely misleading

  1   2   >