Re: Article: Writing Julia style multiple dispatch code in D

2017-08-31 Thread Jean-Louis Leroy via Digitalmars-d-announce
On Thursday, 31 August 2017 at 06:58:53 UTC, Petar Kirov [ZombineDev] wrote: The workaround is to cast to Object before getting the typeid. The cause for this behavior is that if you have an interface reference to an object it points to the interface vtbl and not to the Object base class vtbl.

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-31 Thread via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 23:34:10 UTC, Jean-Louis Leroy wrote: On Wednesday, 30 August 2017 at 22:30:12 UTC, data pulverizer wrote: On Wednesday, 30 August 2017 at 22:10:38 UTC, Jean-Louis Leroy wrote: On Wednesday, 30 August 2017 at 21:30:29 UTC, data pulverizer wrote: In the light of

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-31 Thread Rainer Schuetze via Digitalmars-d-announce
On 31.08.2017 01:34, Jean-Louis Leroy wrote: On Wednesday, 30 August 2017 at 22:30:12 UTC, data pulverizer wrote: On Wednesday, 30 August 2017 at 22:10:38 UTC, Jean-Louis Leroy wrote: On Wednesday, 30 August 2017 at 21:30:29 UTC, data pulverizer wrote: In the light of this I think your

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread jmh530 via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 23:45:13 UTC, data pulverizer wrote: typeid() will give you the run-time type while typeof() gives the declared (compile time) type, typeid(typeof()) will not give you the run-time type - which in our case is what we want if we are using sub-typing

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread data pulverizer via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 22:49:54 UTC, jmh530 wrote: On Wednesday, 30 August 2017 at 22:30:12 UTC, data pulverizer wrote: On Wednesday, 30 August 2017 at 22:10:38 UTC, Jean-Louis Leroy wrote: On Wednesday, 30 August 2017 at 21:30:29 UTC, data pulverizer wrote: In the light of this I

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread Jean-Louis Leroy via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 22:30:12 UTC, data pulverizer wrote: On Wednesday, 30 August 2017 at 22:10:38 UTC, Jean-Louis Leroy wrote: On Wednesday, 30 August 2017 at 21:30:29 UTC, data pulverizer wrote: In the light of this I think your package just became more interesting to me. I

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread jmh530 via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 22:30:12 UTC, data pulverizer wrote: On Wednesday, 30 August 2017 at 22:10:38 UTC, Jean-Louis Leroy wrote: On Wednesday, 30 August 2017 at 21:30:29 UTC, data pulverizer wrote: In the light of this I think your package just became more interesting to me. I

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread data pulverizer via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 22:10:38 UTC, Jean-Louis Leroy wrote: On Wednesday, 30 August 2017 at 21:30:29 UTC, data pulverizer wrote: In the light of this I think your package just became more interesting to me. I think that your work and mine are complementary :-) Here is one strange

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread data pulverizer via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 22:10:38 UTC, Jean-Louis Leroy wrote: On Wednesday, 30 August 2017 at 21:30:29 UTC, data pulverizer wrote: In the light of this I think your package just became more interesting to me. I think that your work and mine are complementary :-) Yes, one of the

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread Jean-Louis Leroy via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 21:30:29 UTC, data pulverizer wrote: In the light of this I think your package just became more interesting to me. I think that your work and mine are complementary :-)

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread data pulverizer via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 21:30:29 UTC, data pulverizer wrote: On Wednesday, 30 August 2017 at 20:40:38 UTC, Jean-Louis Leroy wrote: After mulling over this example, I don't see how this proves that Julia does *not* support run time polymorphism. On the contrary. In that case you are

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread data pulverizer via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 20:40:38 UTC, Jean-Louis Leroy wrote: After mulling over this example, I don't see how this proves that Julia does *not* support run time polymorphism. On the contrary. If you translate this to D you get the same result by the way: import std.stdio; class

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread Jean-Louis Leroy via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 17:16:59 UTC, data pulverizer wrote: On Wednesday, 30 August 2017 at 17:14:37 UTC, data pulverizer wrote: On Wednesday, 30 August 2017 at 16:45:19 UTC, data pulverizer wrote: You mentioned Julia in your article, however for clarity I would point out that Julia

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread data pulverizer via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 18:48:58 UTC, data pulverizer wrote: I suspect the reason you can't have parametric typed array containers in statically typed compiled languages is that underneath, they are doubly/linked lists, and there is no way of resolving the types at the end of the

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread data pulverizer via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 17:57:49 UTC, data pulverizer wrote: The reason I have never really been comfortable with sub-typing is that the polymorphic types are a black-box, my preference is certainly for parametric type polymorphism. The main disadvantage with parametric polymorphism in

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread data pulverizer via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 17:29:42 UTC, Jean-Louis Leroy wrote: On Wednesday, 30 August 2017 at 17:16:59 UTC, data pulverizer wrote: p.p.s typeof(x[1]) # returns Cat so it isn't really polymorphism - the object is never converted to the "parent" type! Lol ... sorry for the confusion!

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread Jean-Louis Leroy via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 17:16:59 UTC, data pulverizer wrote: p.p.s typeof(x[1]) # returns Cat so it isn't really polymorphism - the object is never converted to the "parent" type! Lol ... sorry for the confusion! Which is polymorphism Haha what I know of Julia is what wikipedia

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread Jean-Louis Leroy via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 16:45:19 UTC, data pulverizer wrote: One thing that confused me was examples like this ... @method Matrix _plus(DiagonalMatrix a, DiagonalMatrix b) { // just add the elements on diagonals // return a DiagonalMatrix } Which is marked as returning a

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread data pulverizer via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 17:14:37 UTC, data pulverizer wrote: On Wednesday, 30 August 2017 at 16:45:19 UTC, data pulverizer wrote: You mentioned Julia in your article, however for clarity I would point out that Julia doesn't have OOP-type polymorphism. There is no notion of being able

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread data pulverizer via Digitalmars-d-announce
On Wednesday, 30 August 2017 at 16:45:19 UTC, data pulverizer wrote: You mentioned Julia in your article, however for clarity I would point out that Julia doesn't have OOP-type polymorphism. There is no notion of being able to do something like: Animal snoopy = new Dog(); p.s. my bad, I was

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-30 Thread data pulverizer via Digitalmars-d-announce
On Monday, 28 August 2017 at 13:19:19 UTC, Jean-Louis Leroy wrote: On Thursday, 24 August 2017 at 23:50:21 UTC, data pulverizer wrote: I find OOP-polymorphic types ultimately unsatisfying, but I don't know of anyway to write, compile and load a D script with new types and methods on the fly

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-28 Thread Jean-Louis Leroy via Digitalmars-d-announce
On Thursday, 24 August 2017 at 23:50:21 UTC, data pulverizer wrote: I find OOP-polymorphic types ultimately unsatisfying, but I don't know of anyway to write, compile and load a D script with new types and methods on the fly into the same session. That is why binding membership and

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-28 Thread Jean-Louis Leroy via Digitalmars-d-announce
On Thursday, 24 August 2017 at 23:50:21 UTC, data pulverizer wrote: I find OOP-polymorphic types ultimately unsatisfying, but I don't know of anyway to write, compile and load a D script with new types and methods on the fly into the same session. That is why binding membership and

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-26 Thread jmh530 via Digitalmars-d-announce
On Saturday, 26 August 2017 at 02:14:59 UTC, data pulverizer wrote: On Friday, 25 August 2017 at 20:54:05 UTC, jmh530 wrote: See below. I haven't implemented the random variables yet, but otherwise it seems to be working well. There is some trickiness with deprecated stuff that I had to hard

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-25 Thread data pulverizer via Digitalmars-d-announce
On Friday, 25 August 2017 at 20:54:05 UTC, jmh530 wrote: See below. I haven't implemented the random variables yet, but otherwise it seems to be working well. There is some trickiness with deprecated stuff that I had to hard code, but other than that it's pretty generic. Also, I think it is

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-25 Thread jmh530 via Digitalmars-d-announce
On Friday, 25 August 2017 at 16:01:27 UTC, data pulverizer wrote: Your wrapping strategy looks sensible though I would probably generate them all using string mixins. See below. I haven't implemented the random variables yet, but otherwise it seems to be working well. There is some

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-25 Thread jmh530 via Digitalmars-d-announce
On Friday, 25 August 2017 at 16:01:27 UTC, data pulverizer wrote: Your wrapping strategy looks sensible though I would probably generate them all using string mixins. That might require less maintenance going forward.

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-25 Thread data pulverizer via Digitalmars-d-announce
On Friday, 25 August 2017 at 14:30:03 UTC, jmh530 wrote: On Friday, 25 August 2017 at 01:04:31 UTC, data pulverizer wrote: [snip] With respect to your point about immutability, you might be interested in the parameterize function in dstats.distrib. I hadn't noticed that was there, but I

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-25 Thread jmh530 via Digitalmars-d-announce
On Friday, 25 August 2017 at 01:04:31 UTC, data pulverizer wrote: [snip] With respect to your point about immutability, you might be interested in the parameterize function in dstats.distrib. I hadn't noticed that was there, but I think it accomplishes, to a limited extent, the behavior of

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-24 Thread data pulverizer via Digitalmars-d-announce
On Friday, 25 August 2017 at 00:35:24 UTC, jmh530 wrote: What you seem concerned about here is how to produce a meaningful error message for distribution that you do not have implementations for. A slightly more elegant solution would be to pack the structs into an AliasSeq and then use

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-24 Thread jmh530 via Digitalmars-d-announce
On Thursday, 24 August 2017 at 23:50:21 UTC, data pulverizer wrote: ``` double density(D: UnivariateDistribution!Discrete, U = getVariateType!D, T = GetDistributionParameterType!D)(D d, U x) if(!is(D == Poisson!T)) { assert(false, "density function unimplemented for this distribution: "

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-24 Thread data pulverizer via Digitalmars-d-announce
On Thursday, 24 August 2017 at 21:13:10 UTC, jmh530 wrote: On UDAs, at least in the current implementation, I think that the actual issue you are trying to address is to force the type in the distribution to be convertible to double in the continuous case and convertible to long in the

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-24 Thread jmh530 via Digitalmars-d-announce
On Thursday, 24 August 2017 at 20:11:32 UTC, data pulverizer wrote: Thanks. I think most of that is down to D's nice syntax and how it easily and clearly emulates Julia. I think that there is certainly more to say on this especially around strategies of how represent concrete types. David

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-24 Thread data pulverizer via Digitalmars-d-announce
On Thursday, 24 August 2017 at 18:16:21 UTC, jmh530 wrote: I think at one point I had actually suggested that dstats or something be re-written in a Julia-like way (before I realized how much work that would be!). It looks very pretty. Thanks. I think most of that is down to D's nice syntax

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-24 Thread jmh530 via Digitalmars-d-announce
On Thursday, 24 August 2017 at 17:20:20 UTC, data pulverizer wrote: In any case, Jean-Louis Leroy did some magic recently to support multiple dynamic dispatch in D. :) http://forum.dlang.org/post/cigbfrgipbokyetsk...@forum.dlang.org I haven't seen this. I'll have to get back to you when I

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-24 Thread jmh530 via Digitalmars-d-announce
On Thursday, 24 August 2017 at 16:10:32 UTC, data pulverizer wrote: Hi all, I have written an article about writing Julia style multiple dispatch code in D (https://github.com/dataPulverizer/dispatch-it-like-julia). I am hoping that it is appropriate for the D blog. Reviews please. Many

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-24 Thread data pulverizer via Digitalmars-d-announce
On Thursday, 24 August 2017 at 17:01:38 UTC, Ali Çehreli wrote: This works only with compile-time dispatch, right? Yes ... Does Julia support dynamic multiple dispatch? Okay Julia is my second favourite language next to D and one of it's cool features is that even though it is a dynamic

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-24 Thread data pulverizer via Digitalmars-d-announce
On Thursday, 24 August 2017 at 16:41:54 UTC, David Gileadi wrote: Very interesting! Thank you I have a couple suggestions: for newbies like me, it would be nice to include a short explanation of multiple dispatch, and maybe a link to a longer description. Wikipedia's description of

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-24 Thread Ali Çehreli via Digitalmars-d-announce
On 08/24/2017 09:10 AM, data pulverizer wrote: Hi all, I have written an article about writing Julia style multiple dispatch code in D (https://github.com/dataPulverizer/dispatch-it-like-julia). I am hoping that it is appropriate for the D blog. Reviews please. Many Thanks! This works only

Re: Article: Writing Julia style multiple dispatch code in D

2017-08-24 Thread David Gileadi via Digitalmars-d-announce
On 8/24/17 9:10 AM, data pulverizer wrote: Hi all, I have written an article about writing Julia style multiple dispatch code in D (https://github.com/dataPulverizer/dispatch-it-like-julia). I am hoping that it is appropriate for the D blog. Reviews please. Many Thanks! Very interesting

Article: Writing Julia style multiple dispatch code in D

2017-08-24 Thread data pulverizer via Digitalmars-d-announce
Hi all, I have written an article about writing Julia style multiple dispatch code in D (https://github.com/dataPulverizer/dispatch-it-like-julia). I am hoping that it is appropriate for the D blog. Reviews please. Many Thanks!