Re: How to convert this function into a template ?

2018-10-02 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 17:37:58 UTC, Ali Çehreli wrote: On 10/02/2018 07:39 AM, Vinod K Chandran wrote: > Thanks a lot. Great help !. I will sure the check the link. :) I find the Index section useful (yes, can be improved). For example, just seach for "append" on this page:

Re: How to implement D to HTML pages ?

2018-10-02 Thread bauss via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 18:27:04 UTC, Aurélien Plazzotta wrote: On Tuesday, 2 October 2018 at 06:56:33 UTC, bauss wrote: On Monday, 1 October 2018 at 23:17:59 UTC, rjframe wrote: vibe.d has more of a node.js feel. There's also DiamondMVC[1], which reminds me of ASP.NET (I'm not 100%

Re: Dynamic Minimum width with Format / writefln

2018-10-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 01:14:24 UTC, Chris Katko wrote: I'm not sure how I made this mistake. But it seems to only show up now if I leave .toStringz() with the writefln. Yeah. So what's happening here is toStringz returns the C-style char*, which printf works well with, but writef

Re: Dynamic Minimum width with Format / writefln

2018-10-02 Thread Chris Katko via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 00:34:33 UTC, Adam D. Ruppe wrote: On Wednesday, 3 October 2018 at 00:14:03 UTC, Chris Katko wrote: Except it doesn't work and tries to decode col.width-1 into a hexadecimal number and only prints that. ("4D6EF6") That number certainly isn't col.width (unless

Re: Dynamic Minimum width with Format / writefln

2018-10-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 00:14:03 UTC, Chris Katko wrote: Except it doesn't work and tries to decode col.width-1 into a hexadecimal number and only prints that. ("4D6EF6") That number certainly isn't col.width (unless you have a width of like millions)... It looks more like a

Dynamic Minimum width with Format / writefln

2018-10-02 Thread Chris Katko via Digitalmars-d-learn
- First, I'm confused. The docs say 's' is "whatever it needs to be". ("he corresponding argument is formatted in a manner consistent with its type:") But what if I specifically want a STRING. Because I only see floats, ints, etc. No forced string types. - Second, This works fine in D:

Re: Dlang tour - Unittesting example

2018-10-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/2/18 8:30 AM, Joe wrote: On Tuesday, 2 October 2018 at 12:25:19 UTC, Joe wrote: On Tuesday, 2 October 2018 at 09:59:28 UTC, bauss wrote: On Tuesday, 2 October 2018 at 04:13:01 UTC, Joe wrote: There appears to be a problem with the example at

Re: GC page and block metadata storage

2018-10-02 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 09:43:02 UTC, thedeemon wrote: I guess you would want to scan the metadata without thrashing all the pages. Keeping metadata together compactly is good for cache. Can you briefly elaborate on what use case(s) you hade in mind when you wrote this?

Re: Linking with a non-default druntime

2018-10-02 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 16:20:52 UTC, Basile B. wrote: This works https://github.com/BBasile/druntime/pull/1. Not sure if it will be useful. Ahh, thanks! I've just found my own way of iterating via a script at https://github.com/nordlow/scripts/blob/master/dmd-own that

Re: Wrong module initialization order when building with Dub on Windows?

2018-10-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-10-02 08:49, bauss wrote: Honestly I would say that it should have worked regardless of the module order, because it's the runtime arguments. Basically D's runtime should set them before ANY module constructors are called and most definitely before the main function is called. They

Re: How to implement D to HTML pages ?

2018-10-02 Thread Aurélien Plazzotta via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 06:56:33 UTC, bauss wrote: On Monday, 1 October 2018 at 23:17:59 UTC, rjframe wrote: vibe.d has more of a node.js feel. There's also DiamondMVC[1], which reminds me of ASP.NET (I'm not 100% sure whether that's intentional, and I haven't tried Diamond) and

Re: How to convert this function into a template ?

2018-10-02 Thread Ali Çehreli via Digitalmars-d-learn
On 10/02/2018 07:39 AM, Vinod K Chandran wrote: > Thanks a lot. Great help !. I will sure the check the link. :) I find the Index section useful (yes, can be improved). For example, just seach for "append" on this page: http://ddili.org/ders/d.en/ix.html > The doumentation did not tell me

