Re: alias this cast

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 11 Sep 2014 11:40:05 + andre via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Hi, I am 80% sure, the failing assertion is correct but please have a look. No it is not assert(cast(A)cast(C)b); // this is OK b is B so it does not know about having alias to A;

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 11 September 2014 at 13:06:05 UTC, Colin wrote: I have this test code: struct Thing { uint x; } void main(){ uint[] ar1 = [1, 2, 3, 4, 5]; auto min1 = ar1.reduce!((a,b) = a b); writefln(%s, min1); // prints 1 as expected Thing[] ar2 = [Thing(1), Thing(2),

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 11 September 2014 at 14:18:31 UTC, Colin wrote: Ah ok. I get it. Thanks daniel! a quiet better version: import std.stdio; import std.algorithm; struct Thing { uint x; alias x this; } void main(){ uint[] ar1 = [1, 2, 3, 4, 5]; auto min1 = ar1

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 11 September 2014 at 14:39:53 UTC, Daniel Kozak wrote: On Thursday, 11 September 2014 at 14:18:31 UTC, Colin wrote: Ah ok. I get it. Thanks daniel! a quiet better version: import std.stdio; import std.algorithm; struct Thing { uint x; alias x this; } void

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 11 Sep 2014 14:49:02 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Daniel Kozak: You can just use min: import std.stdio, std.algorithm; struct Thing { uint x; alias x this; } alias minimum = reduce!min; void main

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 11 September 2014 at 14:56:00 UTC, Daniel Kozak via Digitalmars-d-learn wrote: V Thu, 11 Sep 2014 14:49:02 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Daniel Kozak: You can just use min: import std.stdio, std.algorithm; struct Thing

Re: std.algorithm.reduce on an array of structs

2014-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Thursday, 11 September 2014 at 15:07:03 UTC, Daniel Kozak wrote: or use alias minimum = reduce!a b; ;) ok this one does not work

Re: A significant performance difference

2014-09-01 Thread Daniel Kozak via Digitalmars-d-learn
V Sun, 31 Aug 2014 10:55:31 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: This is C++ code that solves one Euler problem: -- #include stdio.h #include map const unsigned int H = 9, W = 12; const int g[6][3] = {{7, 0, H - 3},

Re: A significant performance difference

2014-09-01 Thread Daniel Kozak via Digitalmars-d-learn
V Mon, 1 Sep 2014 12:38:52 +0300 ketmar via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: On Mon, 01 Sep 2014 09:22:50 + bearophile via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: In theory the best solution is to improve the performance of the

Re: DIP64 - Regarding 'pure' and 'nothrow'

2014-08-28 Thread Daniel Murphy via Digitalmars-d-learn
Brian Schott wrote in message news:pbfgiwaxsdxdxetpi...@forum.dlang.org... The delete keyword is deprecated[1] and making that decision never broke any code. [1] http://dlang.org/deprecate.html#delete If you look at the table up the top, delete hasn't actually been deprecated yet. If

Re: DIP64 - Regarding 'pure' and 'nothrow'

2014-08-28 Thread Daniel Murphy via Digitalmars-d-learn
Jonathan M Davis wrote in message news:xjmfhegvanqdivhbt...@forum.dlang.org... AFAIK, the only reason that it's not deprecated is that no one has bothered to make the change (and you didn't want to deprecate it when you went through all of those and updated their status a while back).

Re: static array in templated struct/class

2014-08-05 Thread Daniel Gibson via Digitalmars-d-learn
Am 05.08.2014 21:13, schrieb Marc Schütz schue...@gmx.net: On Tuesday, 5 August 2014 at 18:36:35 UTC, ddos wrote: alias Vec4f = TVector!(float,4); alias Vec3f = TVector!(float,3); class TVector(T,int n) { T[n] val; ... TVector as class does work as expected, as a struct i get the

Re: Pointer, if pointed type is unknown?

2014-08-02 Thread Daniel Gibson via Digitalmars-d-learn
variants or something): use an appropriate cast, i.e. double pi_2 = *(cast(double*)ptr); furthermore: why not use void* instead of size_t? Cheers, Daniel

Re: Member access of __gshared global object

2014-07-31 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 31 Jul 2014 02:03:35 + Puming via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: Hi, I'm writing this global Config class, with an AA member: ```d module my.config; class Config { Command[string] commands; } __gshared Config CONFIG; ``` and

Re: Split class declaration and definition

