Re: D Beginner Trying Manual Memory Management

2015-01-14 Thread Laeeth Isharc via Digitalmars-d-learn
I don't think you've read h5py source in enough detail :) You're right - I haven't done more than browsed it. It's based HEAVILY on duck typing. There is a question here about what to do in D. On the one hand, the flexibility of being able to open a foreign HDF5 file where you don't know

Re: D Beginner Trying Manual Memory Management

2015-01-14 Thread aldanor via Digitalmars-d-learn
On Wednesday, 14 January 2015 at 16:27:17 UTC, Laeeth Isharc wrote: struct File { Location _location; alias _location this; ... } // group.d public import commonfg; struct File { Location _location; alias _location this; ... } // commonfg.d { ... } enum isContainer(T) = is(T: File) || is(T :

Re: D Beginner Trying Manual Memory Management

2015-01-14 Thread Laeeth Isharc via Digitalmars-d-learn
struct File { Location _location; alias _location this; ... } // group.d public import commonfg; struct File { Location _location; alias _location this; ... } // commonfg.d { ... } enum isContainer(T) = is(T: File) || is(T : Group); auto method1(T)(T obj, args) if (isContainer!T) { ... } auto

Re: D Beginner Trying Manual Memory Management

2015-01-14 Thread aldanor via Digitalmars-d-learn
On Wednesday, 14 January 2015 at 14:54:09 UTC, Laeeth Isharc wrote: In the hierarchy example above (c++ hdf hierarchy link), by using UFCS to implement the shared methods (which are achieved by multiple inheritance in the c++ counterpart) did you mean something like this? // id.d struct ID

Re: D Beginner Trying Manual Memory Management

2015-01-14 Thread Laeeth Isharc via Digitalmars-d-learn
In the hierarchy example above (c++ hdf hierarchy link), by using UFCS to implement the shared methods (which are achieved by multiple inheritance in the c++ counterpart) did you mean something like this? // id.d struct ID { int id; ... } // location.d struct Location { ID _id; alias _id t

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 18:35:15 + aldanor via Digitalmars-d-learn wrote: > I guess two of my gripes with UFCS is (a) you really have to use > public imports in the modules where the target types are defined > so you bring all the symbols in whether you want it or not (b) > you lose access to

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread aldanor via Digitalmars-d-learn
On Tuesday, 13 January 2015 at 17:08:38 UTC, Laeeth Isharc wrote: >> I see, thanks! :) I've started liking structs more and >> more recently as well and been pondering on how to convert >> a class-based code that looks like this (only the base >> class has any data): > it's hard to tell by brie

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 17:08:37 + Laeeth Isharc via Digitalmars-d-learn wrote: > I just finished reading aldanor's blog, so I know he is slightly > allergic to naked functions and prefers classes ;) that's due to absense of modules in C/C++. and namespaces aren't of big help here too. and, of c

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread Laeeth Isharc via Digitalmars-d-learn
>> I see, thanks! :) I've started liking structs more and more >> recently as well and been pondering on how to convert a >> class-based code that looks like this (only the base class >> has any data): > it's hard to tell by brief description. but having multiple > inheritance > immediately rin

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Tue, 13 Jan 2015 16:08:15 + aldanor via Digitalmars-d-learn wrote: > On Tuesday, 13 January 2015 at 08:33:57 UTC, ketmar via > Digitalmars-d-learn wrote: > > On Mon, 12 Jan 2015 22:07:13 + > > aldanor via Digitalmars-d-learn > > > > wrote: > > > >> I see, thanks! :) I've started lik

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread aldanor via Digitalmars-d-learn
On Tuesday, 13 January 2015 at 08:33:57 UTC, ketmar via Digitalmars-d-learn wrote: On Mon, 12 Jan 2015 22:07:13 + aldanor via Digitalmars-d-learn wrote: I see, thanks! :) I've started liking structs more and more recently as well and been pondering on how to convert a class-based code t

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Mon, 12 Jan 2015 22:07:13 + aldanor via Digitalmars-d-learn wrote: > I see, thanks! :) I've started liking structs more and more > recently as well and been pondering on how to convert a > class-based code that looks like this (only the base class has > any data): p.s. can't you convert

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Mon, 12 Jan 2015 22:07:13 + aldanor via Digitalmars-d-learn wrote: > I see, thanks! :) I've started liking structs more and more > recently as well and been pondering on how to convert a > class-based code that looks like this (only the base class has > any data): it's hard to tell by b

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread ketmar via Digitalmars-d-learn
On Mon, 12 Jan 2015 23:06:16 + jmh530 via Digitalmars-d-learn wrote: > I had seen some stuff on alias thing, but I hadn't bothered to > try to understand it until now. If I'm understanding the first > example http://dlang.org/class.html#AliasThis";>here, > alias this let's you refer to x in s