Re: Dlang tour - Unittesting example

2018-10-02 Thread Joe via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 13:24:09 UTC, Basile B. wrote: The problem is the NaN madness. Since several values are NaN there's this strange stuff: void main() { import std.stdio; import std.math : isNaN; double d; writeln(d.init);// nan writeln(d); // nan

Re: Linking with a non-default druntime

2018-10-02 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 13:07:04 UTC, Basile B. wrote: On Monday, 1 October 2018 at 11:10:07 UTC, Per Nordlöw wrote: On Monday, 1 October 2018 at 08:27:54 UTC, Basile B. wrote: I think so. Apparently it's registered with a string, e.g "manual" and you pass a special druntime option with

Re: How to convert this function into a template ?

2018-10-02 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 12:23:47 UTC, Jonathan M Davis wrote: The template equivalent would have been something like void arrayAdd(T)(ref T[] x, T value) { auto index = x.length; x.length += 1; x[index] = value; } But if you're new to the language, I'd suggest that you read

Re: Wrong module initialization order when building with Dub on Windows?

2018-10-02 Thread Kagamin via Digitalmars-d-learn
Missing command line arguments? Sounds like this: https://forum.dlang.org/post/eevaqbqufmhhducua...@forum.dlang.org

Re: Dlang tour - Unittesting example

2018-10-02 Thread ag0aep6g via Digitalmars-d-learn
On 10/02/2018 03:24 PM, Basile B. wrote: The problem is the NaN madness. Since several values are NaN there's this strange stuff: void main() {     import std.stdio;     import std.math : isNaN;     double d;     writeln(d.init);    // nan     writeln(d); // nan    

Re: Dlang tour - Unittesting example

2018-10-02 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 12:30:36 UTC, Joe wrote: On Tuesday, 2 October 2018 at 12:25:19 UTC, Joe wrote: On Tuesday, 2 October 2018 at 09:59:28 UTC, bauss wrote: On Tuesday, 2 October 2018 at 04:13:01 UTC, Joe wrote: There appears to be a problem with the example at

Re: Linking with a non-default druntime

2018-10-02 Thread Basile B. via Digitalmars-d-learn
On Monday, 1 October 2018 at 11:10:07 UTC, Per Nordlöw wrote: On Monday, 1 October 2018 at 08:27:54 UTC, Basile B. wrote: I think so. Apparently it's registered with a string, e.g "manual" and you pass a special druntime option with your program to select. Actually i would be interested to

Re: Dlang tour - Unittesting example

2018-10-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 2, 2018 3:59:28 AM MDT bauss via Digitalmars-d-learn wrote: > On Tuesday, 2 October 2018 at 04:13:01 UTC, Joe wrote: > > There appears to be a problem with the example at > > > > https://tour.dlang.org/tour/en/gems/unittesting > > > > If compiled with -unittest, the resulting

Re: Dlang tour - Unittesting example

2018-10-02 Thread Joe via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 12:25:19 UTC, Joe wrote: On Tuesday, 2 October 2018 at 09:59:28 UTC, bauss wrote: On Tuesday, 2 October 2018 at 04:13:01 UTC, Joe wrote: There appears to be a problem with the example at https://tour.dlang.org/tour/en/gems/unittesting If compiled with -unittest,

Re: Dlang tour - Unittesting example

2018-10-02 Thread Joe via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 09:59:28 UTC, bauss wrote: On Tuesday, 2 October 2018 at 04:13:01 UTC, Joe wrote: There appears to be a problem with the example at https://tour.dlang.org/tour/en/gems/unittesting If compiled with -unittest, the resulting program crashes. It happens with ldc2 on

Re: How to convert this function into a template ?

2018-10-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 2, 2018 6:09:53 AM MDT Vinod K Chandran via Digitalmars- d-learn wrote: > On Tuesday, 2 October 2018 at 11:49:06 UTC, Jonathan M Davis > > wrote: > > Why do you have a function for that? All you need to do is use > > the append operator. e.g. > > > > x ~= value; > > > > -

Re: How to convert this function into a template ?