2014-07-31 Thread Daniel Kozak via Digitalmars-d-learn
V Thu, 31 Jul 2014 13:26:38 + Kagamin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: On Thursday, 31 July 2014 at 12:02:22 UTC, Kozzi11 wrote: module m; @someUda class C { void someFun(); } @someUda class D { void anotherFun(); }

Re: It is a bug?

2014-07-30 Thread Daniel Kozak via Digitalmars-d-learn
On Wednesday, 30 July 2014 at 16:14:56 UTC, Jesse Phillips wrote: On Wednesday, 30 July 2014 at 07:08:17 UTC, Kozzi11 wrote: #main.d: import m.f; class A { //class main.A member m is not accessible //mixin(t!(typeof(this), m)); void m() {}; //here is ok //mixin(t!(typeof(this),

Re: pointer array?

2014-07-30 Thread Daniel Kozak via Digitalmars-d-learn
V Wed, 30 Jul 2014 14:33:51 + seany via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: In Ali's excllent book, somehow one thing has escaped my attention, and that it the mentioning of pointer arrays. Can pointers of any type of pointed variable be inserted in an int

Re: D JSON (WAT?!)

2014-07-24 Thread Daniel Gibson via Digitalmars-d-learn
Am 24.07.2014 17:29, schrieb Pavel: On Thursday, 24 July 2014 at 15:22:46 UTC, Adam D. Ruppe wrote: On Thursday, 24 July 2014 at 15:15:37 UTC, Pavel wrote: string s = parsed[fail].str; Since there is no entry fail in the object, it returns a null JSON_VALUE pointer. Trying to get the string

Re: D JSON (WAT?!)

2014-07-24 Thread Daniel Gibson via Digitalmars-d-learn
is in a map. If it is, it returns a pointer to the value, otherwise null. Thus null. Cheers, Daniel

Re: How to copy an object to separate allocated memory?

2014-07-24 Thread Daniel Gibson via Digitalmars-d-learn
Am 24.07.2014 19:05, schrieb Gary Willoughby: I was reading Ali's book (http://ddili.org/ders/d.en/index.html) and saw this piece of code on how to get the true size of an object: MyClass* buffer = cast(MyClass*)GC.calloc(__traits(classInstanceSize, MyClass) * 10); That got me thinking, how

Re: Map one tuple to another Tuple of different type