Re: D Beginner Trying Manual Memory Management

2015-01-12 Thread jmh530 via Digitalmars-d-learn
I had seen some stuff on alias thing, but I hadn't bothered to try to understand it until now. If I'm understanding the first example http://dlang.org/class.html#AliasThis";>here, alias this let's you refer to x in s by writing either s.x (as normally) or just s. That didn't seem that interesting,

Re: D Beginner Trying Manual Memory Management

2015-01-12 Thread Mike via Digitalmars-d-learn
On Monday, 12 January 2015 at 19:29:54 UTC, jmh530 wrote: I'm new to D. I have some modest knowledge of C++, but am more familiar with scripting languages (Matlab, Python, R). D seems so much easier than C++ in a lot of ways (and I just learned about rdmd today, which is pretty cool). I am conc

Re: D Beginner Trying Manual Memory Management

2015-01-12 Thread aldanor via Digitalmars-d-learn
On Monday, 12 January 2015 at 21:54:51 UTC, ketmar via Digitalmars-d-learn wrote: On Mon, 12 Jan 2015 21:37:27 + aldanor via Digitalmars-d-learn wrote: On Monday, 12 January 2015 at 20:30:45 UTC, ketmar via Digitalmars-d-learn wrote: > it even has `RefCounted!`, but it doesn't play well

Re: D Beginner Trying Manual Memory Management

2015-01-12 Thread ketmar via Digitalmars-d-learn
On Mon, 12 Jan 2015 21:37:27 + aldanor via Digitalmars-d-learn wrote: > On Monday, 12 January 2015 at 20:30:45 UTC, ketmar via > Digitalmars-d-learn wrote: > > it even has `RefCounted!`, but it doesn't play well with > > classes yet > > (AFAIR). > I wonder if it's possible to somehow make a

Re: D Beginner Trying Manual Memory Management

2015-01-12 Thread aldanor via Digitalmars-d-learn
On Monday, 12 January 2015 at 20:30:45 UTC, ketmar via Digitalmars-d-learn wrote: it even has `RefCounted!`, but it doesn't play well with classes yet (AFAIR). I wonder if it's possible to somehow make a version of refcounted that would work with classes (even if limited/restricted in some cer

Re: D Beginner Trying Manual Memory Management

2015-01-12 Thread ketmar via Digitalmars-d-learn
On Mon, 12 Jan 2015 20:14:19 + jmh530 via Digitalmars-d-learn wrote: > Thanks for the reply, I wasn't familiar with scoped. I was aware > that structs are on the stack and classes are on the heap in D, > but I didn't know it was possible to put a class on the stack. > Might be interesting

Re: D Beginner Trying Manual Memory Management

2015-01-12 Thread jmh530 via Digitalmars-d-learn
Thanks for the reply, I wasn't familiar with scoped. I was aware that structs are on the stack and classes are on the heap in D, but I didn't know it was possible to put a class on the stack. Might be interesting to see how this is implemented. After looking up some more C++, I think what I wa

Re: D Beginner Trying Manual Memory Management

2015-01-12 Thread ketmar via Digitalmars-d-learn
On Mon, 12 Jan 2015 19:29:53 + jmh530 via Digitalmars-d-learn wrote: the proper answer is too long to write (it will be more an article that a forum answer ;-), so i'll just give you some directions: import std.typecons; { auto b = scoped!B(); // `auto` is important here! ...

D Beginner Trying Manual Memory Management

2015-01-12 Thread jmh530 via Digitalmars-d-learn
I'm new to D. I have some modest knowledge of C++, but am more familiar with scripting languages (Matlab, Python, R). D seems so much easier than C++ in a lot of ways (and I just learned about rdmd today, which is pretty cool). I am concerned about performance of D vs. C++, so I wanted to learn