Error: need this for method of type

2019-10-23 Thread Márcio Martins via Digitalmars-d-learn
Hi! Consider this simplified program: ``` import std.stdio; struct X { void method(int x) { writeln("method called"); } } void main() { X x; foreach (member; __traits(allMembers, X)) { alias method = __traits(getMember, x, member); method(1); } } ``

DLL on LDC

2019-11-11 Thread Márcio Martins via Digitalmars-d-learn
Hi, I am trying to create a simple DLL and a simple app that loads it on Linux with end goal of having it work on MacOS. Everything seems to work fine with DMD, but when I use LDC2 to build the loader, I don't get the `shared static this()` and `~this` called when I `dlopen()` and `dlclose()

Weird compilation error only as static library

2018-09-26 Thread Márcio Martins via Digitalmars-d-learn
Hi! I am getting this error when compiling my code as a static library. It works fine as an executable. I have no idea what's happening. Has someone seen something like this before? What could be different? This is the error: /usr/include/dmd/druntime/import/core/stdc/stdint.d(159,26): Erro

Re: Weird compilation error only as static library

2018-09-28 Thread Márcio Martins via Digitalmars-d-learn
On Friday, 28 September 2018 at 15:24:03 UTC, Andrea Fontana wrote: On Wednesday, 26 September 2018 at 19:08:45 UTC, Márcio Martins wrote: Hi! I am getting this error when compiling my code as a static library. It works fine as an executable. I have no idea what's happening. Has someone seen

Is this a bug?

