Re: extern(C++) in win32.mak

2018-02-06 Thread rikki cattermole via Digitalmars-d-learn
On 07/02/2018 6:05 AM, Paul D Anderson wrote: I don't understand the following line in dmd/src/win32.mak: extern (C++) __gshared const(char)* ddoc_default = import ("default_ddoc_theme.ddoc"); That is a string import (-J). What does the word "import" mean in this context? I can't find any

extern(C++) in win32.mak

2018-02-06 Thread Paul D Anderson via Digitalmars-d-learn
I don't understand the following line in dmd/src/win32.mak: extern (C++) __gshared const(char)* ddoc_default = import ("default_ddoc_theme.ddoc"); What does the word "import" mean in this context? I can't find any documentation on the use of import in this way, and the line fails to compile

Re: more OO way to do hex string to bytes conversion

2018-02-06 Thread rikki cattermole via Digitalmars-d-learn
On 07/02/2018 4:06 AM, Craig Dillabaugh wrote: On Wednesday, 7 February 2018 at 03:25:05 UTC, rikki cattermole wrote: On 06/02/2018 8:46 PM, Craig Dillabaugh wrote: On Tuesday, 6 February 2018 at 18:46:54 UTC, H. S. Teoh wrote: [...] clip [...] clip [...] Wouldn't it be more accurate to

Re: more OO way to do hex string to bytes conversion

2018-02-06 Thread Craig Dillabaugh via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 03:25:05 UTC, rikki cattermole wrote: On 06/02/2018 8:46 PM, Craig Dillabaugh wrote: On Tuesday, 6 February 2018 at 18:46:54 UTC, H. S. Teoh wrote: [...] clip [...] clip [...] Wouldn't it be more accurate to say OO is not the correct tool for every job

Re: more OO way to do hex string to bytes conversion

2018-02-06 Thread rikki cattermole via Digitalmars-d-learn
On 06/02/2018 8:46 PM, Craig Dillabaugh wrote: On Tuesday, 6 February 2018 at 18:46:54 UTC, H. S. Teoh wrote: On Tue, Feb 06, 2018 at 06:33:02PM +, Ralph Doncaster via Digitalmars-d-learn wrote: clip OO is outdated.  D uses the range-based idiom with UFCS for chaining operations in a

Re: enumerated iteration to struct

2018-02-06 Thread Seb via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 01:45:27 UTC, Jonathan M Davis wrote: Perhaps, but foreach does not support that. foreach(e; range) { ... } is lowered to something like for(auto __range = range; !__range.empty; __range.popFront()) { auto e = __range.front; ... } Fun fact: an

Re: enumerated iteration to struct

2018-02-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, February 07, 2018 01:21:16 Fra Mecca via Digitalmars-d-learn wrote: > On Wednesday, 7 February 2018 at 01:10:34 UTC, Fra Mecca wrote: > > I don't know if this post belongs to the learn section, but > > I'll try anyway. > > > > I am using the std.path.pathSplitter function that

macOS preview D files

2018-02-06 Thread Joel via Digitalmars-d-learn
Using finder, I want to see D files shown in the preview column, I some times have with TextMate. Also on my iPhone (in iCloud app, open as a text file) would be a bonus too.

Re: enumerated iteration to struct

2018-02-06 Thread Fra Mecca via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 01:10:34 UTC, Fra Mecca wrote: I don't know if this post belongs to the learn section, but I'll try anyway. I am using the std.path.pathSplitter function that returns a PathSplitter function exposing ranges primitive. I have some question that could be

enumerated iteration to struct

2018-02-06 Thread Fra Mecca via Digitalmars-d-learn
I don't know if this post belongs to the learn section, but I'll try anyway. I am using the std.path.pathSplitter function that returns a PathSplitter function exposing ranges primitive. I have some question that could be generalized to other structs that expose range primitives. 1. Why

Re: Run-time initialised static variables

2018-02-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 06, 2018 23:50:52 dekevin via Digitalmars-d-learn wrote: > Thanks a lot! I will change all my initialisations to static > constructors now. I should point out that the downside to static constructors is that if you have modules that recursively depend on each other, the

Re: Run-time initialised static variables

