Re: Classes and @disable this()

2015-02-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, February 09, 2015 15:25:14 Steven Schveighoffer via Digitalmars-d-learn wrote: Well, if I do this: class C {} I can do this: new C(); Mechanisms to disable this are kind of awkward. I can define this() as private, but that doesn't help for intra-module calls. static class C

Re: Cannot use the same template arguments on function as the ones on struct

2015-02-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 12, 2015 07:11:12 Stefan Koch via Digitalmars-d-learn wrote: DMD cannot overload templated and non-templated functions an empty template argument is needed That's not actually true anymore. However, you have to be really careful when you do it, because it pretty much

Re: What exactly shared means?

2015-01-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 05, 2015 12:59:26 via Digitalmars-d-learn wrote: I am also not overly happy with D making TLS default. That means new threads instantiate a lot of unused memory if the workload is heterogeneous (different threads do different type of work). TLS only make sense for things

Re: Conditional functions

2015-01-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 05, 2015 17:58:06 Dominikus Dittes Scherkl via Digitalmars-d-learn wrote: Cool. I'm every day again astonished how cool D really is. And I'm increasingly frustrated with how other languages lack many of D's cool features... :) - Jonathan M Davis

Re: OutputDebugString()

2015-03-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, March 14, 2015 17:49:10 Robert M. Münch via Digitalmars-d-learn wrote: Now, just need to check why I don't see any debug output but that's not a DMD issue ;-). In case you didn't know, if you're not running the program in visual studio, you should see the output in in DebugView:

Re: ref for (const) variables

2015-03-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, March 16, 2015 18:46:59 Namespace via Digitalmars-d-learn wrote: May this be worth of an enhancement request? Or was this already rejected? And, no, I want no mutable references such as C++. Walter has been adamantly against having ref variables like C++ has. They're a potential

Re: ref for (const) variables

2015-03-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 17, 2015 09:59:59 Namespace via Digitalmars-d-learn wrote: On Tuesday, 17 March 2015 at 09:56:09 UTC, Jonathan M Davis wrote: On Monday, March 16, 2015 18:46:59 Namespace via Digitalmars-d-learn wrote: May this be worth of an enhancement request? Or was this already

Re: final methods by default

2015-03-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, March 20, 2015 23:53:14 Daniel Kozak via Digitalmars-d-learn wrote: On Fri, 20 Mar 2015 22:11:51 + weaselcat via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Friday, 20 March 2015 at 14:25:22 UTC, ref2401 wrote: Why aren't methods of class final by

Re: std.stdio.writeln

2015-03-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, March 09, 2015 15:45:58 ketmar via Digitalmars-d-learn wrote: On Mon, 09 Mar 2015 14:48:19 +, John Colvin wrote: Yet another excellent example of why we should abolish the comma operator in D. or at least warn about it. producing a warning for such expression will ring a

Re: enum and static if

2015-03-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 11, 2015 14:55:01 Namespace via Digitalmars-d-learn wrote: Thanks, I've hoped that 'static if' is a full replacement for #if Walter Bright has a rather dim view of #if and friends in C/C++ given how often he's seen them abused, which is why version and static if are more

Re: Object as function argument

2015-03-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 05, 2015 19:35:34 Chris Sperandio via Digitalmars-d-learn wrote: Hi, I'm a developer coming from C and I've a question about class instance as method or function parameter. In the book The D Programming Language, I read the instance was passed by reference to functions

Re: is struct delete deterministic? (cf used in Unique)

2015-03-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, March 08, 2015 14:04:52 Timothee Cour via Digitalmars-d-learn wrote: On Sun, Mar 8, 2015 at 4:36 AM, Jonathan M Davis via Digitalmars-d-learn I would point out though that until recently, the GC never ran the destructors for structs on the heap, because it didn't have the type

Re: Is std.signals deprecated?

