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

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

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 example,

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

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

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

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

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.

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

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'

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,

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 in

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.

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 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:

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

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 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: 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

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: 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 =

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

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

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: 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: 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 = 366

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

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

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 = 366

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

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

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

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?

Real OOP with D

2015-08-17 Thread Ozan via Digitalmars-d-learn
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 { void greeting() { writeln(I'm dad); } } class Boy :

Re: Real OOP with D

2015-08-17 Thread Ali Çehreli via Digitalmars-d-learn
On 08/16/2015 10:57 PM, Ozan wrote: 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 { } From the way you use it below, a better

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

Re: Real OOP with D

2015-08-17 Thread Rikki Cattermole via Digitalmars-d-learn
On 17/08/2015 5:57 p.m., 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 { void greeting() {