Re: Request assistance initializing struct instance at global scope

2020-12-07 Thread Andrew Edwards via Digitalmars-d-learn
On 12/7/20 10:56 PM, Adam D. Ruppe wrote: On Monday, 7 December 2020 at 04:13:16 UTC, Andrew Edwards wrote: Given: === extern(C): char*[] hldr; Why is this extern(C)? A D array ere is probably wrong. To stay as close to the original implementation as possible. This will all

Re: Request assistance initializing struct instance at global scope

2020-12-07 Thread Andrew Edwards via Digitalmars-d-learn
On 12/7/20 10:12 PM, Jacob Carlborg wrote: On Monday, 7 December 2020 at 04:13:16 UTC, Andrew Edwards wrote: You can either use `extern(C) char*[] hldr` to make only `hldr` have C linkage. Use `extern(C) {}` to group several symbols which should have C linkage or rearrange the code so that

Request assistance initializing struct instance at global scope

2020-12-06 Thread Andrew Edwards via Digitalmars-d-learn
Given: === extern(C): char*[] hldr; enum I = (1<<0); struct S { char* ft; char** fm; int f; } void main(){} === How do I initialize an instance of S at global scope? // Not sure how to do this... so try to keep as close to original as possible // Nope, does not work

Re: Interfacing to C++: Cannot access value from namespace

2019-09-07 Thread Andrew Edwards via Digitalmars-d-learn
On Saturday, 7 September 2019 at 12:39:25 UTC, Ali Çehreli wrote: On 09/07/2019 03:26 AM, Andrew Edwards wrote: > [1] I did not declare any of the other member variables from the struct, > don't know if this is a source of the problem. Yes, it definitely is a problem. The members are accessed

Re: Interfacing to C++: Cannot access value from namespace

2019-09-07 Thread Andrew Edwards via Digitalmars-d-learn
On Saturday, 7 September 2019 at 12:30:53 UTC, Andrew Edwards wrote: On Saturday, 7 September 2019 at 12:24:49 UTC, Ali Çehreli wrote: On 09/07/2019 03:26 AM, Andrew Edwards wrote: > float continuallyUpdatedValue; > float continuallyChangingValue; // [1] They mean the same thing for

Re: Interfacing to C++: Cannot access value from namespace

2019-09-07 Thread Andrew Edwards via Digitalmars-d-learn
On Saturday, 7 September 2019 at 12:24:49 UTC, Ali Çehreli wrote: On 09/07/2019 03:26 AM, Andrew Edwards wrote: > float continuallyUpdatedValue; > float continuallyChangingValue; // [1] They mean the same thing for an English speaker but compilers don't know that (yet?). :) Ali

Interfacing to C++: Cannot access value from namespace

2019-09-07 Thread Andrew Edwards via Digitalmars-d-learn
I'm running into the following issue when attempting to interface with C++: // C++ namespace MySpace { MyType& GetData(); } struct MyType { // ... float continuallyUpdatedValue; // ... }; // call site MySpace::GetData().continuallyUpdatedValue; // D extern

Re: C++ vs D: Default param values and struct to array casting

2019-09-07 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 6 September 2019 at 18:31:29 UTC, Ali Çehreli wrote: On 09/06/2019 02:14 AM, Andrew Edwards wrote: > I'm seeking some pointers on how to define these in D Here is my attempt: Ali, this is awesome. It solves all 4 problems in on shot. I definitely don't intend on using the

Re: C++ vs D: Default param values and struct to array casting

2019-09-06 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 6 September 2019 at 11:35:59 UTC, a11e99z wrote: https://dlang.org/spec/simd.html This didn't work two well because I wont be able to access the members by name as C++ library expects. Will consider during refactoring. also probably u can do https://run.dlang.io/is/WMQE93

Re: C++ vs D: Default param values and struct to array casting

2019-09-06 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 6 September 2019 at 09:49:33 UTC, Johan Engelen wrote: On Friday, 6 September 2019 at 09:14:31 UTC, Andrew Edwards wrote: C++ allows the for following: struct Demo { float a, b, c, d; Demo() { a = b = c = d = 0.0f; } Demo(float _a, float _b, float _c, float

Re: C++ vs D: Default param values and struct to array casting

2019-09-06 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 6 September 2019 at 09:14:31 UTC, Andrew Edwards wrote: C++ allows the for following: struct Demo { float a, b, c, d; Demo() { a = b = c = d = 0.0f; } Demo(float _a, float _b, float _c, float _d) { a = _a; b = _b;

C++ vs D: Default param values and struct to array casting

2019-09-06 Thread Andrew Edwards via Digitalmars-d-learn
C++ allows the for following: struct Demo { float a, b, c, d; Demo() { a = b = c = d = 0.0f; } Demo(float _a, float _b, float _c, float _d) { a = _a; b = _b; c = _c; d = _d; } float

Re: Linking to -framework on MacOS

2019-09-06 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 5 September 2019 at 18:26:41 UTC, DanielG wrote: And depending on the version of macOS / which framework you're linking to, you might need to specify a search path as well (-F): lflags "-framework" "SomeFramework" "-framework" "AnotherFramework" "-F/Library/Frameworks" IIRC I

Re: Linking to -framework on MacOS

2019-09-06 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 5 September 2019 at 12:30:33 UTC, Jacob Carlborg wrote: On 2019-09-04 17:12, Andrew Edwards wrote: Worked like a charm:  -L/System/Library/Frameworks/Cocoa.framework/Cocoa This probably not a good idea. It relies on how a framework is structured internally. Adam's solution is

Re: getting rid of immutable (or const)

2019-09-05 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 5 September 2019 at 08:16:08 UTC, Daniel Kozak wrote: On Thu, Sep 5, 2019 at 9:55 AM berni via Digitalmars-d-learn wrote: I still struggle with the concept of immutable and const: > import std.stdio; > > void main() > { > auto p = Point(3); > auto q = p.x; >

Re: Linking to -framework on MacOS

2019-09-04 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 4 September 2019 at 15:22:51 UTC, Adam D. Ruppe wrote: On Wednesday, 4 September 2019 at 15:00:52 UTC, Andrew Edwards wrote: Could someone point me in the right direction please? You can also add `-L-framework -LCocoa` to dmd to pass the two arguments to the linker (they need

Re: Linking to -framework on MacOS

2019-09-04 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 4 September 2019 at 15:05:46 UTC, rikki cattermole wrote: Four years ago, I was linking against Cocoa via: "lflags-osx": ["/System/Library/Frameworks/Cocoa.framework/Cocoa"], I don't know if this will help you or not. Worked like a charm:

Linking to -framework on MacOS

2019-09-04 Thread Andrew Edwards via Digitalmars-d-learn
Hello, I'm trying to link to "-framework OpenGL" on MacOS and finding any clues on how to accomplish this. If I pass that switch to clang and use clang to create the executable, it works perfectly but I would like to use dmd to create the executable. Here is the list of errors I'm trying to

Re: Basic Linear Algebra and D's Array Operation

2019-05-19 Thread Andrew Edwards via Digitalmars-d-learn
On Sunday, 19 May 2019 at 17:13:11 UTC, Alex wrote: The operation itself is, however, a simple one. To implement a basic version I would cite http://rosettacode.org/wiki/Matrix_multiplication#D This is awesome. Thank you very much. Andrew

Re: Basic Linear Algebra and D's Array Operation

2019-05-19 Thread Andrew Edwards via Digitalmars-d-learn
On Sunday, 19 May 2019 at 10:07:35 UTC, Alex wrote: On Sunday, 19 May 2019 at 06:34:18 UTC, Andrew Edwards wrote: So the question is, how do I pull this off in D using just builtin arrays and phobos? Any assistance is appreciated. Slice operations exist, but they are defined mainly for

Basic Linear Algebra and D's Array Operation

2019-05-19 Thread Andrew Edwards via Digitalmars-d-learn
Sooo... I'm trying to learn this stuff so that I can fully grasp the content of Jens Mueller's 2019 DConf talk and its applications in financial sector (forex and options/futures trading). Unfortunately, I'm doing so using python but I'd like to accomplish the same in D. Here goes: Array

Re: Request some GtkD Assistance

2019-03-28 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 27 March 2019 at 19:18:17 UTC, Mike Wey wrote: That because of the way the dmd and the linker interpret the arguments. -L tell dmd to pass the command that follows to the linker. To tell the linker to link with a library in a known location you would use the -l flag. For the

Re: Request some GtkD Assistance

2019-03-27 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 27 March 2019 at 09:07:37 UTC, Nicholas Wilson wrote: On Wednesday, 27 March 2019 at 06:55:53 UTC, Andrew Edwards wrote: dmd -de -w -Llibgtkd-3.a nufsaid try dmd -de -w -lgtkd-3 nufsaid No. That did not work. dmd -de -w -L/path/to/lib nufsaid This would is already

Request some GtkD Assistance

2019-03-27 Thread Andrew Edwards via Digitalmars-d-learn
Good day all, I've installed Gtk+ and GtkD on my MacBookPro which is running macOS Mojave but am having some issues linking to and using it. Any assistance to resolve this is appreciated. Steps taken: 1. Install Gtk+ brew install gtk+ 2. Build and install GtkD-3.8.5 unzip

Re: std.functional.compose compilation error

2017-11-08 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 9 November 2017 at 05:07:33 UTC, Andrew Edwards wrote: On Thursday, 9 November 2017 at 04:58:19 UTC, Chuck Allison wrote: Chuck Allison Sorry to hijack this thread but it shan't be helped. Chuck, how is it going? Curious about the status of "Thinking in D". How do I go about

Re: std.functional.compose compilation error

2017-11-08 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 9 November 2017 at 04:58:19 UTC, Chuck Allison wrote: Chuck Allison Sorry to hijack this thread but it shan't be helped. Chuck, how is it going? Curious about the status of "Thinking in D". How do I go about participating in the draft review? -- Andrew

Re: Request Assistance Calling D from C++: weird visibility issue inside struct and namespace

2017-11-08 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 08:42:01 UTC, Petar Kirov [ZombineDev] wrote: Walter has recently been working on improving the C++ mangling, so be sure to test the latest dmd nightly build and if that doesn't work be sure to file bug report(s). https://github.com/dlang/dmd/pull/7250

Re: Request Assistance Calling D from C++: weird visibility issue inside struct and namespace

2017-11-08 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 15:12:05 UTC, MGW wrote: The useful material. https://www.youtube.com/watch?v=HTgJaRRfLPk Useful indeed, thank you.

Re: Request Assistance Calling D from C++: weird visibility issue inside struct and namespace

2017-11-08 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 07:30:34 UTC, evilrat wrote: On Wednesday, 8 November 2017 at 06:34:27 UTC, Andrew Edwards just using fully qualified name didn't make it? void call_cpp() { ::foo("do great things"); // calling global foo return; } No, it did not. Are you sure you

Re: Request Assistance Calling D from C++: weird visibility issue inside struct and namespace

2017-11-07 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 07:06:39 UTC, Nicholas Wilson wrote: On Wednesday, 8 November 2017 at 06:34:27 UTC, Andrew Edwards wrote: I'm having a little bit of problem calling D code from C++ and would appreciate some assistance. First, given the following C++ program wich compiles,

Request Assistance Calling D from C++: weird visibility issue inside struct and namespace

2017-11-07 Thread Andrew Edwards via Digitalmars-d-learn
I'm having a little bit of problem calling D code from C++ and would appreciate some assistance. First, given the following C++ program wich compiles, links, and runs without any problem: == // example.h SOME_API void foo(const char* str); // example.cpp

Generating DDOX documentation

2017-10-20 Thread Andrew Edwards via Digitalmars-d-learn
Given a documented source file (eg. process.d), I can generate the DDOC version of the documentation with the -D switch of DMD as such: $ dmd -Dfprocess.html process.d What do I modify on that line to get the DDOX version of the same file? Thanks, Andrew

Re: What's the best way to programmatically detect the most recent release of DMD and others?

2017-10-16 Thread Andrew Edwards via Digitalmars-d-learn
On Monday, 16 October 2017 at 18:21:46 UTC, Jacob Carlborg wrote: On 2017-10-16 17:13, Andrew Edwards wrote: Is there a better way? The official download script [1] is using the following: You're a godsend. Thank you very much.

What's the best way to programmatically detect the most recent release of DMD and others?

2017-10-16 Thread Andrew Edwards via Digitalmars-d-learn
The best way I know to determine the latest DMD release is http://ftp.digitalmars.com/LATEST. I'm not aware that such a file exists for LDC and GDC so I'm currently doing: string latest(string url) { return executeShell("git ls-remote --tags " ~ url ~ " | cut -d 'v' -f 2 | cut -d '-' -f 1

Re: What is the best way to use requests and iopipe on gzipped JSON file

2017-10-13 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 13 October 2017 at 22:29:39 UTC, Steven Schveighoffer wrote: It might be tough to do it right, but moot point now, since it's not necessary anyway :) -Steve Yup. Thanks again. Andrew

Re: What is the best way to use requests and iopipe on gzipped JSON file

2017-10-13 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 13 October 2017 at 21:53:12 UTC, Steven Schveighoffer wrote: On 10/13/17 4:27 PM, Andrew Edwards wrote: On Friday, 13 October 2017 at 19:17:54 UTC, Steven Schveighoffer wrote: On 10/13/17 2:47 PM, Andrew Edwards wrote: A bit of advice, please. I'm trying to parse a gzipped JSON

Re: What is the best way to use requests and iopipe on gzipped JSON file

2017-10-13 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 13 October 2017 at 20:17:50 UTC, Steven Schveighoffer wrote: On 10/13/17 3:17 PM, Steven Schveighoffer wrote: this should work (something like this really should be in iopipe): while(input.extend(0) != 0) {} // get data until EOF This should work today, actually. Didn't think

Re: What is the best way to use requests and iopipe on gzipped JSON file

2017-10-13 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 13 October 2017 at 19:17:54 UTC, Steven Schveighoffer wrote: On 10/13/17 2:47 PM, Andrew Edwards wrote: A bit of advice, please. I'm trying to parse a gzipped JSON file retrieved from the internet. The following naive implementation accomplishes the task: auto url =

What is the best way to use requests and iopipe on gzipped JSON file

2017-10-13 Thread Andrew Edwards via Digitalmars-d-learn
A bit of advice, please. I'm trying to parse a gzipped JSON file retrieved from the internet. The following naive implementation accomplishes the task: auto url = "http://api.syosetu.com/novelapi/api/?out=json=500=5;; getContent(url) .data .unzip

Re: DUB dependency issue

2017-10-03 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 4 October 2017 at 01:59:48 UTC, Andrew Edwards wrote: Attempting to use iopipe but not sure what I'm doing incorrectly Finally figured it out. For some reason, the init find the local dependency to load but simply adding it to the dub.json afterward resolves the issue.

DUB dependency issue

2017-10-03 Thread Andrew Edwards via Digitalmars-d-learn
Attempting to use iopipe but not sure what I'm doing incorrectly I've cloned the repository in /Users/edwarac/git.repo.dir/ then added the path to dub: edwarac-pc:.dub edwarac$ dub add-path /Users/edwarac/git.repo.dir edwarac-pc:.dub edwarac$ dub list Packages present in the system and known

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
Steven Schveighoffer wrote: On 8/3/17 10:14 PM, Andrew Edwards wrote: I certainly can, but the problem is completely in C, I'm not having any problems in D. In this case, I've simply copied the two functions to test.c and inserted main(). Oh. Then Ali is correct. I assumed that char *s was

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
Ali Çehreli wrote: On 08/03/2017 06:02 PM, Andrew Edwards wrote: char *s; That's an uninitialized C string. OK, I was is indeed the problem. I was thinking for some reason that s gets initialized inside nk_color_hex_rgb() but it's expecting to an array to work with. I actually

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
Ali Çehreli wrote: On 08/03/2017 06:02 PM, Andrew Edwards wrote: char *s; That's an uninitialized C string. OK, I was is indeed the problem. I was thinking for some reason that s gets initialized inside nk_color_hex_rgb() but it's expecting to an array to work with. I actually

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
Steven Schveighoffer wrote: On 8/3/17 9:12 PM, Andrew Edwards wrote: Andrew Edwards wrote: Just in case... here are the two functions being called in main(): https://github.com/vurtun/nuklear/blob/master/nuklear.h#L5695-L5722 Can you show how you declared these in D? It's important. I think

Re: OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
Andrew Edwards wrote: int main() { //int wierd[4]; struct nk_color str = nk_rgba_hex("#deadbeef"); //int wierd[4]; char *s; //int wierd[4]; nk_color_hex_rgb(s, str); //int wierd[4]; printf("(%d,%d,%d)\n",str.r, str.g, str.b); //int wierd[4]; printf("%s\n",

OT: What causes the Segfault in the following?

2017-08-03 Thread Andrew Edwards via Digitalmars-d-learn
int main() { //int wierd[4]; struct nk_color str = nk_rgba_hex("#deadbeef"); //int wierd[4]; char *s; //int wierd[4]; nk_color_hex_rgb(s, str); //int wierd[4]; printf("(%d,%d,%d)\n",str.r, str.g, str.b); //int wierd[4]; printf("%s\n", s); //int

Re: How does one determine the UDAs of all symbols contained in a given module?

2017-07-20 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 19 July 2017 at 14:23:25 UTC, Jacob Carlborg wrote: Here's an example: Thanks... Minus the AliasSeq bit, this is pretty much what I've been working with since talking to Brain. The main problem I'm facing is that it fails to compileif any of the symbols in the imported module

Re: How does one determine the UDAs of all symbols contained in a given module?

2017-07-19 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 19 July 2017 at 11:28:30 UTC, Jacob Carlborg wrote: On 2017-07-19 11:25, Nicholas Wilson wrote: You'll want to use https://dlang.org/spec/traits.html#getMember in conjunction with https://dlang.org/spec/traits.html#getAttributes. Have a look some of the projects on github e.g.

How does one determine the UDAs of all symbols contained in a given module?

2017-07-19 Thread Andrew Edwards via Digitalmars-d-learn
Given a module (somepackage.somemodule) how does one programmatically determine the symbols contained therein and associated UDAs? Where symbol is a variable, function, UDT, etc... is this possible? foreach (symbol; somepackage.somemodule) { writeln(symbol.name, " attributes :")

Re: Help me fix my compiler

2017-07-12 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 12 July 2017 at 12:05:17 UTC, Namal wrote: Hello, I used the Install Script command line to install the newest dmd compiler (Ubuntu 16.04.2 LTS). Now I have to type 'source ~/dlang/dmd-2.074.1/activate' before I can use it and it is also not show in the software center like it

Re: rdmd vs dmd WRT static constructors

2017-07-08 Thread Andrew Edwards via Digitalmars-d-learn
On Sunday, 9 July 2017 at 03:11:17 UTC, Mike Parker wrote: On Sunday, 9 July 2017 at 02:57:54 UTC, Andrew Edwards wrote: To include stat1.d and stat2.d in the compilation, you'll either have to import them in statmain.d or use the --extra-file command line switch: rdmd --extra-file=stat1.d

rdmd vs dmd WRT static constructors

2017-07-08 Thread Andrew Edwards via Digitalmars-d-learn
RDMD does not behave the same as DMD WRT static constructors. The following example, extracted form Mike Parker's "Learning D", does not produce the same result: // stat1.d module stat1; import std.stdio; static this() { writeln("stat1 constructor"); } // stat2.d module stat2; import

Re: Is it possible to call a delegate at compile time?

2017-06-22 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 23 June 2017 at 04:58:07 UTC, ketmar wrote: Andrew Edwards wrote: so no, even if you'll remove `ref`, it will not work. sorry. Okay, got it. Much appreciated.

Is it possible to call a delegate at compile time?

2017-06-22 Thread Andrew Edwards via Digitalmars-d-learn
auto foo(Args...)(ref Args args) { with (Module!"std.conv") with (Module!"std.stdio") { return () => { string[] s; foreach (i, arg; args) { static if (is(Args[i] == string)) { s ~= arg; } else {

Re: .sort vs sort(): std.algorithm not up to the task?

2017-06-08 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 8 June 2017 at 07:23:27 UTC, Jonathan M Davis wrote: release is a member of SortedRange. You don't have to import it separately. You have it automatically by virtue of the fact that sort returns a SortedRange. And unlike calling array, it doesn't copy the entire range or

Re: .sort vs sort(): std.algorithm not up to the task?

2017-06-07 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 8 June 2017 at 04:15:12 UTC, Stanislav Blinov wrote: Earns you nothing? How about not performing an allocation and copy? Seen through the eyes of a complete beginner, this means absolutely nothing. Those are the eyes I am using as I'm reading a book and simply following the

Re: .sort vs sort(): std.algorithm not up to the task?

2017-06-07 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 8 June 2017 at 03:40:08 UTC, Jonathan M Davis wrote: On Thursday, June 08, 2017 03:15:11 Andrew Edwards via Digitalmars-d-learn wrote: I completely understand the differences between ranges and arrays... the thing is, I wasn't working with ranges but arrays instead. If sort

Re: .sort vs sort(): std.algorithm not up to the task?

2017-06-07 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 8 June 2017 at 02:31:43 UTC, Stanislav Blinov wrote: On Thursday, 8 June 2017 at 02:25:17 UTC, Jonathan M Davis wrote: Oh I see, the was error related to iteration, not sorting. Ranges do not support iterating with an index. The workaround if you want to have an index with

Re: .sort vs sort(): std.algorithm not up to the task?

2017-06-07 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 8 June 2017 at 02:21:03 UTC, Stanislav Blinov wrote: aa.keys.sort() should just work as is: aa.keys returns a string[], and that's a random access range that can be sorted. What exactly is the error? It does not ... I provided the code and related error message. See the line

Re: .sort vs sort(): std.algorithm not up to the task?

2017-06-07 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 8 June 2017 at 02:19:15 UTC, Andrew Edwards wrote: Pretty funny. But seriously, this is something that just work. There is now to layers of indirection to achieve what I used to do quite naturally in the language. *should just work

Re: .sort vs sort(): std.algorithm not up to the task?

2017-06-07 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 8 June 2017 at 02:07:07 UTC, Mike B Johnson wrote: On Thursday, 8 June 2017 at 01:57:47 UTC, Andrew Edwards wrote: If I hand you a chihuahua for grooming, why am I getting back a pit bull? I simply want a groomed chihuahua. Why do I need to consult a wizard to get back a groomed

.sort vs sort(): std.algorithm not up to the task?

2017-06-07 Thread Andrew Edwards via Digitalmars-d-learn
Ranges may be finite or infinite but, while the destination may be unreachable, we can definitely tell how far we've traveled. So why doesn't this work? import std.traits; import std.range; void main() { string[string] aa; // what others have referred to as // standard sort works

Re: Error: func(const(A) a) is not callable using argument types (const(A)

2017-05-30 Thread Andrew Edwards via Digitalmars-d-learn
On Tuesday, 30 May 2017 at 10:37:58 UTC, Biotronic wrote: On Tuesday, 30 May 2017 at 10:31:24 UTC, Daniel Kozak wrote: import std.traits : fqn = fullyQualifiedName; Darnit. I just googled the template and got a result talking about fqn!T. So yeah - this code: import std.traits;

Re: Error: func(const(A) a) is not callable using argument types (const(A)

2017-05-30 Thread Andrew Edwards via Digitalmars-d-learn
Sorry, rough day. Could someone please explain what this means and how do go about resolving it? Thanks, Andrew

Error: func(const(A) a) is not callable using argument types (const(A)

2017-05-30 Thread Andrew Edwards via Digitalmars-d-learn
What does that even mean? Scenario: bool func(const ImVec2 label_size) { return true; } void main() { //first attempt: const ImVec2 label_size = CalcTextSize(label.ptr, null, true); //Error: cannot implicitly convert expression (CalcTextSize(cast(immutable(char)*)label, null,

Re: [OT] #define

2017-05-23 Thread Andrew Edwards via Digitalmars-d-learn
On Tuesday, 23 May 2017 at 00:14:43 UTC, Mike Parker wrote: On Monday, 22 May 2017 at 18:44:10 UTC, Andrew Edwards wrote: There isn't any Windows specific section. Every function pointer in the library is decorated in one of the following two forms void (APIENTRY *NAME)(PARAMS) or

Re: [OT] #define

2017-05-22 Thread Andrew Edwards via Digitalmars-d-learn
On Monday, 22 May 2017 at 18:48:44 UTC, Adam D. Ruppe wrote: On Monday, 22 May 2017 at 18:44:10 UTC, Andrew Edwards wrote: Both happen to be the exact same. So does mean that for every function pointer in the file, I need to duplicate as such? You can use `extern(System)` or that case in D.

Re: [OT] #define

2017-05-22 Thread Andrew Edwards via Digitalmars-d-learn
On Monday, 22 May 2017 at 16:56:10 UTC, Mike Parker wrote: On Monday, 22 May 2017 at 16:37:51 UTC, Andrew Edwards wrote: Specific context at the following links: https://github.com/glfw/glfw/blob/66ff4aae89572419bb130c5613798e34d7521fc7/deps/glad/glad.h#L24-L48 Generally, any functions

Re: [OT] #define

2017-05-22 Thread Andrew Edwards via Digitalmars-d-learn
On Monday, 22 May 2017 at 13:52:35 UTC, Dukc wrote: On Monday, 22 May 2017 at 13:11:15 UTC, Andrew Edwards wrote: Sorry if this is a stupid question but it eludes me. In the following, what is THING? What is SOME_THING? [...] I assume you know that the above part is c/c++ preprocessor, which

Re: [OT] #define

2017-05-22 Thread Andrew Edwards via Digitalmars-d-learn
On Monday, 22 May 2017 at 13:15:31 UTC, Adam D. Ruppe wrote: On Monday, 22 May 2017 at 13:11:15 UTC, Andrew Edwards wrote: #ifndef THING #define THING #endif This kind of thing is most commonly used in include guards

Re: [OT] #define

2017-05-22 Thread Andrew Edwards via Digitalmars-d-learn
On Monday, 22 May 2017 at 13:18:51 UTC, Eugene Wissner wrote: On Monday, 22 May 2017 at 13:11:15 UTC, Andrew Edwards wrote: Sorry if this is a stupid question but it eludes me. In the following, what is THING? What is SOME_THING? #ifndef THING #define THING #endif #ifndef

[OT] #define

2017-05-22 Thread Andrew Edwards via Digitalmars-d-learn
Sorry if this is a stupid question but it eludes me. In the following, what is THING? What is SOME_THING? #ifndef THING #define THING #endif #ifndef SOME_THING #define SOME_THING THING * #endif Is this equivalent to: alias thing = void; alias someThing =

Re: Access specifiers and visibility

2017-05-12 Thread Andrew Edwards via Digitalmars-d-learn
On Thursday, 11 May 2017 at 04:35:22 UTC, Jesse Phillips wrote: On Wednesday, 10 May 2017 at 13:29:40 UTC, Andrew Edwards wrote: On Wednesday, 10 May 2017 at 13:13:46 UTC, Jesse Phillips wrote: On Wednesday, 10 May 2017 at 01:42:47 UTC, Andrew Edwards wrote: Attempting to update a git repo to

Re: Access specifiers and visibility

2017-05-10 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 10 May 2017 at 13:13:46 UTC, Jesse Phillips wrote: On Wednesday, 10 May 2017 at 01:42:47 UTC, Andrew Edwards wrote: Attempting to update a git repo to current D, I encounter the following deprecation messages: src/glwtf/signals.d-mixin-256(256,2): Deprecation:

Access specifiers and visibility

2017-05-09 Thread Andrew Edwards via Digitalmars-d-learn
Attempting to update a git repo to current D, I encounter the following deprecation messages: src/glwtf/signals.d-mixin-256(256,2): Deprecation: glwtf.input.BaseGLFWEventHandler._on_key_down is not visible from module glwtf.signals src/glwtf/signals.d-mixin-256(256,2): Deprecation:

Re: Problem with using readln.

2017-04-29 Thread Andrew Edwards via Digitalmars-d-learn
On Sunday, 30 April 2017 at 03:20:20 UTC, JV wrote: On Sunday, 30 April 2017 at 03:18:04 UTC, Adam D. Ruppe wrote: On Sunday, 30 April 2017 at 03:10:25 UTC, JV wrote: btw i forgot to add () at readln while editing the post That's not necessary, it doesn't change anything. But readln without

Re: warning: pointer not aligned at address

2017-04-12 Thread Andrew Edwards via Digitalmars-d-learn
On Wednesday, 12 April 2017 at 03:18:32 UTC, Matt Whisenhunt wrote: ld: warning: pointer not aligned at address 0x100050C7D Are you running macOS and recently installed an update to Xcode? I ran into this today as well. Looks like other have too:

Re: warning: pointer not aligned at address

2017-04-11 Thread Andrew Edwards via Digitalmars-d-learn
Conveniently the site is down immediately after I posted that so here is the code to which I was referring: import std.stdio, std.algorithm, std.range; enum DoorState : bool { closed, open } alias Doors = DoorState[]; Doors flipUnoptimized(Doors doors) pure nothrow { doors[] =

warning: pointer not aligned at address

2017-04-11 Thread Andrew Edwards via Digitalmars-d-learn
When compiled with any dmd compiler from 2.069.0 through present (2.074.0), https://rosettacode.org/wiki/100_doors#D produces the following linker warning: ld: warning: pointer not aligned at address 0x10004FCEB (_D51TypeInfo_S3std5range13__T4iotaTiTmZ4iotaFimZ6Result6__initZ + 24 from

Recursive-descent parsing

2016-12-24 Thread Andrew Edwards via Digitalmars-d-learn
The authors of "The Art of Java" present, as a first coding example, a recursive-descent parser to demonstrate Java's ability to facilitate low level programming commonly performed in C and C++. I took the opportunity to port the code to D. By doing this, I now have an understanding of how a

Re: webfreak001: Request assist installing workspace-d on Windows

2016-07-05 Thread Andrew Edwards via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 19:43:02 UTC, WebFreak001 wrote: On Tuesday, 5 July 2016 at 19:34:48 UTC, Andrew Edwards wrote: It's more than that. Now, it fails because it can't find DMD. As you can see in the build.bat from DCD it is hardcoded to DMD:

Re: webfreak001: Request assist installing workspace-d on Windows

2016-07-05 Thread Andrew Edwards via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 19:25:50 UTC, WebFreak001 wrote: On Tuesday, 5 July 2016 at 19:14:32 UTC, Andrew Edwards wrote: There is on --config=client for the current version of dub so I went to the location of the source for experimental_allocator and ran dub build --build=release

webfreak001: Request assist installing workspace-d on Windows

2016-07-05 Thread Andrew Edwards via Digitalmars-d-learn
I cloned the package and ran install.bat. The result is $ dub build --build=release --config=client Performing "release" build using ldc2 for x86. experimental_allocator 2.70.0-b1: building configuration "library"... Using Visual Studio: C:\Program Files (x86)\Microsoft Visual Studio 14.0\

Re: Fibers under the hood

2016-06-09 Thread Andrew Edwards via Digitalmars-d-learn
On 6/9/16 2:15 PM, Jonathan Marler wrote: On Thursday, 9 June 2016 at 05:07:33 UTC, Nikolay wrote: On Thursday, 9 June 2016 at 04:57:30 UTC, Jonathan Marler wrote: I've googled and searched through the forums but haven't found too much on how fibers are implemented. How does yield return

Re: Request assistance binding to Windows dsound.{lib, dll}

2016-05-27 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 27 May 2016 at 20:59:56 UTC, John wrote: Additionally, remove QueryInterface, AddRef and Release from the definition of IDirectSound. Also, interfaces are already references, so the definition of LPDIRECTSOUND should be: alias LPDIRECTSOUND = IDirectSound; Note there should be

Re: Request assistance binding to Windows dsound.{lib, dll}

2016-05-27 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 27 May 2016 at 17:49:56 UTC, Adam D. Ruppe wrote: On Friday, 27 May 2016 at 17:37:38 UTC, Andrew Edwards wrote: extern (C) class IDirectSound : IUnknown That should just be `interface IDirectSound : IUnknown` Thanks for the clarification. That actually compiles but results

Re: Request assistance binding to Windows dsound.{lib, dll}

2016-05-27 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 27 May 2016 at 16:08:27 UTC, Kagamin wrote: On Friday, 27 May 2016 at 15:28:42 UTC, Andrew Edwards wrote: Have you tried with extern(C) yet? extern(C) is for undecorated symbold extern(Windows) adds the _ and @12 decorations (would be __stdcall on C/C++ side) The thought never

Re: Request assistance binding to Windows dsound.{lib, dll}

2016-05-27 Thread Andrew Edwards via Digitalmars-d-learn
On Friday, 27 May 2016 at 12:30:50 UTC, Guillaume Piolat wrote: On Friday, 27 May 2016 at 12:26:19 UTC, Andrew Edwards wrote: OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html

Request assistance binding to Windows dsound.{lib, dll}

2016-05-27 Thread Andrew Edwards via Digitalmars-d-learn
http://ftp.dlang.org/ctg/implib.html The above URL suggests that, on Windoze, I can create a D compatible lib from a dll file by issuing the command: implib /s dsound.lib dsound.dll The following file: sound.d === pragma(lib, "dsound") struct IDirectSound{};

Re: Request assistance converting C's #ifndef to D

2016-05-13 Thread Andrew Edwards via Digitalmars-d-learn
On 5/14/16 12:35 AM, Steven Schveighoffer wrote: On 5/13/16 12:59 AM, Andrew Edwards wrote: On 5/13/16 8:40 AM, Andrew Edwards wrote: That seems wrong. You can't assign to an enum. Besides, doesn't your declaration of MIN shadow whatever other definitions may be currently in effect? Okay,

Re: Request assistance converting C's #ifndef to D

2016-05-13 Thread Andrew Edwards via Digitalmars-d-learn
On 5/13/16 3:23 PM, tsbockman wrote: On Friday, 13 May 2016 at 06:05:14 UTC, Andrew Edwards wrote: Additionally, what's the best way to handle nested #ifdef's? Those that appear inside structs, functions and the like... I know that global #ifdef's are turned to version blocks but versions

Re: imports && -run [Bug?]

2016-05-13 Thread Andrew Edwards via Digitalmars-d-learn
On 5/13/16 3:10 PM, tsbockman wrote: On Friday, 13 May 2016 at 01:16:36 UTC, Andrew Edwards wrote: command: dmd -run mod inc output: Undefined symbols for architecture x86_64: "_D3inc5printFZv", referenced from: __Dmain in mod.o ld: symbol(s) not found for architecture x86_64 clang:

Re: Request assistance converting C's #ifndef to D

2016-05-13 Thread Andrew Edwards via Digitalmars-d-learn
On 5/13/16 7:51 AM, Andrew Edwards wrote: The following preprocessor directives are frequently encountered in C code, providing a default constant value where the user of the code has not specified one: #ifndef MIN #define MIN 99 #endif #ifndef MAX #define MAX

Re: Request assistance converting C's #ifndef to D

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
On 5/13/16 8:40 AM, Andrew Edwards wrote: That seems wrong. You can't assign to an enum. Besides, doesn't your declaration of MIN shadow whatever other definitions may be currently in effect? Okay, got it. It seams I just hadn't hit that bug yet because of other unresolved issues. Perhaps

imports && -run [Bug?]

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
module mod; // import inc; [1] // import inc: p=print; [1] // static import inc; [1] void main() { // import inc: print; // [2] print(); // static import inc; // [3] // inc.print(); } -- module inc; /*public*/ void print() // [4] { import

Re: Request assistance converting C's #ifndef to D

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
On 5/13/16 8:00 AM, H. S. Teoh via Digitalmars-d-learn wrote: On Fri, May 13, 2016 at 07:51:17AM +0900, Andrew Edwards via Digitalmars-d-learn wrote: The following preprocessor directives are frequently encountered in C code, providing a default constant value where the user of the code has

Request assistance converting C's #ifndef to D

2016-05-12 Thread Andrew Edwards via Digitalmars-d-learn
The following preprocessor directives are frequently encountered in C code, providing a default constant value where the user of the code has not specified one: #ifndef MIN #define MIN 99 #endif #ifndef MAX #define MAX 999 #endif I'm at

Re: Error with associative array initializer DMD32 D Compiler v2.070.0

2016-03-03 Thread Andrew Edwards via Digitalmars-d-learn
On 3/3/16 7:01 PM, MGW wrote: immutable long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ]; The only way this can be done outside the body of a function is if it is a manifest constant. This works: enum long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ];

Re: Alternate databases

2016-02-22 Thread Andrew Edwards via Digitalmars-d-learn
On 2/21/16 12:23 AM, yawniek wrote: On Saturday, 20 February 2016 at 13:09:53 UTC, Andrew Edwards wrote: I'm searching for client drivers for the following databases. Are the any available? https://rethinkdb.com/docs/install-drivers/

  1   2   >