2015-03-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 05, 2015 21:54:01 weaselcat via Digitalmars-d-learn wrote: Seems barely maintained and there was a proposed replacement claiming it was broken(http://wiki.dlang.org/Review/std.signal) that never got approved. Is std.signals worth using over a dub package? I think that the

Re: 2.067 Beta: Behavior of enum and ref changed

2015-03-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 10, 2015 13:26:00 Ali Çehreli via Digitalmars-d-learn wrote: On 03/10/2015 11:05 AM, Ali Çehreli wrote: In other words, the result of the implicit conversion is an rvalue Steven Schveighoffer says there is no rvalue in this case; an enum is a derivative:

Re: 2.067 Beta: Behavior of enum and ref changed

2015-03-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 10, 2015 08:19:27 Meta via Digitalmars-d-learn wrote: On Tuesday, 10 March 2015 at 07:04:48 UTC, Andre wrote: Hi, following coding raises a compiler error with the beta of 2.067. Is this error intended or not? It is working if I change first line of main to: ulong

Re: std.stdio.writeln

2015-03-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, March 09, 2015 22:29:23 Meta via Digitalmars-d-learn wrote: On Monday, 9 March 2015 at 22:00:46 UTC, ketmar wrote: i remember that deprecation was rejected. maybe this is false memory, though. btw, there are legit uses of comma, in c-style `for`, for example. this should

Re: How to use UFCS and std.algorithm.sort?

2015-03-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 10, 2015 07:24:52 Andre via Digitalmars-d-learn wrote: Hi, with the new beta I get the warning I should use std.algorithm.sort instead the .sort property. I thought the std.algorithm.sort method is used in this example? void main() { import std.algorithm: sort, uniq,

Re: Filling a char array with letters and element type of char[]

2015-03-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 03, 2015 09:06:03 Tobias Pankrath via Digitalmars-d-learn wrote: I have three questions? If I change the iterator which I get from algorithm, the owner data will change or not? How to use std.algorithm.fill with char types? What is the type of char array holds

Re: D constness: head tail

2015-03-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, March 02, 2015 14:20:45 drug via Digitalmars-d-learn wrote: I'm just trying to study constness in D and periodically fails with it. Thanks for answer. Then I guess that constness in D is in the finished form, hasn't some pitfalls, won't be changed significantly in some future and so

Re: D constness: head tail

2015-03-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, March 02, 2015 11:21:32 drug via Digitalmars-d-learn wrote: what is the state of headtail constness in D? Where we are and where we are moving toward? Where can I find some info about head and tail constness? I mean forum posts, stackoverflow questions, arcticles somewhere and so

Re: D constness: head tail

2015-03-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, March 02, 2015 10:15:00 ketmar via Digitalmars-d-learn wrote: or, tl;dr: `const` in D is working as it was designed to work. there are no changes planning for it, and it will not be turned to c++-like const. We couldn't even if we wanted to. It would never work with immutable. -

Re: Filling a char array with letters and element type of char[]

2015-03-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 03, 2015 08:50:35 Steven Schveighoffer via Digitalmars-d-learn wrote: What is the type of char array holds why it does not matches char? Because D is schizophrenic ;) Phobos considers char[] arrays not to be arrays of char, only ranges of dchar. Unless you talk to the

Re: Getting what came *before* the results of a find call

2015-02-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, February 27, 2015 14:42:17 Ali Çehreli via Digitalmars-d-learn wrote: On 02/27/2015 02:29 PM, Mark Isaacson wrote: What's the idiomatic way of getting everything *before* the results of a call to find? assert(hello world.find( world).what_goes_here??? == hello); In an

Re: const member function

2015-02-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, February 23, 2015 09:12:33 rumbu via Digitalmars-d-learn wrote: On Saturday, 21 February 2015 at 15:26:28 UTC, ketmar wrote: On Sat, 21 Feb 2015 08:27:13 +, rumbu wrote: My question was not how I do this, I know already. My question was if there is another way to safely

Re: Deprecation process documented?

2015-02-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 24, 2015 08:49:55 Jacob Carlborg via Digitalmars-d-learn wrote: Is the deprecation process used for Phobos and druntime code documented somewhere? I.e. how long after a deprecation is a symbols removed and so on. No, it's not documented. I really should put it up on the

Re: Is this a bug in dmd 2.067 for struct initializers?

2015-02-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, February 22, 2015 17:45:48 Ali Çehreli via Digitalmars-d-learn wrote: On 02/22/2015 03:17 PM, Martin Nowak wrote: On Thursday, 19 February 2015 at 22:07:55 UTC, stewarth wrote: I've gone with static this() approach and it works. You should use shared static this to initialize

Re: Deprecation process documented?

2015-02-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 24, 2015 17:57:12 Jacob Carlborg via Digitalmars-d-learn wrote: On 2015-02-24 10:20, Jonathan M Davis via Digitalmars-d-learn wrote: No, it's not documented. I really should put it up on the wiki. The current process is that if the replacement for the symbol is being

Re: const member function

2015-02-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, February 21, 2015 08:27:13 rumbu via Digitalmars-d-learn wrote: On Saturday, 21 February 2015 at 08:08:25 UTC, Mike Parker wrote: On 2/21/2015 4:31 PM, rumbu wrote: you can do this instead: this() { cache = SomeExpensiveOp(); } public @property const(int)

Re: Installing DMD From Zip

2015-02-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 26, 2015 10:10:45 Mike Parker via Digitalmars-d-learn wrote: Once upon a time, there were instructions linked from the DMD download page explaining how to install from the zip file on each platform. I can't find anything about it now, not from dlang.org or from the wiki.

Re: Installing DMD From Zip

2015-02-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 26, 2015 19:47:20 Mike Parker via Digitalmars-d-learn wrote: On 2/26/2015 7:26 PM, Jonathan M Davis via Digitalmars-d-learn wrote: As for the page in question, it looks like it was probably lost in the site redesign. Looks like the same can be said for the page

Re: Deprecation process documented?

2015-02-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 24, 2015 10:05:21 H. S. Teoh via Digitalmars-d-learn wrote: On Tue, Feb 24, 2015 at 09:55:28AM -0800, Jonathan M Davis via Digitalmars-d-learn wrote: [...] Regardless, when a symbol is either marked as scheduled for deprecation in the docs or outright deprecated

Re: Thread.sleep( dur!(msecs)( 50 ) ); // sleep for 50 milliseconds

2015-01-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 30, 2015 10:39:44 Suliman via Digitalmars-d-learn wrote: foreach(f; files)) { if (canFind(to!string(f), )) { writeln(whitespace found:); writeln(f); Thread.sleep( dur!(msecs)( 50 ) ); // sleep for

Re: is it std.datetime bug?

2015-04-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 31, 2015 12:47:34 anonymous via Digitalmars-d-learn wrote: On Tuesday, 31 March 2015 at 11:51:26 UTC, drug wrote: import std.datetime; import std.stdio; void main() { long.max.SysTime.toISOExtString.writeln; } dmd 2.065 (dpaste.dzfl.pl):

Re: User defined properties signatures

2015-04-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 20, 2015 19:42:30 dvic via Digitalmars-d-learn wrote: Thanks for your answer Jonathan. But does the return type part of a method signature? I don't know what theory is claiming about that, but for me they are 2 different methods. So contextually, the best fit should prevail.

Re: SysTime.toISOExtString with timezone offset

2015-04-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 20, 2015 08:10:40 Jack Applegame via Digitalmars-d-learn wrote: I need current system time ISO string with timezone offset. For example 2015-04-20T11:00:44.735441+03:00 but Clock.currTime.toISOExtString doesn't write offset: 2015-04-20T11:00:44.735441+03:00 I found

Re: std.datetime.parseRFC822DateTime

2015-04-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 21, 2015 08:14:10 Jakob Ovrum via Digitalmars-d-learn wrote: std.datetime contains parseRFC822DateTime to convert from an RFC822/RFC5322 formatted string (ala Sat, 6 Jan 1990 12:14:19 -0800) to a SysTime. Does it contain anything for the converse - converting from a SysTime

Re: How to turn an inout(Object) into a string

2015-04-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, April 26, 2015 05:09:30 Meta via Digitalmars-d-learn wrote: On Sunday, 26 April 2015 at 04:52:36 UTC, Jonathan M Davis wrote: It's only undefined if mutation is involved, though I don't know if mutation is involved in this case or not I was thinking that a class can define an

Re: How to turn an inout(Object) into a string

2015-04-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, April 26, 2015 03:51:25 Meta via Digitalmars-d-learn wrote: On Sunday, 26 April 2015 at 03:48:00 UTC, tcak wrote: On Sunday, 26 April 2015 at 03:09:17 UTC, Meta wrote: The following code spits out pages of error messages, and it's driving me insane. I know that Object.toString

Re: Observing exceptions in a destructor

2015-04-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, April 22, 2015 01:02:15 Mark Isaacson via Digitalmars-d-learn wrote: I'd like to be able to know if my destructor is being called because an exception was thrown. Any way to do that? I tried this: http://ideone.com/JbXH2w (Pasted here for convenience): import std.stdio,

Re: User defined properties signatures

2015-04-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 20, 2015 18:35:34 dvic via Digitalmars-d-learn wrote: Hi guys, It seems it's possible to define different read properties, only differing by the return type. Not possible. Just like pretty much any C-derived language (C++, Java, C#, etc.) the return type of a function is not

Re: A slice can lose capacity simply by calling a function

2015-05-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 02, 2015 01:21:14 Ali Çehreli via Digitalmars-d-learn wrote: 2) void foo(const(int[]) arr); // cannot affect anything // (even capacity) Actually, you can modify the capacity of arr quite easily. All you have to do is slice it

Re: A slice can lose capacity simply by calling a function

2015-05-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 02, 2015 07:46:27 Ali Çehreli via Digitalmars-d-learn wrote: On 05/02/2015 01:56 AM, Jonathan M Davis via Digitalmars-d-learn wrote: I really don't think that it's reasonable in the general case to expect to be able to guarantee that the capacity of a dynamic array won't

Re: Parameter storage class 'in' transitive like 'const'?

2015-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 02, 2015 22:20:33 Ali Çehreli via Digitalmars-d-learn wrote: We know that 'in' is equivalent to const scope: http://dlang.org/function.html#parameters So, the constness of 'in' is transitive as well, right? Of course. in is identical to const scope. It doesn't introduce

Re: A slice can lose capacity simply by calling a function

2015-05-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, 4 May 2015 at 06:23:42 UTC, Ali Çehreli wrote: On 05/03/2015 06:06 PM, Jonathan M Davis via Digitalmars-d-learn wrote: (I am eagerly waiting for your DConf talk to see how you make sense of it all.) Well, we'll see how much I'm able to cover about arrays. The focus of the talk

Re: Efficiently passing structs

2015-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 03, 2015 21:58:12 bitwise via Digitalmars-d-learn wrote: If I have a large struct that needs to be passed around, like a 4x4 matrix for example, how do I do that efficiently in D? In std.datetime, in is used for most struct parameters, but I'm confused by the docs for function

Re: A slice can lose capacity simply by calling a function

2015-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 03, 2015 15:21:15 Andrew Godfrey via Digitalmars-d-learn wrote: I really don't think that it's an issue in general, but if you do want to guarantee that nothing affects the capacity of your array, then you're going to need to either wrap all access to it I agree with

Re: Capacity is first-come first served for multiple slices to all elements

2015-04-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, April 30, 2015 11:59:00 Ali Çehreli via Digitalmars-d-learn wrote: (Thanks to Luís Marques for waking me up.) Although it makes sense now, somehow some parts of this story is news to me after all these years. :-/ When there are multiple slices to all elements of an array, they

Re: Static function template

2015-05-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 07, 2015 10:19:42 Lemonfiend via Digitalmars-d-learn wrote: Is it not possible to have a static function template with the same name as the non-static version? No. Unfortunately, you can't overload based on static. I believe that it works if they're overloaded on parameters but

Re: Efficiently passing structs

2015-05-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 5 May 2015 at 02:47:03 UTC, bitwise wrote: On Mon, 04 May 2015 00:16:03 -0400, Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: D will move the argument if it can rather than copying it (e.g. if a temporary is being passed in), which reduces the need

Re: Bug or feature?

2015-05-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 10, 2015 10:48:33 Ali Çehreli via Digitalmars-d-learn wrote: On 05/10/2015 10:18 AM, Jack Applegame wrote: code: class A { void test(int) {} } class B : A { void test() { super.test(1); // compiles test(10); // error } }

Re: UFCS

2015-05-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 15, 2015 21:31:35 Manfred Nowak via Digitalmars-d-learn wrote: The following gives: Error: 'a += b' is not a scalar, it is a C although UFCS should engage. -manfred class C{} int main(){ void opOpAssign( string op)( C a, C b){ } C a, b; a+= b; } Overloaded

Re: Returning an empty range of a given type

2015-05-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 14, 2015 02:47:22 rcorre via Digitalmars-d-learn wrote: I've run into this situation a lot: I have a function that returns a range (in this case, a slice of a custom container). In some cases, the function needs to return an empty range. It sounded like takeNone was what I

Re: Template type deduction and specialization

2015-05-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 20, 2015 06:31:11 Mike Parker via Digitalmars-d-learn wrote: I don't understand why this behaves as it does. Given the following two templates: ``` void printVal(T)(T t) { writeln(t); } void printVal(T : T*)(T* t) { writeln(*t); } ``` I find that I actually have

Re: Template type deduction and specialization

2015-05-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 20, 2015 07:36:21 Namespace via Digitalmars-d-learn wrote: What about: import std.stdio; void printVal(T)(T t) { static if (is(T : U*, U)) printVal(*t); else writeln(t); } void main() { int x = 100; printVal(x); int*

Re: Template type deduction and specialization

2015-05-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 20, 2015 19:20:19 Mike Parker via Digitalmars-d-learn wrote: On 5/20/2015 6:35 PM, Jonathan M Davis via Digitalmars-d-learn wrote: I'm using a fairly recent version of dmd master, and it prints out the address for px in both cases when I compile your code. So, if it's

Re: Internal Compiler Error Help

2015-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 21, 2015 08:28:29 Saurabh Das via Digitalmars-d-learn wrote: Am I correct in assuming that an internal error in the compiler should be filed as a bug report? Yes. You should never see an ICE, and the compiler should never segfault. So, whenever you see either of those happen,

Re: Why is there no named parameter support?

2015-06-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 08, 2015 20:36:05 Yuxuan Shui via Digitalmars-d-learn wrote: Is there any reasons/difficulties for not implementing named parameters? There is clearly a need: http://forum.dlang.org/thread/wokfqqbexazcguffw...@forum.dlang.org#post-pxndhoskpjxvnoacajaz:40forum.dlang.org

Re: Why is there no named parameter support?

2015-06-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 08, 2015 23:18:50 Timothee Cour via Digitalmars-d-learn wrote: nim has both overloading and named arguments (with reordering and defaults allowed): http://nim-lang.org/docs/tut1.html#procedures-named-arguments and it doesn't seem to cause issues. Is there a document / thread

Re: Why is there no named parameter support?

2015-06-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 09, 2015 01:38:56 Timothee Cour via Digitalmars-d-learn wrote: On Mon, Jun 8, 2015 at 11:32 PM, Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Monday, June 08, 2015 23:18:50 Timothee Cour via Digitalmars-d-learn wrote: nim has both

Re: Nullable with reference types

2015-07-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 30, 2015 14:29:52 Steven Schveighoffer via Digitalmars-d-learn wrote: I know this is just back-of-envelope, but what's wrong with: alias Nullable(T) if(is(T == class)) = T; bool isNull(T)(T t) if(is(T == class)) { return t is null;} In principle, there's no reason why we

Re: Template Declarations - Why not Template definitions?

2015-07-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 01, 2015 09:29:56 via Digitalmars-d-learn wrote: On Tuesday, 30 June 2015 at 21:06:58 UTC, WhatMeWorry wrote: Bonus question: Isn't a Zero-parameter template declaration pretty much worthless? Functions in templates get certain attributes inferred automatically, like

Re: how to avoid cycle detected?

2015-07-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 01, 2015 09:09:52 aki via Digitalmars-d-learn wrote: Following code causes run-time error. How can I use static this() without causing error? It's difficult to avoid this situation because actual code is more complex. file main.d: void main() { } file a.d: import b;

Re: Nullable with reference types

2015-07-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 01, 2015 08:43:59 Steven Schveighoffer via Digitalmars-d-learn wrote: On 7/1/15 5:45 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: On Tuesday, 30 June 2015 at 18:29:31 UTC, Steven Schveighoffer wrote: I know this is just back-of-envelope, but what's wrong with:

Re: Bug or feature?

2015-06-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, 29 June 2015 at 14:28:06 UTC, anonymous wrote: On Monday, 29 June 2015 at 12:04:46 UTC, Jonathan M Davis wrote: You haven't declared an immutable constructor, so you can't construct an immutable Foo. That's not what's happening. Constructing an immutable Foo works just fine.

Re: Nullable with reference types

2015-06-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 00:02:38 UTC, Meta wrote: On Monday, 29 June 2015 at 19:29:37 UTC, sigod wrote: Hi, everyone. ``` import std.typecons : Nullable; class Test {} Nullable!Test test; assert(test.isNull); ``` Why does `Nullable` allowed to be used with reference types (e.g.

Re: time difference - beautify my code

2015-07-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 02, 2015 19:42:57 anonymous via Digitalmars-d-learn wrote: On Thursday, 2 July 2015 at 19:03:49 UTC, dd0s wrote: i got a date t described in seconds from 1.1.1970, I.e., you have a unix timestamp. and i want to check if the current time is further than 12 hours from

Re: how to avoid cycle detected?

2015-07-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 02, 2015 06:56:26 Steven Schveighoffer via Digitalmars-d-learn wrote: On 7/1/15 6:25 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Wednesday, July 01, 2015 08:52:38 Steven Schveighoffer via Digitalmars-d-learn wrote: The runtime cannot introspect the code

Re: time difference - beautify my code

2015-07-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 02, 2015 19:03:48 dd0s via Digitalmars-d-learn wrote: i got a date t described in seconds from 1.1.1970, and i want to check if the current time is further than 12 hours from the given time t. the following code works but it's super ugly =S please give me some ideas how to

Re: how to avoid cycle detected?

2015-07-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 01, 2015 08:52:38 Steven Schveighoffer via Digitalmars-d-learn wrote: The runtime cannot introspect the code to detect the circular dependency, so it makes a conservative decision. I'm waiting on an introduction of RTInfo for modules [1] to allow us to mark static ctors as

Re: Replacement of std.stream

2015-06-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, June 28, 2015 11:14:57 Baz via Digitalmars-d-learn wrote: On Sunday, 28 June 2015 at 05:04:48 UTC, DlangLearner wrote: I will convert a Java program into D. The original Java code is based on the class RandomeAccessFile which essentially defines a set of methods for read/write

Re: Bug or feature?

2015-06-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, June 28, 2015 11:37:59 Jack Applegame via Digitalmars-d-learn wrote: I don't see any reason why it should not compile. import std.array; import std.range; import std.algorithm; class Foo { } void main() { auto result = iota(3).map!(i = new immutable Foo).array(); }

Re: proper way to calculate toHash() for string

2015-06-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, 30 June 2015 at 14:19:39 UTC, aki wrote: I would like to know proper way to calculate hash for given member fields. class Foo { int value; string str; override nothrow @safe size_t toHash() { // calculate hash based on field value.

Re: Checking template parameter types of class

2015-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 25, 2015 03:42:22 tcak via Digitalmars-d-learn wrote: On Monday, 25 May 2015 at 03:35:22 UTC, Jonathan M Davis wrote: On Monday, May 25, 2015 03:19:29 tcak via Digitalmars-d-learn wrote: Is there any syntax for something like that: class Resource(T) if( is(T:

Re: Checking template parameter types of class

2015-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 25, 2015 03:19:29 tcak via Digitalmars-d-learn wrote: Is there any syntax for something like that: class Resource(T) if( is(T: FileResource) ){ } I tried it as above, but it is not accepted. Maybe I am following a wrong syntax. I tried class Resource(T: FileResource){ }

Re: How to append range to array?

2015-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 24, 2015 22:13:25 Steven Schveighoffer via Digitalmars-d-learn wrote: On 5/23/15 4:27 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Saturday, May 23, 2015 07:03:33 Vladimir Panteleev via Digitalmars-d-learn wrote: int[] arr = [1, 2, 3]; auto r = iota(4, 10

Re: How to append range to array?

2015-05-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 23, 2015 07:03:33 Vladimir Panteleev via Digitalmars-d-learn wrote: int[] arr = [1, 2, 3]; auto r = iota(4, 10); // ??? assert(equal(arr, iota(1, 10))); Hopefully in one GC allocation (assuming we know the range's length). I tried std.range.primitives.put but its

Re: How to append range to array?

2015-05-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 23, 2015 08:36:47 weaselcat via Digitalmars-d-learn wrote: On Saturday, 23 May 2015 at 08:35:45 UTC, weaselcat wrote: On Saturday, 23 May 2015 at 07:03:35 UTC, Vladimir Panteleev wrote: int[] arr = [1, 2, 3]; auto r = iota(4, 10); // ??? assert(equal(arr, iota(1,

Re: Dual conditions in D and Python

2015-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 21, 2015 16:57:14 Dennis Ritchie via Digitalmars-d-learn wrote: Hi, In Python I can write this: if (4 = 5 = 6): print (OK) - http://rextester.com/NNAM70713 In D, I can only write this: import std.stdio; void main() { if (4 = 5 5 = 6)

Re: What is a mutable method?

2015-05-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 22, 2015 12:12:45 tcak via Digitalmars-d-learn wrote: I know there is mutable variables, but what is a mutable method? Error message says mutable method project.mariadb.connector.ver2p1.resultset.ResultSetColumn.info is not callable using a const object. It's a method / member

Re: automatically verifying code samples in phobos docs

2015-08-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, August 20, 2015 02:09:12 Timon Gehr via Digitalmars-d-learn wrote: On 08/20/2015 02:02 AM, Laeeth Isharc wrote: On Thursday, 20 August 2015 at 00:00:55 UTC, Timon Gehr wrote: On 08/20/2015 01:41 AM, Laeeth Isharc wrote: BTW I don't know why you can't convert a char[] to

Re: Weird error message.

2015-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 16, 2015 21:32:08 Warwick via Digitalmars-d-learn wrote: Dont know what to make of this, I pretty much get it every other time I call rdmd. It'll alternate between running fine and then giving me this error... C:\Program Files (x86)\Notepad++rdmd J:\Code\statproc.d

Re: Array start index

2015-08-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 03, 2015 21:32:03 DLearner via Digitalmars-d-learn wrote: On Monday, 3 August 2015 at 13:45:01 UTC, bachmeier wrote: On Sunday, 2 August 2015 at 21:58:48 UTC, QAston wrote: Adding 1-indexed arrays to the language fixes nothing. Just write your 1-indexed array type and if

Re: std.container.array - are these arrays passed by reference?

2015-07-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 30, 2015 21:05:24 Harry P via Digitalmars-d-learn wrote: I'm trying to avoid the gc so I'm using std.container.array arrays instead of the standard ones. I know the standard arrays return by reference so I imagine that the nogc alternative is also passed by reference because

Re: !in operator

2015-08-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 02, 2015 21:51:48 Ali Çehreli via Digitalmars-d-learn wrote: Is my understanding below correct? Does any documentation need updating? Operator precedence table lists !in as an operator: http://wiki.dlang.org/Operator_precedence Operator overloading documentation does

Re: Measuring Execution time

2015-07-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 23, 2015 13:59:11 Steven Schveighoffer via Digitalmars-d-learn wrote: On 7/22/15 5:23 AM, Clayton wrote: How does one represent Duration in only Micro-seconds, or milliseconds. Trying to measure the execution time of an algorithm and I get 4 ms, 619 μs, and 8 hnsecs , I

Re: How do you make a copy TO and object when you're INSIDE of it?

2015-07-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 24, 2015 01:30:55 Enjoys Math via Digitalmars-d-learn wrote: Here's my code: module grammar; class Grammar(T : ulong) { this(const T[] str) { auto grammar = str in grammarCache; if (grammar) { this = grammar.dup; } else {

Re: static linking

2015-07-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 26, 2015 19:17:59 Martin Nowak via Digitalmars-d-learn wrote: On 07/26/2015 05:19 PM, Laeeth Isharc wrote: The former is trickier on arch in particular (not related to Dicebot's choice) because they don't distributed static versions of library files as a matter of policy.

Re: Passing struct and struct[] into a template

2015-07-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 22, 2015 04:29:23 Taylor Gronka via Digitalmars-d-learn wrote: I have a template function, and I want it to do something if the input variable is a list of structs, and something else if the input is a struct. If you want a template to be different for different types, then

Re: Code Coverage Analysis, how do I skip (ignore) a line?

2015-07-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 22, 2015 02:19:52 antropod via Digitalmars-d-learn wrote: I want my coverage analysis to be 100%, how do I skip lines like assert(0); from being counted? AFAIK, there is no way to so, and I've mentioned that problem to Walter before, so I would have expected him to mention

Re: How does __traits and std.traits differ?

2015-07-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 24, 2015 07:16:41 WhatMeWorry via Digitalmars-d-learn wrote: Looking at the online documentation, it says: __traits are extensions to the language to enable programs, at compile time, to get at information internal to the compiler. std.traits are Templates which extract

Re: Converting uint[] slice to string for the purpose of hashing?

2015-07-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 23, 2015 12:56:13 Temtaime via Digitalmars-d-learn wrote: All types are hashable and for your own structs and classes you can redefine opHash It's toHash, actually, but yeah. - Jonathan M Davis

Re: Getting this to work similar to self in Python

2015-07-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 22, 2015 23:19:35 nurfz via Digitalmars-d-learn wrote: Hmm, is there a specific reason aside from the encapsulation violation? It seems needlessly complicated. If you have someone/something that has direct access to your source code, isn't a getter/setter the least of your

Re: Getting this to work similar to self in Python

2015-07-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 22, 2015 22:22:00 nurfz via Digitalmars-d-learn wrote: How could I get this D code to work similar to this Python code? So, here is the D code: import std.stdio; class Vehicle { int speed; void printSpeed() {

Re: How to get *32mscoff libraries for phobos?

2015-07-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 22, 2015 20:27:35 Taylor Hillegeist via Digitalmars-d-learn wrote: I have tried to build this and failed miserably. I have some questions? What make do you use? digital mars, gnu. what tools do you need? is it possible? I also failed to build zlib32coff.lib make[2]: ***

Re: question about the semantics of unshared variables

2015-07-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 16, 2015 06:53:50 aki via Digitalmars-d-learn wrote: I noticed just making many threads cause an error. Are there any limit for the number of threads? import std.concurrency; import core.thread; void fun() { Thread.sleep(5000.msecs); } void testThread() { foreach(i;

Re: Weird behavior of this in a subclass, I think?

2015-07-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 16, 2015 01:20:10 seashell86 via Digitalmars-d-learn wrote: On Thursday, 16 July 2015 at 00:39:29 UTC, H. S. Teoh wrote: On Thu, Jul 16, 2015 at 12:18:30AM +, seashell86 via Digitalmars-d-learn wrote: [...] The reason is that class variables cannot be overridden,

Re: question about the semantics of unshared variables

2015-07-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 15, 2015 16:21:29 aki via Digitalmars-d-learn wrote: I want to make sure about the semantics of unshared variables. import std.concurrency; import core.thread; ubyte[1024 * 1024] buf1MB; void fun() { Thread.sleep(5000.msecs); } void testThread() { foreach(i; 0..2000) {

Re: How to convert byte array to float

2015-07-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 17, 2015 18:43:26 DLangLearner via Digitalmars-d-learn wrote: Excuse me for my trivial question, but I'd like to know how to convert byte array to float? What I could think of are cast(float)(byte[]) and to!float(byte[]) but they do not work for me. Thanks! You could use

Re: What is the std.stream replacement?

2015-07-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 19, 2015 09:56:11 Charles Hixson via Digitalmars-d-learn wrote: I have DMD64 D Compiler v2.067.1 installed, and in the documentation of phobos what it says about std.stream is don't use it on new code. It doesn't, however, appear to offer any replacement. Certainly std.file,

Re: can't zip a char[5], string[5], real[5]

2015-10-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, October 21, 2015 14:11:20 anonymous via Digitalmars-d-learn wrote: > On Wednesday, 21 October 2015 at 14:06:54 UTC, Shriramana Sharma > wrote: > > import std.stdio, std.range; > > void mywrite(char [5] chars, real[5] vals) > > { > > static string [5] fmts = ["%9.4f, ", "%9.4f; ",

<    1   2   3   4   5   6   7   8   9   10   >