2018-02-06 Thread dekevin via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 23:50:52 UTC, dekevin wrote: On Tuesday, 6 February 2018 at 23:21:36 UTC, Jonathan M Davis wrote: [...] Thanks a lot! I will change all my initialisations to static constructors now. The only additional problem I have, is that ℚInf has a disabled default

Re: Run-time initialised static variables

2018-02-06 Thread dekevin via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 23:21:36 UTC, Jonathan M Davis wrote: On Tuesday, February 06, 2018 23:03:07 dekevin via Digitalmars-d-learn wrote: Hello everyone, I just ran into the problem, that I need a static variable, where the initialisation code for that variable is only accessible

Re: Implicit Casting

2018-02-06 Thread Ali Çehreli via Digitalmars-d-learn
On 02/06/2018 01:35 PM, Jonathan wrote: > But what I really want it to do is to implicitly cast an `int[2]` to a > `Pos`. > > Is this possible in D? Simply, no. :) Ali

Re: Run-time initialised static variables

2018-02-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 06, 2018 23:03:07 dekevin via Digitalmars-d-learn wrote: > Hello everyone, > I just ran into the problem, that I need a static variable, where > the initialisation code for that variable is only accessible > during run-time (since part of the initialisation code will be >

Run-time initialised static variables

2018-02-06 Thread dekevin via Digitalmars-d-learn
Hello everyone, I just ran into the problem, that I need a static variable, where the initialisation code for that variable is only accessible during run-time (since part of the initialisation code will be dynamically linked). Is there a way to do this in D? To be a bit more concrete, this

Shouldn't D be added to this list?

2018-02-06 Thread WhatMeWorry via Digitalmars-d-learn
Sorry if this is the wrong place to post, but I just came across this just now: https://www.khronos.org/opengl/wiki/Language_bindings I was thinking that with derelictGL, D should be on this list? If so, I'm not sure how one would go about this?

Re: more OO way to do hex string to bytes conversion

2018-02-06 Thread Ali Çehreli via Digitalmars-d-learn
On 02/06/2018 11:55 AM, Ralph Doncaster wrote: > I'll have to do some more reading about > maps. My initial though is they don't seem as readable as loops. Surprisingly, they may be very easy to read in some situations. > The chunks() is useful, so for now what I'm going with is: >

Re: DLangUI Drag and Drop support?

2018-02-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-02-06 09:32, Andres Clari wrote: But DWT doesn't support macOS right? That would be my main target... Aha, no it doesn't. -- /Jacob Carlborg

Re: dirEntries returns relative, not absolute paths

2018-02-06 Thread Timothee Cour via Digitalmars-d-learn
https://github.com/dlang/phobos/pull/6133 On Tue, Feb 6, 2018 at 1:40 PM, Jonathan M Davis via Digitalmars-d-learn wrote: > On Tuesday, February 06, 2018 18:58:43 number via Digitalmars-d-learn wrote: >> https://dlang.org/phobos/std_file.html#dirEntries >> >>

Re: dirEntries returns relative, not absolute paths

2018-02-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 06, 2018 18:58:43 number via Digitalmars-d-learn wrote: > https://dlang.org/phobos/std_file.html#dirEntries > > >> The name of each iterated directory entry contains the > >> absolute path. > > it seems to be absolute only if the specified path is absolute, > or always

Implicit Casting

2018-02-06 Thread Jonathan via Digitalmars-d-learn
I am trying to make a `Pos` type. But I need it to implicitly cast from an `int[2]`. I am using the `alias this` to get most of what I want but it still doesn't do all an implicit cast can do. What I have now is this: struct Pos { int[2] pos; alias pos this; this

Re: workspace-d dsymbol Visual Code macOS

2018-02-06 Thread Joel via Digitalmars-d-learn
[snip] On Tuesday, 6 February 2018 at 20:59:54 UTC, WebFreak001 wrote: can you try git clone https://github.com/Pure-D/workspace-d.git cd workspace-d dub upgrade dub build and then put the resulting path of the executables in your user settings as "d.workspacedPath" I got the same compile

Re: workspace-d dsymbol Visual Code macOS

2018-02-06 Thread WebFreak001 via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 20:43:55 UTC, Joel wrote: On Tuesday, 6 February 2018 at 19:36:54 UTC, WebFreak001 wrote: On Tuesday, 6 February 2018 at 05:41:19 UTC, Joel wrote: I'm using a macOS (10.12.6) computer. workspace-d used to work, but now it says it's not installed, (I think since I

Re: more OO way to do hex string to bytes conversion

2018-02-06 Thread Craig Dillabaugh via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 18:46:54 UTC, H. S. Teoh wrote: On Tue, Feb 06, 2018 at 06:33:02PM +, Ralph Doncaster via Digitalmars-d-learn wrote: clip OO is outdated. D uses the range-based idiom with UFCS for chaining operations in a way that doesn't require you to write loops

Re: workspace-d dsymbol Visual Code macOS

2018-02-06 Thread Joel via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 19:36:54 UTC, WebFreak001 wrote: On Tuesday, 6 February 2018 at 05:41:19 UTC, Joel wrote: I'm using a macOS (10.12.6) computer. workspace-d used to work, but now it says it's not installed, (I think since I quit out of Visual Code before shutting down the

Re: more OO way to do hex string to bytes conversion

2018-02-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/6/18 1:46 PM, H. S. Teoh wrote: Of course, this eagerly constructs an array to store the result, which allocates, and also requires the hex string to be fully constructed first. You can make this code lazy by turning it into a range algorithm, then you can actually generate the hex digits

Re: DLangUI Drag and Drop support?

2018-02-06 Thread Andres Clari via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 08:48:47 UTC, aberba wrote: On Saturday, 3 February 2018 at 18:06:30 UTC, Andres Clari wrote: Hi, is there support for drag and drop in dlangui?? I haven't found anything on the docs, issues or forums. I'm building a project that requires support for dropping

Re: more OO way to do hex string to bytes conversion

2018-02-06 Thread Ralph Doncaster via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 18:33:02 UTC, Ralph Doncaster wrote: I've been reading std.conv and std.range, trying to figure out a high-level way of converting a hex string to bytes. The only way I've been able to do it is through pointer access: import std.stdio; import std.string; import

Re: workspace-d dsymbol Visual Code macOS

2018-02-06 Thread WebFreak001 via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 05:41:19 UTC, Joel wrote: I'm using a macOS (10.12.6) computer. workspace-d used to work, but now it says it's not installed, (I think since I quit out of Visual Code before shutting down the computer). I tried compiling with with the option, but got this:

Re: Getting compiler Segfault

2018-02-06 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Feb 05, 2018 at 07:30:09PM +, Ur@nuz via Digitalmars-d-learn wrote: > On Monday, 5 February 2018 at 12:20:05 UTC, Jacob Carlborg wrote: > > On 2018-02-04 13:52, Ur@nuz wrote: > > > Getting compiler stack overflow when building my project, but > > > still do not know how to localize

Re: Can't cast from void*

2018-02-06 Thread Temtaime via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 08:29:05 UTC, Kagamin wrote: On Monday, 5 February 2018 at 15:33:02 UTC, Steven Schveighoffer wrote: Is there a more pragmatic use case why this should be possible? Maybe for least surprise. The error message almost convinced me that such cast is impossible,

Re: more OO way to do hex string to bytes conversion

2018-02-06 Thread Machin via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 18:33:02 UTC, Ralph Doncaster wrote: I've been reading std.conv and std.range, trying to figure out a high-level way of converting a hex string to bytes. The only way I've been able to do it is through pointer access: import std.stdio; import std.string; import

Re: more OO way to do hex string to bytes conversion

2018-02-06 Thread ag0aep6g via Digitalmars-d-learn
On 02/06/2018 07:33 PM, Ralph Doncaster wrote: I've been reading std.conv and std.range, trying to figure out a high-level way of converting a hex string to bytes.  The only way I've been able to do it is through pointer access: import std.stdio; import std.string; import std.conv; void

dirEntries returns relative, not absolute paths

2018-02-06 Thread number via Digitalmars-d-learn
https://dlang.org/phobos/std_file.html#dirEntries The name of each iterated directory entry contains the absolute path. it seems to be absolute only if the specified path is absolute, or always relative to the parent dir of the specified path. import std.stdio;import std.stdio; void main()

Re: more OO way to do hex string to bytes conversion

2018-02-06 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Feb 06, 2018 at 06:33:02PM +, Ralph Doncaster via Digitalmars-d-learn wrote: > I've been reading std.conv and std.range, trying to figure out a > high-level way of converting a hex string to bytes. The only way I've > been able to do it is through pointer access: > > import

more OO way to do hex string to bytes conversion

2018-02-06 Thread Ralph Doncaster via Digitalmars-d-learn
I've been reading std.conv and std.range, trying to figure out a high-level way of converting a hex string to bytes. The only way I've been able to do it is through pointer access: import std.stdio; import std.string; import std.conv; void main() { immutable char* hex =

Re: Error: template std.conv.parse cannot deduce function from argument types

2018-02-06 Thread Ralph Doncaster via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 17:47:30 UTC, Adam D. Ruppe wrote: On Tuesday, 6 February 2018 at 17:33:43 UTC, Ralph Doncaster wrote: I get this error when I try the following code: parse specifically works with a reference input it can advance. From the docs: "It takes the input by

Re: Error: template std.conv.parse cannot deduce function from argument types

2018-02-06 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 17:33:43 UTC, Ralph Doncaster wrote: I get this error when I try the following code: parse specifically works with a reference input it can advance. From the docs: "It takes the input by reference. (This means that rvalues - such as string literals - are not

Error: template std.conv.parse cannot deduce function from argument types

2018-02-06 Thread Ralph Doncaster via Digitalmars-d-learn
I get this error when I try the following code: struct Record { union { ubyte[8] bytes; ulong l;} uint key; } Record r; r.l = parse!ulong("deadbeef", 16); However the following works: string s = "deadbeef"; r.l = parse!ulong(s, 16); And another way that works: r.l =

Re: Can't cast from void*

2018-02-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/6/18 3:29 AM, Kagamin wrote: On Monday, 5 February 2018 at 15:33:02 UTC, Steven Schveighoffer wrote: Is there a more pragmatic use case why this should be possible? Maybe for least surprise. The error message almost convinced me that such cast is impossible, only because of my memory

Understanding the AST...

2018-02-06 Thread joe via Digitalmars-d-learn
Hello everybody! Last week end I found this post ( https://dlang.org/blog/2017/08/01/a-dub-case-study-compiling-dmd-as-a-library/ ) on the Blog and thought to myself awesome. So I built the library and everything went smooth. Thanks for the effort of all the involved people who made that

Re: Using file as input to stdin when compiling

2018-02-06 Thread Seb via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 06:10:30 UTC, Jamie wrote: Hi, I'm following through TDPL and am trying to import a txt file during compiling for the stdin.byLine() function to read. Currently I have #!/usr/bin/rdmd and would like it to analyse the supplied text file. Is this possible in the

Re: Interactive Interpreter

2018-02-06 Thread Jiyan via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 01:23:57 UTC, Stefan Koch wrote: On Monday, 5 February 2018 at 19:54:09 UTC, Jiyan wrote: Is there any work for an interactive interpreter for D -maybe just for ctfe-able expressions? It shouldnt be too hard to implement it regarding the fact, that ctfe is kinda

Re: DLangUI Drag and Drop support?

2018-02-06 Thread aberba via Digitalmars-d-learn
On Saturday, 3 February 2018 at 18:06:30 UTC, Andres Clari wrote: Hi, is there support for drag and drop in dlangui?? I haven't found anything on the docs, issues or forums. I'm building a project that requires support for dropping URLs from the browser into a ListWidget. Is this possible with

Re: DLangUI Drag and Drop support?

2018-02-06 Thread Andres Clari via Digitalmars-d-learn
On Monday, 5 February 2018 at 12:17:22 UTC, Jacob Carlborg wrote: On 2018-02-03 19:06, Andres Clari wrote: Hi, is there support for drag and drop in dlangui?? I haven't found anything on the docs, issues or forums. I'm building a project that requires support for dropping URLs from the

Re: Can't cast from void*

2018-02-06 Thread Kagamin via Digitalmars-d-learn
On Monday, 5 February 2018 at 15:33:02 UTC, Steven Schveighoffer wrote: Is there a more pragmatic use case why this should be possible? Maybe for least surprise. The error message almost convinced me that such cast is impossible, only because of my memory that this cast used to be possible