2018-10-15 Thread Márcio Martins via Digitalmars-d-learn
import std.stdio; void incx(T, Args...)(ref T t) { ++t.x; } static struct Test(T) { T x; } void main() { Test!uint t; t.incx(); // works t.incx!(); // works incx(t);// works t.incx!(1, 2, 3); // what? incx(t, 1, 2, 3); // what?

Re: Is this a bug?

2018-10-15 Thread Márcio Martins via Digitalmars-d-learn
On Monday, 15 October 2018 at 16:46:34 UTC, Steven Schveighoffer wrote: On 10/15/18 12:40 PM, Márcio Martins wrote: import std.stdio; void incx(T, Args...)(ref T t) {     ++t.x; } static struct Test(T) {     T x; } void main() {     Test!uint t;     t.incx();   // works     t.inc

Re: Is this a bug?

2018-10-16 Thread Márcio Martins via Digitalmars-d-learn
On Tuesday, 16 October 2018 at 02:13:21 UTC, Ali Çehreli wrote: On 10/15/2018 01:36 PM, Márcio Martins wrote: > Considering that the declaration is legal, and that the template > parameter deduction works when Args.length == 0, but stops working when > Args.length > 0. For deduction to work, th

Re: Is this a bug?

2018-10-16 Thread Márcio Martins via Digitalmars-d-learn
On Tuesday, 16 October 2018 at 13:09:34 UTC, Steven Schveighoffer wrote: On 10/15/18 4:36 PM, Márcio Martins wrote: [...] Hm... didn't realize that. It seems to me like an odd limitation, but I can see how it's ambiguous. The solution is to double-template: template incx(Args...) { void

LDC2 with -fxray-instrument

2019-01-15 Thread Márcio Martins via Digitalmars-d-learn
Anyone has any idea how to build with LDC and -fxray-instrument? I am running LDC 1.13 on Linux (x64) The XRay section is in the binary, and the compiler-rt is linked in, but when I run the binary with XRAY_OPTIONS="patch_premain=true verbosity=1" in the environment, and I get nothing. No XRay

Re: LDC2 with -fxray-instrument

2019-01-16 Thread Márcio Martins via Digitalmars-d-learn
On Tuesday, 15 January 2019 at 22:51:15 UTC, Johan Engelen wrote: What platform are you on? Linux x64

Re: LDC2 with -fxray-instrument

2019-01-21 Thread Márcio Martins via Digitalmars-d-learn
On Thursday, 17 January 2019 at 00:11:10 UTC, Johan Engelen wrote: On Wednesday, 16 January 2019 at 23:29:45 UTC, Johan Engelen wrote: On Wednesday, 16 January 2019 at 22:10:14 UTC, Johan Engelen wrote: On Wednesday, 16 January 2019 at 17:36:31 UTC, Márcio Martins wrote: On Tuesday, 15 January

DMD Callstacks

2017-10-23 Thread Márcio Martins via Digitalmars-d-learn
What is everyone doing to get proper file name and line number info for callstacks with DMD? addr2line just gives me ??:0

Re: DMD Callstacks

2017-10-23 Thread Márcio Martins via Digitalmars-d-learn
On Monday, 23 October 2017 at 12:54:33 UTC, Nicholas Wilson wrote: On Monday, 23 October 2017 at 12:41:09 UTC, Márcio Martins wrote: What is everyone doing to get proper file name and line number info for callstacks with DMD? addr2line just gives me ??:0 What OS, etc? Linux 64-bit (Ubuntu

Issue with traits usability

2018-03-21 Thread Márcio Martins via Digitalmars-d-learn
Hi! How do I get past this? static struct X { int x; private enum T = 1; private alias M = string; } foreach (Member; __traits(allMembers, X)) { pragma(msg, __traits(getProtection, __traits(getMember, X, Member))); } Output: public private c.d(1084): Error: argume

Re: String interpolation

2015-11-10 Thread Márcio Martins via Digitalmars-d-learn
On Tuesday, 10 November 2015 at 11:29:32 UTC, TheFlyingFiddle wrote: On Tuesday, 10 November 2015 at 10:41:52 UTC, tired_eyes wrote: On Tuesday, 10 November 2015 at 10:33:30 UTC, Tobias Pankrath wrote: Ruby: a = 1 b = 4 puts "The number #{a} is less than #{b}" PHP: $a = 1; $b = 4; echo "The nu

Comparison operator overloading

2015-12-06 Thread Márcio Martins via Digitalmars-d-learn
I am writing a generic numerical array struct, and I can't find a way to do element-wise comparison operators. What I had envisioned was something like the following, assuming a, b, c and m are array-like, and all operations return arrays. auto m = (a > b) * a + 15; auto c = a.choose(a > b)^^

Re: Comparison operator overloading

2015-12-07 Thread Márcio Martins via Digitalmars-d-learn
On Monday, 7 December 2015 at 00:43:50 UTC, Ali Çehreli wrote: On 12/06/2015 06:41 AM, Márcio Martins wrote: > auto m = (a > b) * a + 15; > auto c = a.choose(a > b)^^2; What do those operations do? Are you thinking of a special meaning for '>', perhaps common in numerical computations, which

Re: Question about mysql-d Object

2015-12-07 Thread Márcio Martins via Digitalmars-d-learn
On Monday, 7 December 2015 at 14:40:12 UTC, Martin Tschierschke wrote: When I do the following: auto mysql = new Mysql("localhost", 3306, "mt", "", "verwaltung"); auto rows = mysql.query("select field from my_table limit 50"); foreach(row;rows){ writeln(row["field"]);} // second time same l

Conflicting UDA

2016-02-06 Thread Márcio Martins via Digitalmars-d-learn
I came across an issue with UDAs and was wondering if there really is no way or if I just missed something... Basically, my library has an @ignore UDA, which conflicts with vibe.d's vibe.data.serialization. If both mine and vibe's module are imported, DMD will fail with a very non-descriptiv

Re: Conflicting UDA

2016-02-06 Thread Márcio Martins via Digitalmars-d-learn
On Saturday, 6 February 2016 at 15:01:44 UTC, Marc Schütz wrote: On Saturday, 6 February 2016 at 13:36:32 UTC, Márcio Martins wrote: [...] `@(mylib.ignore)` should work. You could open an enhancement request to enable the paren-less syntax. Thanks, that does work indeed and is not that verb

Re: Odd Destructor Behavior

2016-02-07 Thread Márcio Martins via Digitalmars-d-learn
On Sunday, 7 February 2016 at 21:49:24 UTC, Matt Elkins wrote: I've been experiencing some odd behavior, where it would appear that a struct's destructor is being called before the object's lifetime expires. More likely I am misunderstanding something about the lifetime rules for structs. I hav

Re: String compare in words?

2016-05-30 Thread Márcio Martins via Digitalmars-d-learn
On Monday, 30 May 2016 at 09:28:29 UTC, ag0aep6g wrote: On 05/29/2016 10:40 PM, qznc wrote: bool string_cmp_opt(immutable(ubyte)[] x, immutable(ubyte)[] y) { Having "string" in the function name may be a bit misleading. This doesn't have any special functionality for text/characters/Unicode,

Overloads

2016-06-26 Thread Márcio Martins via Digitalmars-d-learn
Consider this snippet: struct X { int foo(Args...)(Args args) if (Args.length > 1) { return Args.length; } int foo() { return 0; } int foo(int y) { return 1; } alias Name = string; int field_; } void listMembers(T)(ref T x) { foreach (Member; __traits(derivedMembers, T)) {