Re: Real OOP with D

2015-08-17 Thread Ozan via Digitalmars-d-learn
On Monday, 17 August 2015 at 06:59:51 UTC, BBasile wrote: On Monday, 17 August 2015 at 05:57:52 UTC, Ozan wrote: Hi [...] Is there any way to get real OOP with D? Regards, Ozan Can you name an OOP oriented language that allows this ? Your example is eroneous OOP. The 2 other answers you

Re: Real OOP with D

2015-08-17 Thread Ozan via Digitalmars-d-learn
On Monday, 17 August 2015 at 06:10:38 UTC, Rikki Cattermole wrote: On 17/08/2015 5:57 p.m., Ozan wrote: Hi [...] import std.stdio; abstract class Family { void greeting(); } class Dad : Family { void greeting() { writeln("I'm dad"); } } class Boy : Family { void greeting() { writeln("I'm dad

Re: Real OOP with D

2015-08-17 Thread Ozan via Digitalmars-d-learn
On Monday, 17 August 2015 at 06:08:35 UTC, Ali Çehreli wrote: On 08/16/2015 10:57 PM, Ozan wrote: [...] From the way you use it below, a better name for that class would be FamilyMember but I get the point. Yes, you're right. [...] > father.greeting; > son.greeting; What you mean is t

Re: unusual bare metal target: Amazon Dash

2015-08-17 Thread Rikki Cattermole via Digitalmars-d-learn
On 18/08/2015 1:32 p.m., Laeeth Isharc wrote: I don't know whether D can run on one, but from a quick look perhaps feasible. Running D on something like this (perhaps it's underpowered, but looked to have similar spec to what people had been doing with related ARM cortex processors) would certai

unusual bare metal target: Amazon Dash

2015-08-17 Thread Laeeth Isharc via Digitalmars-d-learn
I don't know whether D can run on one, but from a quick look perhaps feasible. Running D on something like this (perhaps it's underpowered, but looked to have similar spec to what people had been doing with related ARM cortex processors) would certainly make the point very vivid that it can be

Re: Getting a TypeTuple of a Template's Arguments

2015-08-17 Thread Ali Çehreli via Digitalmars-d-learn
Aside: With 2.068, std.typetuple and TypeTuple are renamed as std.meta and AliasSeq, respectively. On 08/17/2015 02:23 PM, Meta wrote:> For functions, we have std.traits.ParameterTypeTuple. Is there any > equivalent functionality for templates? There is TemplateArgsOf for instances of templat

Re: Compiletime Vs Runtime bencmarks

2015-08-17 Thread John Colvin via Digitalmars-d-learn
On Monday, 17 August 2015 at 17:48:22 UTC, D_Learner wrote: On Monday, 17 August 2015 at 14:52:18 UTC, Edwin van Leeuwen wrote: [...] The surprisingly, the D-profiler gives plausible results:- Algorithm1 2921 int rtime_pre.bm_rmatch (runtime ) 2122 int ctime_pre.bm_cmatch

Getting a TypeTuple of a Template's Arguments

2015-08-17 Thread Meta via Digitalmars-d-learn
For functions, we have std.traits.ParameterTypeTuple. Is there any equivalent functionality for templates?

Re: How to provide this arg or functor for algorithm?

2015-08-17 Thread anonymous via Digitalmars-d-learn
On Monday, 17 August 2015 at 16:21:16 UTC, thedeemon wrote: On Monday, 17 August 2015 at 16:18:50 UTC, thedeemon wrote: I've just checked with my runtime GC hook. Here the call to func() allocates 12 bytes via gc_malloc, and it's the same for a 4-elements array, so it's not for the array itself

Re: Compiletime Vs Runtime bencmarks

2015-08-17 Thread D_Learner via Digitalmars-d-learn
On Monday, 17 August 2015 at 14:52:18 UTC, Edwin van Leeuwen wrote: On Monday, 17 August 2015 at 14:43:35 UTC, D_Learner wrote: Hello everyone . I need advice on my first D-project . I have uploaded it at :- Current Results for the pattern="GCAGAGAG" are as below :- BM_Runtime = 36

Re: A couple questions about a simple project

2015-08-17 Thread Ali Çehreli via Digitalmars-d-learn
On 08/17/2015 10:08 AM, Andre Polykanine via Digitalmars-d-learn wrote: > string s; > try { > s = cast(string)std.file.read(f); > try { >

Re: A couple questions about a simple project

2015-08-17 Thread Andre Polykanine via Digitalmars-d-learn
Hello John, Yes, but this doesn't work, either. Now I have this (that was my first variant, btw): string s; try { s = cast(string)std.file.read(f); try {

Re: Weird error message.

2015-08-17 Thread Kagamin via Digitalmars-d-learn
On Monday, 17 August 2015 at 03:14:24 UTC, BBasile wrote: It's locked unless it's specified during the call to `CreateFile()` that the file can be shared for reading/writing (FILE_SHARE_READ / FILE_SHARE_WRITE). And the executable file being run must not be shared for writing, because it's ma

Re: Weird error message.

2015-08-17 Thread Kagamin via Digitalmars-d-learn
On Sunday, 16 August 2015 at 21:32:10 UTC, Warwick 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... Any ideas? rdmd creates an executable and runs it immediately. If you have an ant

Re: How to provide this arg or functor for algorithm?

2015-08-17 Thread thedeemon via Digitalmars-d-learn
On Monday, 17 August 2015 at 16:18:50 UTC, thedeemon wrote: I've just checked with my runtime GC hook. Here the call to func() allocates 12 bytes via gc_malloc, and it's the same for a 4-elements array, so it's not for the array itself, it's for a closure, I think. Also, compiling with -vgc s

Re: How to provide this arg or functor for algorithm?

2015-08-17 Thread thedeemon via Digitalmars-d-learn
On Monday, 17 August 2015 at 12:38:05 UTC, anonymous wrote: auto func()(uint[] arr, uint delegate(uint) pure @nogc d) @nogc { return arr.map!(d); } void main() @nogc { uint[3] arr = [1,2,3]; uint context = 2; auto c = Caller(context); auto d = &c.method; auto r = func(ar

Re: A couple questions about a simple project

2015-08-17 Thread FreeSlave via Digitalmars-d-learn
On Monday, 17 August 2015 at 15:05:56 UTC, Andre Polykanine wrote: Hi everyone, I'm new to D (I'm learning it by reading the great online book by Ali Çehreli - thank you very much for it, sir!), and, more than that, programming is my hobby, so please bear with me if I'm asking stupid

Re: Compiletime Vs Runtime bencmarks

2015-08-17 Thread D_Learner via Digitalmars-d-learn
On Monday, 17 August 2015 at 14:52:18 UTC, Edwin van Leeuwen wrote: On Monday, 17 August 2015 at 14:43:35 UTC, D_Learner wrote: Hello everyone . I need advice on my first D-project . I have uploaded it at :- Current Results for the pattern="GCAGAGAG" are as below :- BM_Runtime = 36

Re: A couple questions about a simple project

2015-08-17 Thread John Colvin via Digitalmars-d-learn
On Monday, 17 August 2015 at 15:05:56 UTC, Andre Polykanine wrote: Hi everyone, I'm new to D (I'm learning it by reading the great online book by Ali Çehreli - thank you very much for it, sir!), and, more than that, programming is my hobby, so please bear with me if I'm asking stupid

A couple questions about a simple project

2015-08-17 Thread Andre Polykanine via Digitalmars-d-learn
Hi everyone, I'm new to D (I'm learning it by reading the great online book by Ali Çehreli - thank you very much for it, sir!), and, more than that, programming is my hobby, so please bear with me if I'm asking stupid questions. I've made a toy project which is a small command-line X

Re: Compiletime Vs Runtime bencmarks

2015-08-17 Thread Edwin van Leeuwen via Digitalmars-d-learn
On Monday, 17 August 2015 at 14:43:35 UTC, D_Learner wrote: Hello everyone . I need advice on my first D-project . I have uploaded it at :- Current Results for the pattern="GCAGAGAG" are as below :- BM_Runtime = 366 hnsecs position= 513 BM_Compile-time = 294 hnsecs pos

Compiletime Vs Runtime bencmarks

2015-08-17 Thread D_Learner via Digitalmars-d-learn
Hello everyone . I need advice on my first D-project . I have uploaded it at :- https://bitbucket.org/mrjohns/matcher/downloads IDEA : Benchmarking of 3 runtime algorithms and comparing them to their compile-time variants. The only difference between these is that for the compile time-ones, t

Re: Pointers to Dynamic Arrays

2015-08-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 August 2015 at 13:27:19 UTC, Brandon Ragland wrote: If that is true, than passing it as _char[] file_ makes the most sense to me. A pointer copy doesn't hurt as bad as an array copy, of say, 100Kibibytes... Right. Knowing this helps to explain a lot btw: char[] foo; void func(

Re: std.net.curl

2015-08-17 Thread tired_eyes via Digitalmars-d-learn
On Monday, 17 August 2015 at 13:26:29 UTC, Adam D. Ruppe wrote: On Monday, 17 August 2015 at 13:04:31 UTC, tired_eyes wrote: Error: unrecognized switch '-lcurl' ooh I'm sorry, should have been `dmd -L-lcurl yourprogram.d` Yes, it did the trick.

Re: std.net.curl

2015-08-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 August 2015 at 13:04:31 UTC, tired_eyes wrote: Error: unrecognized switch '-lcurl' ooh I'm sorry, should have been `dmd -L-lcurl yourprogram.d`

Re: Pointers to Dynamic Arrays

2015-08-17 Thread Brandon Ragland via Digitalmars-d-learn
On Monday, 17 August 2015 at 03:07:26 UTC, Adam D. Ruppe wrote: On Monday, 17 August 2015 at 02:45:22 UTC, Brandon Ragland wrote: [...] Short answer: pointers to slices are usually a mistake, you probably don't actually want it, but rather should be using a regular slice instead. [...]

Re: std.net.curl

2015-08-17 Thread anonymous via Digitalmars-d-learn
On Monday, 17 August 2015 at 13:13:48 UTC, anonymous wrote: and figured out that the linker is invoked (on my machine) with gcc a.o -o a -m64 -lcurl -L/usr/lib/x86_64-linux-gnu -Xlinker correct (I named the example programm a.d instead of app.d): gcc app.o -o app -m64 -lcurl -L/usr/lib/x86_64

Re: std.net.curl

2015-08-17 Thread anonymous via Digitalmars-d-learn
On Monday, 17 August 2015 at 12:58:54 UTC, Adam D. Ruppe wrote: On Monday, 17 August 2015 at 12:52:37 UTC, tired_eyes wrote: Hovewer, "dmd app.d" spits a whole bunch of strange error messages: try "dmd -lcurl app.d" and see if that helps. DMD does not accept -lcurl. From dmd --help: -Llinke

Re: std.net.curl

2015-08-17 Thread yawniek via Digitalmars-d-learn
On Monday, 17 August 2015 at 13:04:31 UTC, tired_eyes wrote: On Monday, 17 August 2015 at 12:58:54 UTC, Adam D. Ruppe wrote: On Monday, 17 August 2015 at 12:52:37 UTC, tired_eyes wrote: Hovewer, "dmd app.d" spits a whole bunch of strange error messages: try "dmd -lcurl app.d" and see if that

Re: std.net.curl

2015-08-17 Thread tired_eyes via Digitalmars-d-learn
On Monday, 17 August 2015 at 12:58:54 UTC, Adam D. Ruppe wrote: On Monday, 17 August 2015 at 12:52:37 UTC, tired_eyes wrote: Hovewer, "dmd app.d" spits a whole bunch of strange error messages: try "dmd -lcurl app.d" and see if that helps. Error: unrecognized switch '-lcurl'

Re: std.net.curl

2015-08-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 17 August 2015 at 12:52:37 UTC, tired_eyes wrote: Hovewer, "dmd app.d" spits a whole bunch of strange error messages: try "dmd -lcurl app.d" and see if that helps.

std.net.curl

2015-08-17 Thread tired_eyes via Digitalmars-d-learn
Hi, I'm trying to compile this trivial example of std.net.curl: // app.d import std.stdio; import std.net.curl; void main() { auto content = get("dlang.org"); } Hovewer, "dmd app.d" spits a whole bunch of strange error messages: /usr/lib64/libphobos2.a(curl.o): In function `_D3std3net4c

Re: How to provide this arg or functor for algorithm?

2015-08-17 Thread anonymous via Digitalmars-d-learn
On Monday, 17 August 2015 at 10:28:33 UTC, thedeemon wrote: Nope, it "works" only because "r" is unreferenced and gets thrown out. Just try using r.front there, for example, and the error returns. You're right, it falls short. But I think r not being referenced is not exactly it. Using front

Re: Theoretical Best Practices

2015-08-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/14/15 6:25 PM, DarthCthulhu wrote: On Friday, 14 August 2015 at 12:40:08 UTC, Steven Schveighoffer wrote: I would do it this way: // at module level debug(logging) { Logger logger; static this() { logger = new Logger;} } By 'module level', I assume you mean in the module that d

Re: How to provide this arg or functor for algorithm?

2015-08-17 Thread thedeemon via Digitalmars-d-learn
On Monday, 17 August 2015 at 09:51:47 UTC, anonymous wrote: Huh. I think func being a template is the key here. When the original code is put in a template, it works too (with 2.068): Nope, it "works" only because "r" is unreferenced and gets thrown out. Just try using r.front there, for examp

Re: How to provide this arg or functor for algorithm?

2015-08-17 Thread anonymous via Digitalmars-d-learn
On Sunday, 16 August 2015 at 23:05:42 UTC, Ali Çehreli wrote: // Now the type of d is a template parameter @nogc auto func(Func)(uint[] arr, Func d) { return arr.map!(d); } Huh. I think func being a template is the key here. When the original code is put in a template, it works too (with 2

Re: Real OOP with D

2015-08-17 Thread BBasile via Digitalmars-d-learn
On Monday, 17 August 2015 at 05:57:52 UTC, Ozan wrote: Hi Working with objectoriented concepts results often in large trees of related classes. Every instance of a class knows his methods and data. An example like following would work: import std.stdio; class Family { } class Dad : Family {