2018-10-02 Thread Vinod K Chandran via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 11:49:06 UTC, Jonathan M Davis wrote: Why do you have a function for that? All you need to do is use the append operator. e.g. x ~= value; - Jonathan M Davis Thanks for the reply. I did not find that it in documentation. Ofcourse i lost a chance to learn

Re: How to convert this function into a template ?

2018-10-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 2, 2018 5:40:18 AM MDT Vinod K Chandran via Digitalmars- d-learn wrote: > Hi all, > I have a function and i want to convert this into a template so > that i can use this function for more than one data type. > This is my function. > ```D > void ArrayAdd( ref int[] x, int value)

How to convert this function into a template ?

2018-10-02 Thread Vinod K Chandran via Digitalmars-d-learn
Hi all, I have a function and i want to convert this into a template so that i can use this function for more than one data type. This is my function. ```D void ArrayAdd( ref int[] x, int value) { int index = x.length ; x.length += 1 ; x[index] = value ; } ```

Re: Does the WInMain function is mandatory ?

2018-10-02 Thread Vinod K Chandran via Digitalmars-d-learn
On Sunday, 30 September 2018 at 15:06:31 UTC, Mike Parker wrote: On Sunday, 30 September 2018 at 14:06:20 UTC, Vinod K Chandran wrote: Thanks. It worked. I would like to compile this as a gui. Now it starts with the cmd. Google search didn't gave me the link i want. Any help ? With the

Re: Use nested functions as callbacks with Windows API functions?

2018-10-02 Thread John Chapman via Digitalmars-d-learn
On Monday, 1 October 2018 at 20:27:43 UTC, spikespaz wrote: Of course there is nothing wrong with defining each callback as a separate function, but then comes the issue of naming them. I also don't like the way it makes my code look. I think the best you can do is something like this: ---

Re: Dlang tour - Unittesting example

2018-10-02 Thread bauss via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 04:13:01 UTC, Joe wrote: There appears to be a problem with the example at https://tour.dlang.org/tour/en/gems/unittesting If compiled with -unittest, the resulting program crashes. It happens with ldc2 on Linux but it can also be seen if you click on "Export"

Re: GC page and block metadata storage

2018-10-02 Thread thedeemon via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 07:25:36 UTC, Per Nordlöw wrote: Should a new fresh GC for D store block metadata inside the page itself or in a (pool) structure separate from the page? I'm already aware of Dmitry's suggestion to separate value-type pools from pools of types possibly containing

GC page and block metadata storage

2018-10-02 Thread Per Nordlöw via Digitalmars-d-learn
Should a new fresh GC for D store block metadata inside the page itself or in a (pool) structure separate from the page? I'm already aware of Dmitry's suggestion to separate value-type pools from pools of types possibly containing addresses.

Re: How to implement D to HTML pages ?

2018-10-02 Thread bauss via Digitalmars-d-learn
On Monday, 1 October 2018 at 23:17:59 UTC, rjframe wrote: vibe.d has more of a node.js feel. There's also DiamondMVC[1], which reminds me of ASP.NET (I'm not 100% sure whether that's intentional, and I haven't tried Diamond) and includes an ORM. As the creator of Diamond, then I can say

Re: How to implement D to HTML pages ?

2018-10-02 Thread bauss via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 06:56:33 UTC, bauss wrote: As described on the website (https://diamondmvvc.org/): Minor typo sorry. https://diamondmvc.org/

Re: Wrong module initialization order when building with Dub on Windows?

2018-10-02 Thread bauss via Digitalmars-d-learn
On Tuesday, 2 October 2018 at 01:57:00 UTC, Vladimir Panteleev wrote: Ran into this today, don't have time to dig in now but maybe someone ran into this too. Steps to reproduce: - git clone https://github.com/CyberShadow/ae - cd ae/demo/inputtiming - (download/unpack

Re: Use nested functions as callbacks with Windows API functions?

2018-10-02 Thread Boris-Barboris via Digitalmars-d-learn
On Monday, 1 October 2018 at 23:07:29 UTC, spikespaz wrote: The problem with the code you have is that the callback needs to be extern (Windows). I don't know how to do that with a "lambda". Neither do I actually. Apparently it is impossible. Best I could squeeze out was this: