Re: question on dub and postgresql

2020-10-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 5 October 2020 at 15:08:54 UTC, Alaindevos wrote: Yet it would be nice to know why i can't iterate directly over answer using foreach. Looking at the implementation of the `Answer` type [1], I see no way to create a range or a slice, and no `opApply`. So you'll have to ask the

Re: question on dub and postgresql

2020-10-05 Thread Alaindevos via Digitalmars-d-learn
On Monday, 5 October 2020 at 14:57:53 UTC, Alaindevos wrote: answer[0][0].as!PGtext contains good data I found an answer. foreach(rownumber; answer.length.iota){ auto arow=answer[rownumber]; writeln(arow); } Yet it would be nice to know why i can't iterate directly over answer using

Re: question on dub and postgresql

2020-10-05 Thread Alaindevos via Digitalmars-d-learn
answer[0][0].as!PGtext contains good data

Re: question on dub and postgresql

2020-10-05 Thread Alaindevos via Digitalmars-d-learn
Just Connection worked. But how do I loop over results of a select statement. string sql=format(" SELECT * from %s ;",tablepredata); auto answer = conn.exec(sql); foreach(arow; answer){ writeln(arow); } Fails with, dub ~master: building configuration "application"... source/app.d(36,3):

Re: question on dub and postgresql

2020-10-05 Thread Alaindevos via Digitalmars-d-learn
On Monday, 5 October 2020 at 13:30:22 UTC, Alaindevos wrote: On Monday, 5 October 2020 at 11:35:43 UTC, Imperatorn wrote: On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote: On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote: On Monday, 5 October 2020 at 08:24:26 UTC,

Re: question on dub and postgresql

2020-10-05 Thread Alaindevos via Digitalmars-d-learn
On Monday, 5 October 2020 at 11:35:43 UTC, Imperatorn wrote: On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote: On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote: On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote: [...] Take a look at:

Re: question on dub and postgresql

2020-10-05 Thread Imperatorn via Digitalmars-d-learn
On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote: On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote: On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote: [...] Take a look at: https://code.dlang.org/packages/dpq2 https://code.dlang.org/packages/ddbc Say I want

Re: question on dub and postgresql

2020-10-05 Thread Alaindevos via Digitalmars-d-learn
On Monday, 5 October 2020 at 09:24:33 UTC, Mike Parker wrote: On Monday, 5 October 2020 at 09:05:16 UTC, Alaindevos wrote: [...] You don't need to install dpq2 if you are using dub to build your project. Add it as a dependency to your dub.json (or dub.sdl if you prefer that format). When

Re: question on dub and postgresql

2020-10-05 Thread Mike Parker via Digitalmars-d-learn
On Monday, 5 October 2020 at 09:05:16 UTC, Alaindevos wrote: A name dependency solution is at least vage. How do I install , https://github.com/denizzzka/dpq2 on unix so in the code i write the .d files of that library and after compilation linked to the libary shared objects. For that shared

Re: question on dub and postgresql

2020-10-05 Thread drug via Digitalmars-d-learn
On 10/5/20 12:05 PM, Alaindevos wrote: On Monday, 5 October 2020 at 08:54:39 UTC, Daniel Kozak wrote: On Mon, Oct 5, 2020 at 10:25 AM Alaindevos via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: Can I say python has pip, ruby has bundle and D has dub. Meaning they perform

Re: question on dub and postgresql

2020-10-05 Thread Alaindevos via Digitalmars-d-learn
On Monday, 5 October 2020 at 08:54:39 UTC, Daniel Kozak wrote: On Mon, Oct 5, 2020 at 10:25 AM Alaindevos via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: Can I say python has pip, ruby has bundle and D has dub. Meaning they perform the same function ? Or am I wrong? Yes

Re: question on dub and postgresql

2020-10-05 Thread Alaindevos via Digitalmars-d-learn
On Monday, 5 October 2020 at 08:50:53 UTC, Alaindevos wrote: On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote: On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote: On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote: [...] Take a look at:

Re: question on dub and postgresql

2020-10-05 Thread Daniel Kozak via Digitalmars-d-learn
On Mon, Oct 5, 2020 at 10:25 AM Alaindevos via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > Can I say python has pip, ruby has bundle and D has dub. > Meaning they perform the same function ? > Or am I wrong? > Yes and no. Dub is Dlang dependency solution but it is not

Re: question on dub and postgresql

2020-10-05 Thread Alaindevos via Digitalmars-d-learn
On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote: On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote: On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote: [...] Take a look at: https://code.dlang.org/packages/dpq2 https://code.dlang.org/packages/ddbc Say I want

Re: question on dub and postgresql

2020-10-05 Thread Alaindevos via Digitalmars-d-learn
On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote: On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote: [...] Take a look at: https://code.dlang.org/packages/dpq2 https://code.dlang.org/packages/ddbc Say I want to use dpq2. Do I need to clone the git repository with "git

Re: question on dub and postgresql

2020-10-05 Thread Alaindevos via Digitalmars-d-learn
clone ? Do I need to create and edit a specific dub json config file ? It is very unclear how to start. [Cfr. in python it is just a "pip install postgres". And you're fine ] Thanks for any info. Some additional question, i struggle with. Do i run dub make dub install on git clone ? Or m

Re: question on dub and postgresql

2020-10-05 Thread Imperatorn via Digitalmars-d-learn
On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote: Can I say python has pip, ruby has bundle and D has dub. Meaning they perform the same function ? Or am I wrong? As I use unix the parameters for include and library are a real pain. I have totally no idea how to connect to a

question on dub and postgresql

2020-10-05 Thread Alaindevos via Digitalmars-d-learn
Can I say python has pip, ruby has bundle and D has dub. Meaning they perform the same function ? Or am I wrong? As I use unix the parameters for include and library are a real pain. I have totally no idea how to connect to a postgresql database. Where and how do I start to connect to a

Re: Question about linker errors when using slices

2020-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn
Andrei's recent push to demystify TypeInfo stuff makes this a lot more tractable. The answer is -- just build with all the files. The linker should throw out stuff that isn't needed. PS: I hope this is the right sub-forum for asking this sort of question! Of course! -Steve

Re: Question about linker errors when using slices

2020-09-19 Thread Jacob Carlborg via Digitalmars-d-learn
in advance for your time! You should compile both files. I'm guessing LDC might be doing some form of optimization to figure out that it doesn't need those symbols. PS: I hope this is the right sub-forum for asking this sort of question! Yes. -- /Jacob Carlborg

Question about linker errors when using slices

2020-09-18 Thread tspike via Digitalmars-d-learn
this is the right sub-forum for asking this sort of question!

Re: another question on hidden mixin names

2020-09-17 Thread 60rntogo via Digitalmars-d-learn
On Thursday, 17 September 2020 at 22:07:54 UTC, Simen Kjærås wrote: Usually, that would be: struct V { int x; mixin assign!"+" a; mixin assign!"-" b; alias opOpAssign = a.opOpAssign; alias opOpAssign = b.opOpAssign; } However, I can't seem to get that working. It seems to

Re: another question on hidden mixin names

2020-09-17 Thread Simen Kjærås via Digitalmars-d-learn
On Thursday, 17 September 2020 at 21:05:59 UTC, 60rntogo wrote: struct V { int x; mixin assign!"+"; // mixin assign!"-"; } However, if I uncomment the second mixin, there is an error "v is not a scalar, it is a V". I guess I somehow need to merge these overloads, but I don't know how.

another question on hidden mixin names

2020-09-17 Thread 60rntogo via Digitalmars-d-learn
I suspect that this is similar to the issue I asked about here: https://forum.dlang.org/post/vukxaqprjbyrdpiou...@forum.dlang.org, but I can't figure it out. This compiles: --- private mixin template assign(string op_) { ref auto opOpAssign(string op, this RHS)(RHS rhs) if (op == op_) {

Re: Newbie question: Return a locally allocated variable

2020-09-14 Thread Fitz via Digitalmars-d-learn
On Monday, 14 September 2020 at 16:44:14 UTC, Adam D. Ruppe wrote: This is a common mistake with people coming from C++. A D class is more like a Java class - it is automatically a reference. So your class Bob here in D would actually be represented as `Bob*` in C++. Thus when you define

Re: Newbie question: Return a locally allocated variable

2020-09-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 14 September 2020 at 16:29:11 UTC, Fitz wrote: I expect the following code below to create 10 items with 10 different addresses, instead they all have the same address? You are taking the address of the local variable holding reference, not the reference itself. class Bob { }

Newbie question: Return a locally allocated variable

2020-09-14 Thread Fitz via Digitalmars-d-learn
I expect the following code below to create 10 items with 10 different addresses, instead they all have the same address? import std.stdio; class Bob { } void main() { for (auto i = 0; i < 10; i++) { auto pBob = bobFactory(); writefln("bob @ %x\n", pBob); } } Bob

Re: Vibe-D File Question

2020-09-12 Thread Selim Ozel via Digitalmars-d-learn
On Friday, 11 September 2020 at 13:03:16 UTC, James Blachly wrote: On 9/11/20 7:28 AM, Daniel Kozak wrote: void fun(HTTPServerRequest req, HTTPServerResponse res) nothrow { try { res.headers["Content-Disposition"] = "filename=\"muj.csv\""; res.writeBody("some;csv;data", "text/csv"); } catch

Re: Vibe-D File Question

2020-09-11 Thread James Blachly via Digitalmars-d-learn
On 9/11/20 7:28 AM, Daniel Kozak wrote: void fun(HTTPServerRequest req, HTTPServerResponse res) nothrow { try { res.headers["Content-Disposition"] = "filename=\"muj.csv\""; res.writeBody("some;csv;data", "text/csv"); } catch (Exception e) {} } Selim, note the Content-Disposition header in

Re: Vibe-D File Question

2020-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Fri, Sep 11, 2020 at 1:15 PM Daniel Kozak wrote: > On Fri, Sep 11, 2020 at 1:10 PM Selim Ozel via Digitalmars-d-learn < > digitalmars-d-learn@puremagic.com> wrote: > >> It seems like rejected-software forum is flooded with spam, so I >> decided to ask it here. Is there a way to generate a

Re: Vibe-D File Question

2020-09-11 Thread Daniel Kozak via Digitalmars-d-learn
On Fri, Sep 11, 2020 at 1:10 PM Selim Ozel via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: > It seems like rejected-software forum is flooded with spam, so I > decided to ask it here. Is there a way to generate a file -csv > for example- on the back-end and serve it to the

Vibe-D File Question

2020-09-11 Thread Selim Ozel via Digitalmars-d-learn
It seems like rejected-software forum is flooded with spam, so I decided to ask it here. Is there a way to generate a file -csv for example- on the back-end and serve it to the front-end as a file. Serve static file [1] function does this for files saved on the disk. I want to be able to

Re: Question about UDAs

2020-08-03 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Aug 03, 2020 at 08:16:57PM -0700, Ali Çehreli via Digitalmars-d-learn wrote: [...] > UDAs were added to D by a request from Manu Evans and that's when I > learned them. In one of Manu's use cases they would put a @Tweakable > attribute to certain struct members. The effect of that

Re: Question about UDAs

2020-08-03 Thread Ali Çehreli via Digitalmars-d-learn
On 8/2/20 8:00 PM, Cecil Ward wrote: > Ali Çehreli’s book mentions them briefly with an example > but that doesn’t seem to qualify as a realistic use-case. The XML example I chose there qualifies as serialization like H. S. Teoh mentions. UDAs on user-defined type members are for marking them

Re: Question about UDAs

2020-08-03 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Aug 03, 2020 at 03:00:08AM +, Cecil Ward via Digitalmars-d-learn wrote: > When practically speaking would you use UDAs? A real-world use-case? There are probably more use cases than this, but for me, their primary usefulness is in declarative programming and compile-time

Re: Question about UDAs

2020-08-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 3 August 2020 at 03:00:08 UTC, Cecil Ward wrote: When practically speaking would you use UDAs? A real-world use-case? They are useful when you want to attach some kind of metadata to the declarations for a library to read. For example, my script.d looks for `@scriptable` for

Question about UDAs

2020-08-02 Thread Cecil Ward via Digitalmars-d-learn
When practically speaking would you use UDAs? A real-world use-case? I’ve seen them in use already for core language features instead of keywords like "pure", and I suppose this choice keeps the number of keywords down and the result is perhaps easier to extend. The motivation for these usages

Re: Question about publishing a useful function I have written

2020-07-15 Thread Andre Pany via Digitalmars-d-learn
On Wednesday, 15 July 2020 at 09:31:27 UTC, Cecil Ward wrote: On Tuesday, 14 July 2020 at 23:10:28 UTC, Max Haughton wrote: On Tuesday, 14 July 2020 at 21:58:49 UTC, Cecil Ward wrote: I have written something which may or may not be novel and I’m wondering about how to distribute it to as many

Re: Question about publishing a useful function I have written

2020-07-15 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-07-14 23:58, Cecil Ward wrote: What’s the best way to publish a D routine ? As others have already said, on GitHub. Then as a Dub package as well [1]. [1] https://code.dlang.org -- /Jacob Carlborg

Re: Question about publishing a useful function I have written

2020-07-15 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 15 July 2020 at 02:25:42 UTC, 9il wrote: On Tuesday, 14 July 2020 at 21:58:49 UTC, Cecil Ward wrote: Does anyone know if this has already been published by someone else? https://github.com/libmir/mir-core/blob/master/source/mir/utility.d#L29 We test LDC and DMC. CI needs

Re: Question about publishing a useful function I have written

2020-07-15 Thread Cecil Ward via Digitalmars-d-learn
On Tuesday, 14 July 2020 at 23:10:28 UTC, Max Haughton wrote: On Tuesday, 14 July 2020 at 21:58:49 UTC, Cecil Ward wrote: I have written something which may or may not be novel and I’m wondering about how to distribute it to as many users as possible, hoping others will find it useful. What’s

Re: Question about publishing a useful function I have written

2020-07-14 Thread 9il via Digitalmars-d-learn
On Tuesday, 14 July 2020 at 21:58:49 UTC, Cecil Ward wrote: Does anyone know if this has already been published by someone else? https://github.com/libmir/mir-core/blob/master/source/mir/utility.d#L29 We test LDC and DMC. CI needs an update to be actually tested with GDC.

Re: Question about publishing a useful function I have written

2020-07-14 Thread Max Haughton via Digitalmars-d-learn
On Tuesday, 14 July 2020 at 21:58:49 UTC, Cecil Ward wrote: I have written something which may or may not be novel and I’m wondering about how to distribute it to as many users as possible, hoping others will find it useful. What’s the best way to publish a D routine ? [...] GitHub is the

Question about publishing a useful function I have written

2020-07-14 Thread Cecil Ward via Digitalmars-d-learn
I have written something which may or may not be novel and I’m wondering about how to distribute it to as many users as possible, hoping others will find it useful. What’s the best way to publish a D routine ? It is called void assume( bool condition ) nothrow nogc safe for example:

Re: scope guard question

2020-07-01 Thread Simen Kjærås via Digitalmars-d-learn
On Tuesday, 30 June 2020 at 12:18:14 UTC, Steven Schveighoffer wrote: I can see where it would be confusing, and it could probably contain an example and clarification. https://issues.dlang.org/show_bug.cgi?id=20997

Re: scope guard question

2020-06-30 Thread Arjan via Digitalmars-d-learn
On Tuesday, 30 June 2020 at 12:18:14 UTC, Steven Schveighoffer wrote: On 6/30/20 2:56 AM, Arjan wrote: On Monday, 29 June 2020 at 22:47:16 UTC, Steven Schveighoffer wrote: [...] Thanks for the assurance. The spec does state it like this: ``` The ScopeGuardStatement executes

Re: scope guard question

2020-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/20 2:56 AM, Arjan wrote: On Monday, 29 June 2020 at 22:47:16 UTC, Steven Schveighoffer wrote: Yes. The return statement is inside the scope of the function, so it runs before the scope is exited. Are you saying the spec doesn't say that? Thanks for the assurance. The spec does state

Re: scope guard question

2020-06-30 Thread Arjan via Digitalmars-d-learn
On Monday, 29 June 2020 at 22:47:16 UTC, Steven Schveighoffer wrote: Yes. The return statement is inside the scope of the function, so it runs before the scope is exited. Are you saying the spec doesn't say that? Thanks for the assurance. The spec does state it like this: ``` The

Re: scope guard question

2020-06-29 Thread Stanislav Blinov via Digitalmars-d-learn
On Monday, 29 June 2020 at 22:31:12 UTC, Arjan wrote: So when no inner scope is present, the scope exit 'runs' after the return? Is that indeed expected behavior according to the specification? Yes. A scope ends at the '}'. Destructors and scope guards execute then, after the return.

Re: scope guard question

2020-06-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/29/20 6:31 PM, Arjan wrote: ``` void main() {   import std.stdio;   auto f = (){     string[] t;     { // inner scope   t ~= "hello";   scope( exit ) t ~= "world";     } // inner scope exit     return t;   };   f().writeln; // ["hello", "world"] } ``` removing the inner

scope guard question

2020-06-29 Thread Arjan via Digitalmars-d-learn
``` void main() { import std.stdio; auto f = (){ string[] t; { // inner scope t ~= "hello"; scope( exit ) t ~= "world"; } // inner scope exit return t; }; f().writeln; // ["hello", "world"] } ``` removing the inner scope in f() gives ["hello"] So when no

Re: Template type deduction question

2020-05-21 Thread data pulverizer via Digitalmars-d-learn
On Thursday, 21 May 2020 at 07:16:11 UTC, Basile B. wrote: The problem is that "K" is a template type parameter [1]. When the compiler deduces the parameter that ends up with a symbol, i.e not a type. To permit a symbol to be deduced you can use a template alias parameter[2] instead: ---

Re: Template type deduction question

2020-05-21 Thread Basile B. via Digitalmars-d-learn
On Thursday, 21 May 2020 at 07:16:11 UTC, Basile B. wrote: On Thursday, 21 May 2020 at 04:46:02 UTC, data pulverizer wrote: I'd like to pass kernel functions using: ``` auto calculateKernelMatrix(K, T)(K!(T) Kernel, Matrix!(T) data) { ... } ``` and call it using

Re: Template type deduction question

2020-05-21 Thread Basile B. via Digitalmars-d-learn
On Thursday, 21 May 2020 at 04:46:02 UTC, data pulverizer wrote: I'd like to pass kernel functions using: ``` auto calculateKernelMatrix(K, T)(K!(T) Kernel, Matrix!(T) data) { ... } ``` and call it using `calculateKernelMatrix(myKernel, myData);` but I get a type deduction error and have

Template type deduction question

2020-05-20 Thread data pulverizer via Digitalmars-d-learn
I'd like to pass kernel functions using: ``` auto calculateKernelMatrix(K, T)(K!(T) Kernel, Matrix!(T) data) { ... } ``` and call it using `calculateKernelMatrix(myKernel, myData);` but I get a type deduction error and have to call it using `calculateKernelMatrix!(typeof(myKernel),

Re: Probably a trivial question regarding version identifier and unittest

2020-05-11 Thread WhatMe Worry via Digitalmars-d-learn
On Tuesday, 12 May 2020 at 02:17:36 UTC, Adam D. Ruppe wrote: On Tuesday, 12 May 2020 at 01:54:49 UTC, WhatMeWorry wrote: [...] The unittest {} block is actually a special syntax for a function. So the main function in here is a *nested* function inside the unittest function and thus

Re: Probably a trivial question regarding version identifier and unittest

2020-05-11 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 May 2020 at 01:54:49 UTC, WhatMeWorry wrote: version(demos) unittest { import arsd.terminal; void main() Shouldn't the version identifier demos and the unittest option activate the test block and therefore defines main() which then give the "Start Address"? The

Re: Probably a trivial question regarding version identifier and unittest

2020-05-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/11/20 9:54 PM, WhatMeWorry wrote: I'm trying to study Adam Ruppe's terminal.d sub-package and I see the following code segment: version(demos) unittest {     import arsd.terminal;     void main()     {     // . . .     }     main; // exclude from docs } Looks like a good

Probably a trivial question regarding version identifier and unittest

2020-05-11 Thread WhatMeWorry via Digitalmars-d-learn
I'm trying to study Adam Ruppe's terminal.d sub-package and I see the following code segment: version(demos) unittest { import arsd.terminal; void main() { // . . . } main; // exclude from docs } Looks like a good baby step to take, so in the command line I

Re: CTFE and Static If Question

2020-05-07 Thread jmh530 via Digitalmars-d-learn
On Thursday, 7 May 2020 at 17:59:30 UTC, Paul Backus wrote: On Thursday, 7 May 2020 at 15:00:18 UTC, jmh530 wrote: Does foo!y0(rt) generate the same code as foo(rt, y0)? How is the code generated by foo(rt, x0) different from foo(rt,y0)? You can look at the generated code using the Compiler

Re: CTFE and Static If Question

2020-05-07 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, May 07, 2020 at 05:34:21PM +0200, ag0aep6g via Digitalmars-d-learn wrote: [...] > Compared with LDC and GDC, DMD has a poor optimizer, [...] DMD's optimizer is the whipping boy around here, but to be fair, it is poor only when it comes to aggrssive inlining and optimizing loops. Other

Re: CTFE and Static If Question

2020-05-07 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 7 May 2020 at 15:00:18 UTC, jmh530 wrote: Does foo!y0(rt) generate the same code as foo(rt, y0)? How is the code generated by foo(rt, x0) different from foo(rt,y0)? You can look at the generated code using the Compiler Explorer at d.godbolt.org. Here's a link to your example,

Re: CTFE and Static If Question

2020-05-07 Thread jmh530 via Digitalmars-d-learn
On Thursday, 7 May 2020 at 15:34:21 UTC, ag0aep6g wrote: [snip] The `static if` is guaranteed to be evaluated during compilation. That means, `foo!y0` effectively becomes this: auto foo(int rt) { return rt + 1; } There is no such guarantee for `foo(rt, y0)`. It doesn't matter that y0

Re: CTFE and Static If Question

2020-05-07 Thread jmh530 via Digitalmars-d-learn
On Thursday, 7 May 2020 at 15:29:01 UTC, H. S. Teoh wrote: [snip] You explained things very well, thanks.

Re: CTFE and Static If Question

2020-05-07 Thread ag0aep6g via Digitalmars-d-learn
On 07.05.20 17:00, jmh530 wrote: Does foo!y0(rt) generate the same code as foo(rt, y0)? How is the code generated by foo(rt, x0) different from foo(rt,y0)? auto foo(bool rtct)(int rt) {     static if (rtct)     return rt + 1;     else     return rt; } auto foo(int rt, bool rtct) {

Re: CTFE and Static If Question

2020-05-07 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, May 07, 2020 at 03:00:18PM +, jmh530 via Digitalmars-d-learn wrote: > I am curious how ctfe and static ifs interact. Then you should find this article helpful: https://wiki.dlang.org/User:Quickfur/Compile-time_vs._compile-time > In particular, if an enum bool passed as a

CTFE and Static If Question

2020-05-07 Thread jmh530 via Digitalmars-d-learn
I am curious how ctfe and static ifs interact. In particular, if an enum bool passed as a template parameter or run-time one will turn an if statement into something like a static if statement (perhaps after the compiler optimizes other code away). In the code below, I am a function that takes

Re: Implicit Function Template Instantiation (IFTI) Question

2020-04-27 Thread jmh530 via Digitalmars-d-learn
On Monday, 27 April 2020 at 17:40:06 UTC, Steven Schveighoffer wrote: [snip] Thanks for that. Very detailed. In terms of a use case, we just added a center function to mir [1]. It can take an alias to a function. I wanted to add a check that the arity of the function was 1, but it turned

Re: Implicit Function Template Instantiation (IFTI) Question

2020-04-27 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Apr 27, 2020 at 05:19:35PM +, jmh530 via Digitalmars-d-learn wrote: > When using a template with multiple functions within it, is it > possible to access the underlying functions directly? Yes, but only if the template is not eponymous. > Not sure I am missing anything, but what

Re: Implicit Function Template Instantiation (IFTI) Question

2020-04-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/27/20 1:19 PM, jmh530 wrote: When using a template with multiple functions within it, is it possible to access the underlying functions directly? Not sure I am missing anything, but what works when the functions are named differently from the headline template doesn't work when the

Implicit Function Template Instantiation (IFTI) Question

2020-04-27 Thread jmh530 via Digitalmars-d-learn
When using a template with multiple functions within it, is it possible to access the underlying functions directly? Not sure I am missing anything, but what works when the functions are named differently from the headline template doesn't work when the functions are named the same. import

Re: Wired question related with Chinese characters

2020-03-31 Thread walker via Digitalmars-d-learn
On Sunday, 29 March 2020 at 10:36:53 UTC, lovemini wrote: import std.stdio; void main() { version( Windows ) { //直接运行中文显示乱码,原因在于Windows控制台默认编码为 936,而D语言输出utf-8 //可以将控制台编码修改为 utf-8,命令为 "CHCP 65001" //修改后就可以显示中文了 import

Re: A question about C++ interop

2020-03-29 Thread YD via Digitalmars-d-learn
On Sunday, 29 March 2020 at 17:32:59 UTC, kinke wrote: On Sunday, 29 March 2020 at 15:20:52 UTC, YD wrote: So what do I need to declare in the D file for it to match the library entry? Thanks! This is similar to https://issues.dlang.org/show_bug.cgi?id=19260, and can be worked around the

Re: A question about C++ interop

2020-03-29 Thread kinke via Digitalmars-d-learn
On Sunday, 29 March 2020 at 15:20:52 UTC, YD wrote: So what do I need to declare in the D file for it to match the library entry? Thanks! This is similar to https://issues.dlang.org/show_bug.cgi?id=19260, and can be worked around the same way by messing manually with the mangled name, if

Re: A question about C++ interop

2020-03-29 Thread YD via Digitalmars-d-learn
On Sunday, 29 March 2020 at 15:20:52 UTC, YD wrote: On Sunday, 29 March 2020 at 01:50:24 UTC, evilrat wrote: [...] Thanks, dummy placeholder works. But there is a new problem on Windows, let's say there are two classes in C++: [...] Actually I found that if I create a C wrapper like

Re: A question about C++ interop

2020-03-29 Thread YD via Digitalmars-d-learn
On Sunday, 29 March 2020 at 01:50:24 UTC, evilrat wrote: ... Same here, STL bindings is not yet finished. If you don't need that method specifically, just replace it with a dummy. Or make your own bindings. Thanks, dummy placeholder works. But there is a new problem on Windows, let's say

Re: Wired question related with Chinese characters

2020-03-29 Thread lovemini via Digitalmars-d-learn
import std.stdio; void main() { version( Windows ) { //直接运行中文显示乱码,原因在于Windows控制台默认编码为 936,而D语言输出utf-8 //可以将控制台编码修改为 utf-8,命令为 "CHCP 65001" //修改后就可以显示中文了 import core.sys.windows.windows; SetConsoleCP(65001);

Re: Wired question related with Chinese characters

2020-03-29 Thread lovemini via Digitalmars-d-learn
On Sunday, 22 March 2020 at 15:19:13 UTC, walker wrote: I am new to dlang, I like it :) I am on windows10 and use the terminal preview to test and run programs. In order to print Chinese characters correctly, I always use void main() { string var1 = "你好"; # to!string(in_other_conditions)

Re: A question about C++ interop

2020-03-28 Thread evilrat via Digitalmars-d-learn
On Saturday, 28 March 2020 at 19:14:38 UTC, YD wrote: Hi, now I have a further question: when the C++ class A actually has a method that looks like virtual void get_info(std::string ) const = 0; in order to preserve the virtual function table layout (I found that if I omit

Re: A question about C++ interop

2020-03-28 Thread YD via Digitalmars-d-learn
o a C interface (using a void *), and interface to the wrapped-up C library through D, it will work fine. So what am I doing wrong here? Thanks! Classes in D are always passed by reference. Try dropping the pointer in the `create` method: static A create(); Hi, now I have a further quest

Re: A question about C++ interop

2020-03-28 Thread YD via Digitalmars-d-learn
On Saturday, 28 March 2020 at 07:33:38 UTC, Jacob Carlborg wrote: On 2020-03-27 20:17, YD wrote: [...] Classes in D are always passed by reference. Try dropping the pointer in the `create` method: static A create(); Thanks! I got it to work for now.

Re: A question about C++ interop

2020-03-28 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-03-27 20:17, YD wrote: Hi, I have a C++ header file which looks like     class A {     public:     static A *create();     virtual int f() const = 0;     }; And there is a C++ library file which provides the implementation, so that if I write a C++ program and call    

A question about C++ interop

2020-03-27 Thread YD via Digitalmars-d-learn
Hi, I have a C++ header file which looks like class A { public: static A *create(); virtual int f() const = 0; }; And there is a C++ library file which provides the implementation, so that if I write a C++ program and call auto *p = A::create(); std::cout

Re: Wired question related with Chinese characters

2020-03-23 Thread walker via Digitalmars-d-learn
On Monday, 23 March 2020 at 01:40:16 UTC, Adam D. Ruppe wrote: Terminal.getline *might* work in my lib, but if there's combining codepoints I'm not sure. You can try it though and let me know if you are already using the lib. I have done a small test and It works. Thank you!

Re: Wired question related with Chinese characters

2020-03-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 23 March 2020 at 01:18:15 UTC, walker wrote: Which function should I use when I read Chinese characters in the terminal? Terminal.getline *might* work in my lib, but if there's combining codepoints I'm not sure. You can try it though and let me know if you are already using the

Re: Wired question related with Chinese characters

2020-03-22 Thread walker via Digitalmars-d-learn
On Sunday, 22 March 2020 at 16:12:34 UTC, Adam D. Ruppe wrote: Thank you! Your arsd.terminal is the first 3rd party module I used, which I use to output colored text on the terminal preview on windows10. I have tried your code above with both string and dstring, It works! Really good!

Re: Wired question related with Chinese characters

2020-03-22 Thread walker via Digitalmars-d-learn
On Sunday, 22 March 2020 at 15:53:29 UTC, Steven Schveighoffer wrote: On windows, the default codepage for the terminal is NOT UTF8. Which means it may not know how to properly deal with your output. Most likely nim is making the terminal use the UTF8 codepage. See more info here:

Re: Wired question related with Chinese characters

2020-03-22 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 22 March 2020 at 15:19:13 UTC, walker wrote: writeln(var1); writeln calls the wrong function for the Windows console. You can kinda hack it by changing the code page like Steven said (which has other bugs though, but works for many cases), or you can call the correct function -

Re: Wired question related with Chinese characters

2020-03-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/22/20 11:19 AM, walker wrote: I am new to dlang, I like it :) I am on windows10 and use the terminal preview to test and run programs. In order to print Chinese characters correctly, I always use void main() { string var1 = "你好"; # to!string(in_other_conditions) writeln(var1); } I tried

Wired question related with Chinese characters

2020-03-22 Thread walker via Digitalmars-d-learn
I am new to dlang, I like it :) I am on windows10 and use the terminal preview to test and run programs. In order to print Chinese characters correctly, I always use void main() { string var1 = "你好"; # to!string(in_other_conditions) writeln(var1); } I tried dstring but not working. Need Help

Re: Question about the $ sign in arrays and strings

2020-02-19 Thread mipri via Digitalmars-d-learn
On Wednesday, 19 February 2020 at 07:49:36 UTC, Namal wrote: oooh... I used str = std.readln(); to get my string and there must have been some other sign, line break or whitespace or something at the end :( Now I understand it, thx That makes sense. readln includes the newline: $ echo

Re: Question about the $ sign in arrays and strings

2020-02-18 Thread Namal via Digitalmars-d-learn
oooh... I used str = std.readln(); to get my string and there must have been some other sign, line break or whitespace or something at the end :( Now I understand it, thx

Re: Question about the $ sign in arrays and strings

2020-02-18 Thread mipri via Digitalmars-d-learn
On Wednesday, 19 February 2020 at 07:04:48 UTC, Namal wrote: Hello, I wanted to remove the lastchar in a string and figured that you can do that wit str = str[0..$-2]; but why is str = str[0..$] and str=str[0..$-1] the same ? Why do you think that they are the same? $ rdmd --eval 'auto

Question about the $ sign in arrays and strings

2020-02-18 Thread Namal via Digitalmars-d-learn
Hello, I wanted to remove the lastchar in a string and figured that you can do that wit str = str[0..$-2]; but why is str = str[0..$] and str=str[0..$-1] the same ?

Re: GtkD on Windows: notes + question

2020-02-11 Thread mark via Digitalmars-d-learn
On Tuesday, 11 February 2020 at 20:49:40 UTC, Ron Tarrant wrote: On Sunday, 9 February 2020 at 13:28:59 UTC, mark wrote: I found a much easier way to get GtkD working on windows than that described in https://gtkdcoding.com/2019/01/11/-introduction-to-gtkDcoding.html Just FYI... I don't

Re: GtkD on Windows: notes + question

2020-02-11 Thread Ron Tarrant via Digitalmars-d-learn
On Sunday, 9 February 2020 at 13:28:59 UTC, mark wrote: I found a much easier way to get GtkD working on windows than that described in https://gtkdcoding.com/2019/01/11/-introduction-to-gtkDcoding.html Just FYI... I don't use dub because I don't have time to understand its foibles well

Re: GtkD on Windows: notes + question

2020-02-10 Thread mark via Digitalmars-d-learn
On Sunday, 9 February 2020 at 14:08:02 UTC, Daniel Kozak wrote: "lflags-windows": ["/SUBSYSTEM:WINDOWS", "/ENTRY:mainCRTStartup"], [snip] Is there a way to avoid the console Window, at least for release builds? Thank you! Your solution I guess is for dub.json. For those using dub.sdl the

Re: GtkD on Windows: notes + question

2020-02-10 Thread mark via Digitalmars-d-learn
On Sunday, 9 February 2020 at 14:08:02 UTC, Daniel Kozak wrote: "lflags-windows": ["/SUBSYSTEM:WINDOWS", "/ENTRY:mainCRTStartup"], [snip] Is there a way to avoid the console Window, at least for release builds? Thank you! Your solution I guess is for dub.json. For those using dub.sdl the

Re: GtkD on Windows: notes + question

2020-02-09 Thread Daniel Kozak via Digitalmars-d-learn
"lflags-windows": ["/SUBSYSTEM:WINDOWS", "/ENTRY:mainCRTStartup"], On Sun, Feb 9, 2020 at 2:30 PM mark via Digitalmars-d-learn wrote: > > I found a much easier way to get GtkD working on windows than > that described in > https://gtkdcoding.com/2019/01/11/-introduction-to-gtkDcoding.html > >

Re: GtkD on Windows: notes + question

2020-02-09 Thread JN via Digitalmars-d-learn
On Sunday, 9 February 2020 at 13:28:59 UTC, mark wrote: I found a much easier way to get GtkD working on windows than that described in https://gtkdcoding.com/2019/01/11/-introduction-to-gtkDcoding.html 1. I downloaded and installed the Gtk3 runtime (the link is on

<    1   2   3   4   5   6   7   8   9   10   >