2014-07-21 Thread Daniel Gibson via Digitalmars-d-learn
Am 21.07.2014 17:04, schrieb TheFlyingFiddle: On Monday, 21 July 2014 at 01:42:58 UTC, Daniel Gibson wrote: Am 21.07.2014 03:34, schrieb Vlad Levenfeld: To get a foreach to run at compile-time, you have to give it something whose value is known to the compiler (so, T and typeof(argTuple) would

Re: Map one tuple to another Tuple of different type

2014-07-21 Thread Daniel Gibson via Digitalmars-d-learn
Am 21.07.2014 20:09, schrieb H. S. Teoh via Digitalmars-d-learn: On Mon, Jul 21, 2014 at 06:36:04PM +0200, Daniel Gibson via Digitalmars-d-learn wrote: [...] However, having something like staticIota in the stdlib would probably make sense. [...] It's already in std.typecons. (Admittedly

Re: Building 32bit program with MSVC?

2014-05-31 Thread Daniel Murphy via Digitalmars-d-learn
Jonathan M Davis via Digitalmars-d-learn wrote in message news:mailman.1421.1401576730.2907.digitalmars-d-le...@puremagic.com... By dynamic linking do you mean LoadLibrary or linking with import library? Both will work, otherwise we couldn't use Microsoft's libraries - e.g.

Re: Any chance to avoid monitor field in my class?

2014-05-16 Thread Daniel Murphy via Digitalmars-d-learn
Yuriy wrote in message news:klosrzuxwmvilupzz...@forum.dlang.org... Ok, i can understand that, but what about this one: http://dpaste.dzfl.pl/6a9961e32e6d It doesn't use d arrays in function interfaces. Should it work? Similar problem, D arrays cannot be mangled correctly with C++ mangling.

Re: Any chance to avoid monitor field in my class?

2014-05-15 Thread Daniel Murphy via Digitalmars-d-learn
Yuriy wrote in message news:rfirqtgbparjbqxwt...@forum.dlang.org... On Wednesday, 14 May 2014 at 08:47:38 UTC, Daniel Murphy wrote: I'm not getting any errors with the development head. What os/compiler version? Hm, now that's strange. Building with latest public version seems to work

Re: Any chance to avoid monitor field in my class?

2014-05-14 Thread Daniel Murphy via Digitalmars-d-learn
On Tuesday, 13 May 2014 at 17:41:42 UTC, Yuriy wrote: On Tuesday, 13 May 2014 at 17:09:01 UTC, Daniel Murphy wrote: What exactly is the mangling problem with extern(C++) classes? Can't use D arrays (and strings) as function argument types. Can't use D array types as template arguments. extern

Re: Any chance to avoid monitor field in my class?

2014-05-13 Thread Daniel Murphy via Digitalmars-d-learn
Yuriy wrote in message news:uflaemdlxvavfmvkb...@forum.dlang.org... Hello, is there a way of reducing size of an empty class to just vtbl? I tried to declare it as extern(C++) which works, but has a nasty side effect of limited mangling. What exactly is the mangling problem with extern(C++)

Re: Implicit conversions through purity

2014-04-13 Thread Daniel Murphy
Jonathan M Davis wrote in message news:mailman.112.1397351369.5999.digitalmars-d-le...@puremagic.com... Honestly, I would have considered that to be a bug. Converting the return type to a different level of mutability based on purity is one thing. Automatically casting the return value just

Re: Implicit conversions through purity

2014-04-13 Thread Daniel Murphy
bearophile wrote in message news:hxdrbyqrhwvuochlh...@forum.dlang.org... Is it possible and a good idea to allow code like the function foo2? It seems reasonable.

DList bug or programmer error?

2014-04-12 Thread Daniel K
This block of code fails the second assert, why? Using stableRemove{Front,Back} does not fix it. import std.range; import std.container; unittest { auto dl2 = DList!int([2,7]); dl2.removeFront(); //dl2.stableRemoveFront(); assert(dl2[].walkLength == 1); dl2.removeBack();

Re: Anyone have sucess converting MSVC 2010 COFF libs to OMF

2014-04-09 Thread Daniel Murphy
Byron wrote in message news:li1ba2$5lc$1...@digitalmars.com... So does anyone have a fool prof way of converting coff to omf libs. I feel like this use to be easy.. In general, this won't work. The only thing that is straightforward and reliable is converting coff import libraries to omf

Re: How can I specify a location to write the code coverage files generated with '-cov'?

2014-04-04 Thread Daniel Murphy
On Friday, 4 April 2014 at 04:10:51 UTC, Saurabh Das wrote: Hello, Say I compile a program with: dmd -unittest -debug -cov test.d Then, when I run ./test, a file 'test.lst' is generated in the current working directory. Is there a way in which I can instruct the file to be created in a

Re: Colons and brackets

2014-03-02 Thread Daniel Murphy
evilrat wrote in message news:mxhmgkljrzqhaymec...@forum.dlang.org... On Friday, 28 February 2014 at 04:19:47 UTC, Etienne Cimon wrote: How do you stop statements from belonging to the specific version of code without using brackets? add version(all): after code where specific version

Re: pure vs writeln debugging

2014-02-11 Thread Daniel Murphy
Jesse Phillips wrote in message news:vaatltklsmbmdnabo...@forum.dlang.org... Wish it would work with @safe and nothrow too, granted writeln should eventually be @safe/trusted anyway. I just travelled back in time and granted your wish! int x; int* p; void main() pure nothrow @safe {

Re: How to convert these constructs to D?

2013-12-02 Thread Daniel Kozak
On Monday, 2 December 2013 at 09:01:25 UTC, Gary Willoughby wrote: On Sunday, 1 December 2013 at 20:46:20 UTC, Kozzi wrote: I'm basically porting all the mysql-client headers which i thought would be pretty straight forward but it's taking a little more thought than i anticipated. Can I ask

Re: Deep copy or clone data structure (or object ?)

2013-12-02 Thread Daniel Davidson
On Monday, 2 December 2013 at 13:42:48 UTC, Dfr wrote: Hi I searched through various D documentation sources and did not found anything except 'std.copy', but it's only for slices. Is there such feature in standart library ? Or some easy way to clone for example map of slices of maps or an

Re: pure-ifying my code

2013-11-18 Thread Daniel Davidson
On Sunday, 17 November 2013 at 10:56:16 UTC, Jonathan M Davis wrote: I think that the typical approach at this point is to just drop purity for the moment, but if you want you really want it, you are indeed going to have to implement it yourself. But we'll get there with Phobos eventually.

how use lowerBound with just sorting key, not complete values

2013-11-12 Thread Daniel Davidson
The following code works for finding the lower bound based on needle. But I have to create a needle which I don't want to do. How can I use lowerBound with just the sortKey, date in this case? So I want to do something like the following - but it won't work. Is there a way to search an array

Re: how use lowerBound with just sorting key, not complete values

2013-11-12 Thread Daniel Davidson
On Tuesday, 12 November 2013 at 15:51:53 UTC, bearophile wrote: Daniel Davidson: Is there a way to search an array I know is ordered by date by only supplying date? You can use a map to perform a projection: import std.stdio, std.range, std.datetime, std.algorithm, std.array

Re: how use lowerBound with just sorting key, not complete values

2013-11-12 Thread Daniel Davidson
On Tuesday, 12 November 2013 at 16:34:30 UTC, bearophile wrote: Daniel Davidson: Yes, but that is only giving the dates. I want the actual array elements. Suppose S is a large object with lots of extra fields in addition to `string foo`. There should be a way to pull out the lower bound

Re: is there a merge for associative arrays

2013-11-09 Thread Daniel Davidson
On Tuesday, 5 November 2013 at 17:47:16 UTC, bearophile wrote: TV[TK] mergeAAs(TK, TV)(TV[TK] aas...) { It seems even fit for Phobos. Bye, bearophile I have something I would appreciate feedback/criticism on. My first stab at it worked, but had no support for passing in const/immutable.

Re: fieldPostBlit - what is wrong with this and workarounds

2013-11-06 Thread Daniel Davidson
On Friday, 1 November 2013 at 20:29:54 UTC, Jonathan M Davis wrote: On Friday, November 01, 2013 14:28:55 Daniel Davidson wrote: On Thursday, 31 October 2013 at 19:39:44 UTC, Jonathan M Davis Deep copying is not the only reason to have a postblit. Smart pointers

Re: How to re-initialise an associative array.

2013-11-06 Thread Daniel Davidson
On Wednesday, 6 November 2013 at 16:15:36 UTC, Gary Willoughby wrote: A simple request but i'm failing hard. How do i re-init an associative array? This is obviously not the way: import std.stdio; void main(string[] args) { int[string] x;

Re: How to re-initialise an associative array.

2013-11-06 Thread Daniel Davidson
On Wednesday, 6 November 2013 at 16:41:19 UTC, Gary Willoughby wrote: x.clear(); I looked at that but apparently it leaves the array in an unsafe state. Source: http://forum.dlang.org/thread/iu3ll6$2d48$1...@digitalmars.com Wow! Good to know, thanks!

Re: How to re-initialise an associative array.

2013-11-06 Thread Daniel Davidson
On Wednesday, 6 November 2013 at 16:41:19 UTC, Gary Willoughby wrote: I looked at that but apparently it leaves the array in an unsafe state. Source: http://forum.dlang.org/thread/iu3ll6$2d48$1...@digitalmars.com Is that still the case? The following seems to work just fine. Maybe Kenji

Re: How to iterate through all modules for use with the new getUnitTests trait?

2013-11-06 Thread Daniel Davidson
On Wednesday, 6 November 2013 at 21:26:09 UTC, Dicebot wrote: On Wednesday, 6 November 2013 at 21:07:47 UTC, Gary Willoughby wrote: Unfortunately this still suffers the same problem in that you need a module symbol name to do anything. I need to get all module symbols at compile time. You

is there a merge for associative arrays

2013-11-05 Thread Daniel Davidson
The code below causes a crash. What is the idiomatic way to merge associative arrays? If there is a simple version that allows the value at a key to be clobbered by the value of the right hand operand when there is a collision, that is a start. import std.stdio; void main() { double[string]

Re: is this invalid code

2013-11-01 Thread Daniel Davidson
On Friday, 1 November 2013 at 04:26:25 UTC, Ali Çehreli wrote: You are not going to like my answer but this may be the 16-byte struct bug. Add something to RateCurve and your code works fine... :-/ struct RateCurve { private immutable(DateRate)[] _data; ubyte b; // -- ADDED } I

Re: fieldPostBlit - what is wrong with this and workarounds

2013-11-01 Thread Daniel Davidson
On Thursday, 31 October 2013 at 19:39:44 UTC, Jonathan M Davis wrote: const and postblit fundamentally don't mix, because for it to work, you have to violate the type system. With postblits, the struct gets memcpied and then the postblit constructor has the chance to mutate the resulting

Re: Linker error regarding importing and unit tests. Is this a bug?

2013-11-01 Thread Daniel Davidson
On Friday, 1 November 2013 at 12:59:24 UTC, Gary Willoughby wrote: I have a small test case that displays a linker error. I wondered if this is an issue with the tool chain or whether i'm doing something wrong. I have a simple directory structure like this: test/methods.d test/test1.d

fieldPostBlit - what is wrong with this and workarounds

2013-10-31 Thread Daniel Davidson
Given this code: import plus.tvm.rate_curve; struct T { RateCurve m; } struct S { const(T) rc; } I get this error: Error: mutable method plus.models.dossier.__unittestL42_1.T.__fieldPostBlit is not callable using a const object Is this fundamentally incorrect? I abandoned

structs holding on to reference data by pointer

2013-10-31 Thread Daniel Davidson
The following seems to work, but feels like luck. When foo returns rc should be taken off the stack. If I recall, in C++ something like this would crash, but why not here? import std.stdio; struct RC { this(this) { data = data.dup; } int[] data; } struct T { const(RC) *rc; void goo() {

Re: fieldPostBlit - what is wrong with this and workarounds

2013-10-31 Thread Daniel Davidson
On Thursday, 31 October 2013 at 14:28:31 UTC, bearophile wrote: Daniel Davidson: I get this error: Error: mutable method plus.models.dossier.__unittestL42_1.T.__fieldPostBlit is not callable using a const object Related: http://d.puremagic.com/issues/show_bug.cgi?id=4867 Bye, bearophile

Re: fieldPostBlit - what is wrong with this and workarounds

2013-10-31 Thread Daniel Davidson
On Thursday, 31 October 2013 at 15:56:45 UTC, Maxim Fomin wrote: On Thursday, 31 October 2013 at 14:03:28 UTC, Daniel Davidson wrote: Given this code: import plus.tvm.rate_curve; struct T { RateCurve m; } struct S { const(T) rc; } I get this error: Error: mutable method

Re: structs holding on to reference data by pointer

2013-10-31 Thread Daniel Davidson
On Thursday, 31 October 2013 at 16:16:36 UTC, bearophile wrote: That's wrong code, you are escaping a reference to memory (of rc variable) allocated in the stack frame of foo(). The D compiler is not smart enough to recognize the bug. There are optimizations that patch and avoid this bug

is this invalid code

2013-10-31 Thread Daniel Davidson
The following crashes on writeln, but looks reasonable. Is some form of initializing ctor required for RateCurve? import std.datetime; import std.range; import std.stdio; struct DateRate { Date date; double value = 0.0; } struct RateCurve { private immutable(DateRate)[] _data; } struct

Re: Dynamic associative array, to hold many values per key

2013-10-29 Thread Daniel Davidson
On Tuesday, 29 October 2013 at 18:02:46 UTC, Logesh Pillay wrote: On Sunday, 20 October 2013 at 16:08:50 UTC, bearophile wrote: Logesh Pillay: Thanks. Coming to D from python, I have to say D's tuples look difficult. I'm going to see how far I can get with structs writing my sudoku solver.

Re: conv text and pure

2013-10-28 Thread Daniel Davidson
On Thursday, 24 October 2013 at 00:02:30 UTC, bearophile wrote: Jonathan M Davis: Progress is being made on that however (as evidenced by the fact that format can now be pure in the beta for 2.064). Now two of the most common offenders of pure/nothrow in my high level code are iota() and

Re: selectively running unittest functions

2013-10-26 Thread Daniel Davidson
On Saturday, 26 October 2013 at 08:09:26 UTC, Dmitry Olshansky wrote: 26-Oct-2013 02:36, Daniel Davidson пишет: On Friday, 25 October 2013 at 16:43:23 UTC, Daniel Davidson wrote: On Friday, 25 October 2013 at 14:14:39 UTC, Dicebot wrote: This will work starting with 2.064: Ok. I'll keep

Re: selectively running unittest functions

2013-10-26 Thread Daniel Davidson
Here is a working solution: https://github.com/patefacio/d-help/blob/master/d-help/opmix/ut.d Currently it only pulls in unittests at the module level. I'm sure it will work on unittests scoped to structs/classes, I just need to figure out how to determine if a compile time named object is

Re: selectively running unittest functions

2013-10-25 Thread Daniel Davidson
On Friday, 25 October 2013 at 13:04:03 UTC, Dicebot wrote: I strictly believe any unittest enhancing library must be built on top of existing unittest blocks using __traits(getUnittest) and be 100% compatible with normal `-unittest` mode I don't disagree. What exactly does that mean and what

Re: selectively running unittest functions

2013-10-25 Thread Daniel Davidson
On Friday, 25 October 2013 at 14:14:39 UTC, Dicebot wrote: This will work starting with 2.064: Ok. I'll keep pressing. Here is an updated version: http://pastebin.com/g6FWsTkr The idea is to be able to just import ut, annotate as you have described and get unit tests run. I want to mixin

Re: selectively running unittest functions

2013-10-25 Thread Daniel Davidson
On Friday, 25 October 2013 at 16:43:23 UTC, Daniel Davidson wrote: On Friday, 25 October 2013 at 14:14:39 UTC, Dicebot wrote: This will work starting with 2.064: Ok. I'll keep pressing. Here is an updated version: http://pastebin.com/g6FWsTkr The idea is to be able to just import ut

proper way to find if attribute present?

2013-10-24 Thread Daniel Davidson
enum Bar = Bar; @(Foo) @Bar int x; pragma(msg, __traits(getAttributes, x)); This prints: tuple(Foo, Bar) How do you run code only if Bar is associated with a symbol like x? I was hoping something like this: pragma(msg, hasAnnotation!(x, Bar)); Where getAnnotation from

Re: this() immutable

2013-10-23 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 21:11:19 UTC, H. S. Teoh wrote: On Wed, Oct 16, 2013 at 10:09:50PM +0200, Daniel Davidson wrote: [...] I reported my issue with the `chain` function to this NG and tried to start annotating items used by chain with pure to see how far the thread led. Honestly

conv text and pure

2013-10-23 Thread Daniel Davidson
Should text be pure? I have multiple enforce statements of the form: enforce(0 == _history.length || !binaryFun!(orderingPred)(additional, _history[$-1]), text(V.stringof, must be added in chronological order, but , additional, comes

Re: conv text and pure

2013-10-23 Thread Daniel Davidson
On Wednesday, 23 October 2013 at 19:56:26 UTC, Andrej Mitrovic wrote: On Wednesday, 23 October 2013 at 19:55:26 UTC, Daniel Davidson wrote: Should text be pure? It's pure in 2.064, the upcoming release. Great, thanks. What is the best way to get on that version for the Mac (pointer

Re: conv text and pure

2013-10-23 Thread Daniel Davidson
On Wednesday, 23 October 2013 at 20:18:39 UTC, Andrej Mitrovic wrote: On 10/23/13, Daniel Davidson nos...@spam.com wrote: Great, thanks. What is the best way to get on that version for the Mac (pointer to instructions)? You can download the beta here: http://forum.dlang.org/thread

Re: conv text and pure

2013-10-23 Thread Daniel Davidson
On Wednesday, 23 October 2013 at 21:37:25 UTC, H. S. Teoh wrote: On Wed, Oct 23, 2013 at 11:17:30PM +0200, Daniel Davidson wrote: On Wednesday, 23 October 2013 at 20:18:39 UTC, Andrej Mitrovic wrote: On 10/23/13, Daniel Davidson nos...@spam.com wrote: Great, thanks. What is the best way to get

Re: matrix business in D

2013-10-18 Thread Daniel Davidson
On Thursday, 17 October 2013 at 20:31:38 UTC, Yura wrote: Dear D programmers, I am very new to D programming language. I just started to learn it as an alternative to python since the latter sometimes is too slow. My question is whether there some simple ways to solve linear algebra problems

how would D be different if string were const(char)[]?

2013-10-17 Thread Daniel Davidson
If it would be no different then why prefer immutable(char)[] for string?

Re: mutable, const, immutable guidelines

2013-10-17 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 20:33:23 UTC, H. S. Teoh wrote: On Wed, Oct 16, 2013 at 09:45:09PM +0200, Daniel Davidson wrote: On Wednesday, 16 October 2013 at 19:12:48 UTC, Dicebot wrote: [...] I think any usage of immutable with types/entities not initially designed for immutability

Re: how would D be different if string were const(char)[]?

2013-10-17 Thread Daniel Davidson
On Thursday, 17 October 2013 at 18:28:31 UTC, Meta wrote: On Thursday, 17 October 2013 at 13:08:18 UTC, Daniel Davidson wrote: If it would be no different then why prefer immutable(char)[] for string? Strings are immutable in quite a few other languages. Ex: Java, Python. I found this old

surprised by link error

2013-10-16 Thread Daniel Davidson
The following code runs fine. There is a whole bunch of types imported, so whittling it down to the problem is not too easy. import plus.models.assumption; import pprint.pp; import std.stdio; import std.datetime; void main() { immutable am = AssumptionModel(); writeln(pp(am)); } That code

Re: Interfacing via Java Native Interface

2013-10-16 Thread Daniel Kozak
On Wednesday, 16 October 2013 at 10:11:32 UTC, Andrew wrote: Hello there! I've decided to learn a bit of D, as I am currently Android Developer (mostly C++ - JNI - Java), I'm trying to create a D shared library which exports function (with extern (C)) for invocation from Java. My .d file

Re: this() immutable

2013-10-16 Thread Daniel Davidson
On Thursday, 13 June 2013 at 12:29:57 UTC, Simen Kjaeraas wrote: On Thu, 13 Jun 2013 14:17:22 +0200, Stephan Schiffels stephan_schiff...@mac.com wrote: For example, is there a way of instantiating an object normally (i.e. mutable), and then later freeze it to immutable via a simple cast or

does cast make an lvalue appear to be an rvalue

2013-10-16 Thread Daniel Davidson
The code below fails to compile due to the last line. I was hoping casting away immutable would allow the call to foo. I think it is not accepted because of the rval to ref issue. If that is the case, how can foo be called by casting? I'm not a fan of casting but I'm finding cases where it is

Re: mutable, const, immutable guidelines

2013-10-16 Thread Daniel Davidson
On Wednesday, 2 October 2013 at 13:09:34 UTC, Daniel Davidson wrote: I'm reviewing Ali's insightful presentation from 2013 DConf. I wonder has he or anyone else followed up on the concepts or formalized some guidelines that could achieve consensus. I definitely agree it would be helpful

Re: does cast make an lvalue appear to be an rvalue

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 17:16:39 UTC, Dicebot wrote: It works as it should. Make a mutable copy of t2 and pass it. Or make foo() accept const. I can't imagine a single legitimate use case for destroying type system in a way you want. How do you propose to make a mutable copy

Re: does cast make an lvalue appear to be an rvalue

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 17:58:41 UTC, Dicebot wrote: On Wednesday, 16 October 2013 at 17:50:48 UTC, Daniel Davidson wrote: On Wednesday, 16 October 2013 at 17:16:39 UTC, Dicebot wrote: It works as it should. Make a mutable copy of t2 and pass it. Or make foo() accept const. I can't

Re: does cast make an lvalue appear to be an rvalue

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 17:55:56 UTC, Dicebot wrote: struct S { R r; this(ref immutable(T) t) immutable { r.tupleof = t.tupleof; } } ? Thanks. It is cute - but not so helpful. The example stands. I *need* to call a createRFromT. Their shapes are the same in this simple

Re: does cast make an lvalue appear to be an rvalue

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 18:09:55 UTC, Maxim Fomin wrote: On Wednesday, 16 October 2013 at 17:05:25 UTC, Daniel Davidson wrote: The code below fails to compile due to the last line. I was hoping casting away immutable would allow the call to foo. I think it is not accepted because

Re: mutable, const, immutable guidelines

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 17:55:14 UTC, H. S. Teoh wrote: On Wed, Oct 16, 2013 at 07:23:24PM +0200, Daniel Davidson wrote: On Wednesday, 2 October 2013 at 13:09:34 UTC, Daniel Davidson wrote: [...] Maybe it is a philosophical question, but where does immutability really come from

Re: mutable, const, immutable guidelines

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 18:52:23 UTC, qznc wrote: On Wednesday, 16 October 2013 at 17:55:14 UTC, H. S. Teoh wrote: Maybe it's helpful to understand how D's const system works. The following diagram may help (please excuse the ASCII graphics): const /

Re: mutable, const, immutable guidelines

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 19:01:59 UTC, H. S. Teoh wrote: On Wed, Oct 16, 2013 at 08:49:51PM +0200, Daniel Davidson wrote: On Wednesday, 16 October 2013 at 17:55:14 UTC, H. S. Teoh wrote: On Wed, Oct 16, 2013 at 07:23:24PM +0200, Daniel Davidson wrote: [...] If you have a type that has

Re: mutable, const, immutable guidelines

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 19:12:48 UTC, Dicebot wrote: On Wednesday, 16 October 2013 at 19:06:06 UTC, Daniel Davidson wrote: I don't understand how it could be fine. As code grows it would lead to people not adding useful members like history just because of the huge repercussions

Re: this() immutable

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 19:55:41 UTC, Simen Kjaeraas wrote: On 2013-10-16, 18:54, Daniel Davidson wrote: On Thursday, 13 June 2013 at 12:29:57 UTC, Simen Kjaeraas wrote: On Thu, 13 Jun 2013 14:17:22 +0200, Stephan Schiffels stephan_schiff...@mac.com wrote: For example

Re: does cast make an lvalue appear to be an rvalue

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 19:49:25 UTC, monarch_dodra wrote: On Wednesday, 16 October 2013 at 17:50:48 UTC, Daniel Davidson wrote: How do you propose to make a mutable copy *generically*? You can't. Let alone generically. If I give you an immutable int* p, how do you copy it to int

Re: does cast make an lvalue appear to be an rvalue

2013-10-16 Thread Daniel Davidson
On Wednesday, 16 October 2013 at 19:49:25 UTC, monarch_dodra wrote: On Wednesday, 16 October 2013 at 17:50:48 UTC, Daniel Davidson wrote: How do you propose to make a mutable copy *generically*? You can't. Let alone generically. If I give you an immutable int* p, how do you copy it to int

Re: objects as AA keys

2013-10-15 Thread Daniel Davidson
On Tuesday, 15 October 2013 at 05:44:25 UTC, captaindet wrote: hi, i am a bit confused. the official language ref ( http://dlang.org/hash-map.html ) states: Classes can be used as the KeyType. For this to work, the class definition must override the following member functions of class

should chain be pure

2013-10-15 Thread Daniel Davidson
I would like to correctly annotate my functions with pure. I've hit a function that is calling chain which breaks purity. Is chain really not pure? The relevant section of code is: ... auto sortedRage = assumeSorted!(a.when b.when)(opSlice()); auto trisection =

Re: should chain be pure

2013-10-15 Thread Daniel Davidson
On Tuesday, 15 October 2013 at 13:43:55 UTC, bearophile wrote: Daniel Davidson: I would like to correctly annotate my functions with pure. I've hit a function that is calling chain which breaks purity. Is chain really not pure? Phobos is slowly being annotated with pure/nothrow (and @safe

Re: Is there a graphing library for D?

2013-10-14 Thread Agnew Daniel
I know I am too late, as you know best thing always delay. So visit KoolChart to find best chart library.

Re: mutable, const, immutable guidelines

2013-10-10 Thread Daniel Davidson
On Wednesday, 9 October 2013 at 23:05:27 UTC, qznc wrote: On Wednesday, 9 October 2013 at 15:50:55 UTC, Daniel Davidson wrote: void foo(const(MutableType) mt); void foo(immutable(MutableType) mt); Naturally the inclination is to choose the second as it is a stronger guarantee that no threads

Re: mutable, const, immutable guidelines

2013-10-10 Thread Daniel Davidson
On Thursday, 10 October 2013 at 23:06:23 UTC, qznc wrote: Maybe the fact that D allows this implicit copy to immutable is the problem? If one could require the use of a specific function, this function could be overridden with working behavior. The following code works. Yes - the issue

Re: mutable, const, immutable guidelines

2013-10-09 Thread Daniel Davidson
On Wednesday, 9 October 2013 at 04:31:55 UTC, Ali Çehreli wrote: On 10/08/2013 03:12 PM, qznc wrote: On Monday, 7 October 2013 at 17:57:11 UTC, Ali Çehreli wrote: To look at just one usage example, the following line carries two requirements: auto a = T(); immutable b = a; 1) b

Re: mutable, const, immutable guidelines

2013-10-09 Thread Daniel Davidson
On Wednesday, 9 October 2013 at 04:41:35 UTC, Ali Çehreli wrote: On 10/08/2013 03:03 PM, qznc wrote: On Wednesday, 2 October 2013 at 13:09:34 UTC, Daniel Davidson wrote: 1. If a variable is never mutated, make it const, not immutable. 2. Make the parameter reference to immutable

Re: Can someone explain why i can change this immutable variable please?

2013-10-09 Thread Daniel Davidson
On Wednesday, 9 October 2013 at 15:46:29 UTC, Gary Willoughby wrote: So why does this give me an error i expect: import std.stdio; class Foo { public void change(string[] name) { name[0] = tess;

Re: Can someone explain why i can change this immutable variable please?

2013-10-09 Thread Daniel Davidson
On Wednesday, 9 October 2013 at 15:33:23 UTC, Ali Çehreli wrote: That string is independent from the argument (i.e. Bar.name). They initially share the same characters. Either of those strings can leave this sharing at will, and that is exactly what name=tess does. 'name' now refers to

potential deadlock spawning process

2013-10-08 Thread Daniel Davidson
This simple script calls out to find (on a Mac). For me this works. If I increase the output by changing maxdepth to 3 it hangs forever. When I run the same find from the shell it is fine. What could cause a deadlock in this and what is a workaround? http://pastebin.com/ji8dZwAY Thanks Dan

<    2   3   4   5   6   7   8   9   10   >