Re: Modules

2016-07-23 Thread rikki cattermole via Digitalmars-d-learn
On 24/07/2016 2:28 PM, Rufus Smith wrote: NM, ignore. Seems it was something else going on. Although, if you know how how dmd resolves this stuff exactly, it would be nice to know. Does it just use the module names regardless of path or does the path where the module is located have any

Re: Modules

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
NM, ignore. Seems it was something else going on. Although, if you know how how dmd resolves this stuff exactly, it would be nice to know. Does it just use the module names regardless of path or does the path where the module is located have any play(assuming they are properly passed to the

Modules

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
How do module names and actual folder paths relate? For my own libraries, I use the file path as module name, more or less. e.g., module foo.bar.x; is in folder foo\bar. I imported some external lib that has it's own layout, but I wanted to incorporate it in to my lib, so I stuck it in a

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
On Saturday, 23 July 2016 at 22:48:07 UTC, Lodovico Giaretta wrote: On Saturday, 23 July 2016 at 21:44:05 UTC, Rufus Smith wrote: On Saturday, 23 July 2016 at 17:27:24 UTC, Lodovico Giaretta wrote: - we trust what we are doing: e.g. we cannot mark a thing @nogc, but we know it is and the

Re: How to pause terminal in D on Linux?

2016-07-23 Thread Zekereth via Digitalmars-d-learn
On Saturday, 23 July 2016 at 19:08:00 UTC, WhatMeWorry wrote: What I thought would be trivial is becoming a nightmare. Can anybody set me straight. Thanks in advance. [...] Use the getchar() function. void pause(const string msg = "Press enter/return to continue...") { write(msg);

Re: Expression template

2016-07-23 Thread ketmar via Digitalmars-d-learn
On Saturday, 23 July 2016 at 23:36:40 UTC, Etranger wrote: is there any good benchmarking lib like the #[bench] in rust that I can use ?) dunno, i'm usually just using std.datetime.benchmark.

Re: Expression template

2016-07-23 Thread ag0aep6g via Digitalmars-d-learn
On 07/23/2016 01:05 PM, Etranger wrote: 1- Is there a cleaner way to do it ? I had to use struct because I want every thing to happen at compile time and on the stack (without gc). And I had to use string mixins because template mixin does not work the way I tried to use it ( see the error last

Expression template

2016-07-23 Thread Etranger via Digitalmars-d-learn
On Saturday, 23 July 2016 at 19:08:45 UTC, ketmar wrote: 2OP: sorry, i can barely read that code. this has nothing to do with your skills, it is the topic -- i've never seen clean lazy evaluation code. after all, this is a hack. still, i think that such a library worth at least some work. as

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Lodovico Giaretta via Digitalmars-d-learn
On Saturday, 23 July 2016 at 21:44:05 UTC, Rufus Smith wrote: On Saturday, 23 July 2016 at 17:27:24 UTC, Lodovico Giaretta wrote: - we trust what we are doing: e.g. we cannot mark a thing @nogc, but we know it is and the profiler confirms that no allocation happens, so we are happy; our

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Lodovico Giaretta via Digitalmars-d-learn
On Saturday, 23 July 2016 at 21:44:05 UTC, Rufus Smith wrote: Templates are not the end all be all. They don't allow for run-time polymorphism, which is an important aspect of software. Ok, so you need runtime polymorphism. And you want it in @nogc code. That's not difficult. Just have the

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, July 23, 2016 21:33:29 Rufus Smith via Digitalmars-d-learn wrote: > I am trying to write some general code that works on arbitrary > types. I need to compare, obviously, as that is relatively basic > thing on objects. That's part of of why attribute inferrence works on templates.

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
On Saturday, 23 July 2016 at 17:27:24 UTC, Lodovico Giaretta wrote: On Saturday, 23 July 2016 at 17:04:42 UTC, Jonathan Marler wrote: On Saturday, 23 July 2016 at 16:46:20 UTC, Jonathan Marler wrote: [...] Actually Im going to disagree with myself. This technique actually wouldn't work with

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, July 23, 2016 11:25:02 Steven Schveighoffer via Digitalmars-d- learn wrote: > The real problem here is that there is a base method at all. We have > been striving to remove it at some point, but it is very difficult due > to all the legacy code which is written. > > Almost all the

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
On Saturday, 23 July 2016 at 17:23:37 UTC, Marco Leise wrote: Am Sat, 23 Jul 2016 13:18:03 + schrieb Rufus Smith : Trying to compare a *ptr value with a value in nogc code results in the error: Error: @nogc function '...' cannot call non-@nogc function

Re: JSON Serialization with runtime filtering.

2016-07-23 Thread yawniek via Digitalmars-d-learn
On Friday, 22 July 2016 at 12:36:31 UTC, Alexander Milushev wrote: I there any json serialization library which allow to make decision about ignoring fields in runtime? I trying to write rest client but server accept either 'cmd' or 'args' field for example and I need to find solution. can

Re: Transform/Compile to C/CPP as a target

2016-07-23 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-07-23 14:27, ParticlePeter wrote: Is there any kind of project or workflow that converts D (subset) to C/CPP ? No idea about the status but: https://github.com/adamdruppe/tools/blob/dtoh/dtoh.d -- /Jacob Carlborg

Re: Expression template

2016-07-23 Thread ketmar via Digitalmars-d-learn
2OP: sorry, i can barely read that code. this has nothing to do with your skills, it is the topic -- i've never seen clean lazy evaluation code. after all, this is a hack. still, i think that such a library worth at least some work. as for "is my code/approach is good enough", i know only two

How to pause terminal in D on Linux?

2016-07-23 Thread WhatMeWorry via Digitalmars-d-learn
What I thought would be trivial is becoming a nightmare. Can anybody set me straight. Thanks in advance. void writeAndPause(string s) { writeln(s); // writeln("Press any key to continue..."); // works fine on Windows // executeShell("pause");// works fine on

Re: Expression template

2016-07-23 Thread ketmar via Digitalmars-d-learn
On Saturday, 23 July 2016 at 12:27:39 UTC, rikki cattermole wrote: Either way I recommend you not worry about it. Compilers can be smart and dmd is mostly good enough in this department. he has something to worry about. remember, this is scientific department, where ours 4x4 matrices are

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Lodovico Giaretta via Digitalmars-d-learn
On Saturday, 23 July 2016 at 17:04:42 UTC, Jonathan Marler wrote: On Saturday, 23 July 2016 at 16:46:20 UTC, Jonathan Marler wrote: [...] Actually Im going to disagree with myself. This technique actually wouldn't work with virtual methods:) I don't think we have the big problems with

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Marco Leise via Digitalmars-d-learn
Am Sat, 23 Jul 2016 13:18:03 + schrieb Rufus Smith : > Trying to compare a *ptr value with a value in nogc code results > in the error: > > Error: @nogc function '...' cannot call non-@nogc function > 'object.opEquals' > > Shouldn't object opEquals be

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Jonathan Marler via Digitalmars-d-learn
On Saturday, 23 July 2016 at 16:46:20 UTC, Jonathan Marler wrote: [...] Actually Im going to disagree with myself. This technique actually wouldn't work with virtual methods:)

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Jonathan Marler via Digitalmars-d-learn
On Saturday, 23 July 2016 at 15:25:02 UTC, Steven Schveighoffer wrote: On 7/23/16 10:53 AM, Rufus Smith wrote: On Saturday, 23 July 2016 at 14:15:03 UTC, Lodovico Giaretta wrote: On Saturday, 23 July 2016 at 13:18:03 UTC, Rufus Smith wrote: Trying to compare a *ptr value with a value in nogc

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/23/16 10:53 AM, Rufus Smith wrote: On Saturday, 23 July 2016 at 14:15:03 UTC, Lodovico Giaretta wrote: On Saturday, 23 July 2016 at 13:18:03 UTC, Rufus Smith wrote: Trying to compare a *ptr value with a value in nogc code results in the error: Error: @nogc function '...' cannot call

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Lodovico Giaretta via Digitalmars-d-learn
On Saturday, 23 July 2016 at 14:53:49 UTC, Rufus Smith wrote: Um, this isn't right. GC code can always call non-gc code. If you mark opEquals nogc, it breaks nothing except implementations of opEquals that use the GC. GC code can still call it nogc opequals, it only enforces opEquals code to

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
On Saturday, 23 July 2016 at 14:15:03 UTC, Lodovico Giaretta wrote: On Saturday, 23 July 2016 at 13:18:03 UTC, Rufus Smith wrote: Trying to compare a *ptr value with a value in nogc code results in the error: Error: @nogc function '...' cannot call non-@nogc function 'object.opEquals'

Re: Cannot compare object.opEquals is not nogc

2016-07-23 Thread Lodovico Giaretta via Digitalmars-d-learn
On Saturday, 23 July 2016 at 13:18:03 UTC, Rufus Smith wrote: Trying to compare a *ptr value with a value in nogc code results in the error: Error: @nogc function '...' cannot call non-@nogc function 'object.opEquals' Shouldn't object opEquals be marked? If object.opEquals is marked

Cannot compare object.opEquals is not nogc

2016-07-23 Thread Rufus Smith via Digitalmars-d-learn
Trying to compare a *ptr value with a value in nogc code results in the error: Error: @nogc function '...' cannot call non-@nogc function 'object.opEquals' Shouldn't object opEquals be marked?

Re: Expression template

2016-07-23 Thread Etranger via Digitalmars-d-learn
On Saturday, 23 July 2016 at 12:27:39 UTC, rikki cattermole wrote: If you evaluate it as v = a + b + c instead of v = a + (b + c) you will still have a temporary value. Remember structs are just the values they carry and are basically optimized out. Either way I recommend you not worry about

Re: Transform/Compile to C/CPP as a target

2016-07-23 Thread ParticlePeter via Digitalmars-d-learn
On Saturday, 23 July 2016 at 12:29:45 UTC, rikki cattermole wrote: On 24/07/2016 12:27 AM, ParticlePeter wrote: Is there any kind of project or workflow that converts D (subset) to C/CPP ? This probably will interest you for ldc:

Re: Transform/Compile to C/CPP as a target

2016-07-23 Thread rikki cattermole via Digitalmars-d-learn
On 24/07/2016 12:27 AM, ParticlePeter wrote: Is there any kind of project or workflow that converts D (subset) to C/CPP ? This probably will interest you for ldc: http://stackoverflow.com/questions/5180914/llvm-ir-back-to-human-readable-source-language

Re: Expression template

2016-07-23 Thread rikki cattermole via Digitalmars-d-learn
On 24/07/2016 12:09 AM, Etranger wrote: On Saturday, 23 July 2016 at 11:19:34 UTC, rikki cattermole wrote: On 23/07/2016 11:05 PM, Etranger wrote: [snip] * start of code ** import std.stdio; import std.traits; import std.conv; struct VecExpression(alias

Transform/Compile to C/CPP as a target

2016-07-23 Thread ParticlePeter via Digitalmars-d-learn
Is there any kind of project or workflow that converts D (subset) to C/CPP ?

Re: Expression template

2016-07-23 Thread Etranger via Digitalmars-d-learn
On Saturday, 23 July 2016 at 11:19:34 UTC, rikki cattermole wrote: On 23/07/2016 11:05 PM, Etranger wrote: [snip] * start of code ** import std.stdio; import std.traits; import std.conv; struct VecExpression(alias mixins) { mixin (mixins);

Re: Expression template

2016-07-23 Thread rikki cattermole via Digitalmars-d-learn
On 23/07/2016 11:05 PM, Etranger wrote: [snip] * start of code ** import std.stdio; import std.traits; import std.conv; struct VecExpression(alias mixins) { mixin (mixins); VecSum!(typeof(this), VecExpression!(RHS)) opBinary(string op, alias RHS)(ref

Expression template

2016-07-23 Thread Etranger via Digitalmars-d-learn
Hello all, I will greatly appreciate if you could help me with my first step in the D land. *YOU CAN SKIP DIRECTLY TO THE QUESTION BELLOW*: Please allow me to introduce myself and give you my feelings about the D language then I'll ask my question. I'm a mathematician that works mainly on

Re: full path to source file __FILE__

2016-07-23 Thread Martin Tschierschke via Digitalmars-d-learn
On Thursday, 21 July 2016 at 19:54:34 UTC, Jonathan Marler wrote: Is there a way to get the full path of the current source file? Something like: __FILE_FULL_PATH__ I'm asking because I'm rewriting a batch script in D, meant to be ran with rdmd. However, the script needs to know it's own