Re: Issues with std.net.curl on Win 10 x64

2019-03-25 Thread Boris Carvajal via Digitalmars-d-learn
On Monday, 25 March 2019 at 16:25:37 UTC, cptgrok wrote: Am I doing something wrong or is there some issue with curl or something else? I'm pretty new to D and I'm not sure if I need to go right down to raw sockets and re-invent the wheel or if there is some other library that can help. If I

Re: How to mixin finction name?

2019-04-14 Thread Boris Carvajal via Digitalmars-d-learn
On Sunday, 14 April 2019 at 10:07:30 UTC, Andrey wrote: Create some function in loop and use it. But I don't know how to mixin names? import std.stdio; void main() { enum letters = ['A', 'B', 'C']; static foreach(ch; letters) { mixin("void print" ~ ch ~ "(uint i) {

Re: How to mixin finction name?

2019-04-14 Thread Boris Carvajal via Digitalmars-d-learn
On Sunday, 14 April 2019 at 12:00:38 UTC, Andrey wrote: On Sunday, 14 April 2019 at 11:44:16 UTC, Boris Carvajal wrote: On Sunday, 14 April 2019 at 10:07:30 UTC, Andrey wrote: I want to mixin only name - not the full function code. I think you can't do a partial statement in a mixin. But

Re: Windows segfault, need brief help

2019-07-13 Thread Boris Carvajal via Digitalmars-d-learn
On Friday, 12 July 2019 at 22:46:11 UTC, Anonymouse wrote: I'm suddenly getting segfaults when running tests on Windows. It works fine on Linux. I reduced it to a few lines (plus a dependency) with dustmite, but they don't really make sense[1]. Nevertheless they do trigger the segfault. Can

Re: Windows segfault, need brief help

2019-07-14 Thread Boris Carvajal via Digitalmars-d-learn
On Saturday, 13 July 2019 at 16:39:51 UTC, Anonymouse wrote: Thank you! Filed as https://issues.dlang.org/show_bug.cgi?id=20048. https://github.com/dlang/druntime/pull/2675

Re: OPTLINK : Warning 9: Unknown Option : OUT

2019-07-16 Thread Boris Carvajal via Digitalmars-d-learn
On Tuesday, 16 July 2019 at 09:07:03 UTC, Anonymouse wrote: This works for the reduced test program but not for my whole project. If you wouldn't mind trying it: git clone https://github.com/zorael/kameloso.git && cd kameloso && dub test (Windows 10, dmd 2.087 with your sed substitution)

Re: OPTLINK : Warning 9: Unknown Option : OUT

2019-07-15 Thread Boris Carvajal via Digitalmars-d-learn
On Monday, 15 July 2019 at 11:48:13 UTC, Anonymouse wrote: I built it with: dub fetch digger dub run digger -- build "stable + druntime#2675" I have not touched any digger.ini. The only one I can find is digger.ini.sample. sc.ini and dub output at: https://pastebin.com/jPnh4yEA dub test

Re: Function called twice

2019-08-02 Thread Boris Carvajal via Digitalmars-d-learn
On Friday, 2 August 2019 at 21:44:28 UTC, Jordan Wilson wrote: Hello, I don't quite understand why isEven is called twice in the 2nd example? auto isEven(int n) { n.writeln; return (n % 2) == 0; } void main() { auto z = [1,2,3]; // outputs 1 2 3

Re: Throwing from a lambda isn't supported by the compiler

2019-09-09 Thread Boris Carvajal via Digitalmars-d-learn
On Monday, 9 September 2019 at 09:14:08 UTC, Andre Pany wrote: Hi, I noticed, that I cannot throw from the lambda expression: Error: expression expected, not throw but have to use the longer syntax () {throw new Exception();} --- void foo(void function() e){} void main() { foo(

Re: Is this a new bug ?

2019-07-20 Thread Boris Carvajal via Digitalmars-d-learn
On Saturday, 20 July 2019 at 09:01:47 UTC, Newbie2019 wrote: On Saturday, 20 July 2019 at 09:01:21 UTC, Newbie2019 wrote: I want to cast std.stdio : writefln into pure function pointer, so I can call it from debug pure function. is there a way to work around the pure check for call writefln

Re: Why does a switch break cause a segmentation fault

2019-07-23 Thread Boris Carvajal via Digitalmars-d-learn
On Tuesday, 23 July 2019 at 08:04:07 UTC, adamgoldberg wrote: On Tuesday, 23 July 2019 at 00:01:09 UTC, Exil wrote: On Monday, 22 July 2019 at 22:05:17 UTC, adamgoldberg wrote: Hey, I just happened to be writing a program in D an stumbled upon a bug, that causes it to terminate after receiving

Re: Why is the fPIC switch missing?

2019-09-23 Thread Boris Carvajal via Digitalmars-d-learn
On Monday, 23 September 2019 at 01:31:03 UTC, Emmanuelle wrote: Hello. My problem is exactly what it says on the title: my dmd (windows 7, x64) doesn't seem to have -fPIC: I think it's not needed. The generated code on Windows is always position independent. Still, DMD should warn about it

Re: How to find what is causing a closure allocation

2019-10-02 Thread Boris Carvajal via Digitalmars-d-learn
On Wednesday, 2 October 2019 at 15:19:43 UTC, John Colvin wrote: I have a function that allocates a closure somewhere in it (as shown by the result of -profile=gc). I can't make the function nogc as it calls a lot of other GC using code. profilegc.log only gives me the line number of the

Re: Vibe.d Error

2019-10-18 Thread Boris Carvajal via Digitalmars-d-learn
On Friday, 18 October 2019 at 08:06:30 UTC, Vino wrote: I tried install vibe.d in SUSE linux 12 SP2 and facing the below error, tried the options as per the link https://github.com/vibe-d/vibe.d/issues/1748, still no luck and the lib's are installed in the server Read the last section of

Re: PHP to D Conversion

2019-10-19 Thread Boris Carvajal via Digitalmars-d-learn
On Saturday, 19 October 2019 at 19:08:45 UTC, Vino wrote: On Friday, 18 October 2019 at 14:56:05 UTC, Andre Pany wrote: On Friday, 18 October 2019 at 09:21:46 UTC, Vino wrote: On Friday, 18 October 2019 at 09:17:24 UTC, Vino wrote: [...] And now getting the error : Program exited with code

Re: Inspecting __traits(isDeprecated) and deprecation warnings

2019-09-25 Thread Boris Carvajal via Digitalmars-d-learn
On Wednesday, 25 September 2019 at 14:20:00 UTC, Anonymouse wrote: I added some deprecations in my project and am going through my templates trying to silence the warnings that suddenly popped up. This template works, but it triggers deprecation warnings when I am actively trying to avoid

Re: Using std.net.curl

2020-02-28 Thread Boris Carvajal via Digitalmars-d-learn
On Saturday, 29 February 2020 at 03:53:37 UTC, David Anderson wrote: I want to capture that text in a variable, but the upload function returns void. How can I get the text returned by the web server to be stored in a variable? import std; auto updata = read("inputfile"); auto dldata =

Re: module ... conflicts with package name ...

2020-02-03 Thread Boris Carvajal via Digitalmars-d-learn
On Monday, 3 February 2020 at 16:35:06 UTC, Steven Schveighoffer wrote: I can't reproduce with a small example. Before I try and go through the process to reduce this, just wanted to see if anyone knows about this. -Steve I've made a few changes to the package.d import code, one is

Re: Assoc array init

2020-02-04 Thread Boris Carvajal via Digitalmars-d-learn
On Tuesday, 4 February 2020 at 07:52:05 UTC, JN wrote: int[int] a = [5: 7]; void main() { } This fails because apparently [5: 7] is a "non-const expression". How? Why? Yes, I know I can just init in a static this() section, but that feels like a bad workaround. AFAIK is not implemented.

Re: How add resource.res in RDMD

2020-02-02 Thread Boris Carvajal via Digitalmars-d-learn
On Monday, 3 February 2020 at 03:03:20 UTC, Marcone wrote: On Sunday, 2 February 2020 at 06:03:06 UTC, Marcone wrote: I like use rdmd when I am programming. But I need that the program use resource file becouse I am creating program with gui win32api. How can I add resource when use rdmd? No

Re: static foreach over enum symbols

2020-02-15 Thread Boris Carvajal via Digitalmars-d-learn
On Friday, 14 February 2020 at 22:24:14 UTC, Ben Jones wrote: Hi all, I'm getting unexpected results while trying to process symbols from a module, some of which are enums. Depending on whether or not I comment out the first static foreach loop below, fullyQualifiedName gives me different

Re: static foreach over enum symbols

2020-02-15 Thread Boris Carvajal via Digitalmars-d-learn
On Friday, 14 February 2020 at 22:24:14 UTC, Ben Jones wrote: Hi all, I'm getting unexpected results while trying to process symbols from a module, some of which are enums. Depending on whether or not I comment out the first static foreach loop below, fullyQualifiedName gives me different

Re: How to get to body of HTTP 500 error with std.net.curl.get()?

2020-02-15 Thread Boris Carvajal via Digitalmars-d-learn
On Friday, 14 February 2020 at 00:24:27 UTC, Gregor Mückl wrote: Hi! I am trying to write a client for pretty... well... creatively designed web API. The server gives HTTP status 500 replies if the requests are malformed, but the actual error message is hidden in the body of the reply (an

Re: template instantiation problems

2020-01-14 Thread Boris Carvajal via Digitalmars-d-learn
On Friday, 10 January 2020 at 18:31:59 UTC, ag0aep6g wrote: import m1 = foo.baz; import m2 = foo; alias p = __traits(parent, m1); pragma(msg, m1.stringof); /* "module baz", ok */ pragma(msg, m2.stringof); /* "module foo", ok */ pragma(msg, p.stringof); /* "package foo", ok */ enum e(alias

Re: Get memory used by current process at specific point in time

2020-01-16 Thread Boris Carvajal via Digitalmars-d-learn
On Sunday, 12 January 2020 at 13:58:18 UTC, Per Nordlöw wrote: Is there a druntime/phobos function for getting the amount of memory (both, stack, malloc, and GC) being used by the current process? At least for the GC I remember using GC.stats and GC.profileStats to get some info.

Re: import/format tools?

2020-01-18 Thread Boris Carvajal via Digitalmars-d-learn
On Saturday, 18 January 2020 at 09:33:34 UTC, mark wrote: Is there a tool that will sort imports (e.g., as per the style guide), and that will also add the specific names used? D-Scanner[1] will warn you about non sorted imports You need to set imports_sortedness="enabled" on your

Re: CTFE and assoc array

2020-01-18 Thread Boris Carvajal via Digitalmars-d-learn
On Saturday, 18 January 2020 at 20:54:20 UTC, Andrey wrote: Hello, Why this doesn't work? import std; struct Qwezzz { shared static this() { qaz = qazMap; } enum qazMap = ["rrr": "vv", "hty": "4ft6"]; static immutable string[string] qaz; } void main() {

Re: Defining an alias to an overloaded function

2020-01-20 Thread Boris Carvajal via Digitalmars-d-learn
On Monday, 20 January 2020 at 22:02:54 UTC, olvy wrote: I'm learning D, and as an exercise, I'm trying to define a HashSet that would be a wrapper around an associative array with some dummy value type. This seems to work: ... struct RangeImpl(T) { alias byKeyRetType =

Re: Linear array to matrix

2020-04-04 Thread Boris Carvajal via Digitalmars-d-learn
On Saturday, 4 April 2020 at 09:25:14 UTC, Giovanni Di Maria wrote: Hi. Is there a Built-in function (no code, only a built-in function) that transform a linear array to a Matrix? For example: From [10,20,30,40,50,60,70,80,90,100,110,120]; To [ [10,20,30], [40,50,60], [70,80,90],

Re: need help to get member function const address

2020-03-19 Thread Boris Carvajal via Digitalmars-d-learn
On Thursday, 19 March 2020 at 04:30:32 UTC, Calvin P wrote: I use this code to get member function address on runtime: = struct A { this(){}; } auto ctor = (&__traits(getMember, A.init,"__ctor")).funcptr; = my question is, how to get it in compile time like static

Re: need help to get member function const address

2020-03-19 Thread Boris Carvajal via Digitalmars-d-learn
On Thursday, 19 March 2020 at 14:43:53 UTC, Steven Schveighoffer wrote: I think this is an invalid limitation, you should file an issue at https://issues.dlang.org essentially, with your sample A struct: const f1 = // OK const f2 = // Error, not constant expression Both these should be

Re: Is it possible to write some class members in another module ?

2020-05-19 Thread Boris Carvajal via Digitalmars-d-learn
On Tuesday, 19 May 2020 at 22:01:03 UTC, Vinod K Chandran wrote: Hi all, Is it possible to write some class members in another module ? I have class with a lot of member variables.(probably 50+) I would like to write them (Not all, but some of them) in a special module for the sake of

Re: Postblit segfault.

2020-06-01 Thread Boris Carvajal via Digitalmars-d-learn
On Monday, 1 June 2020 at 06:35:36 UTC, MaoKo wrote: Hello, I don't understand why this code segfault on Reduced to: import std.stdio; struct S {} void main() { S[1] s; writeln(s); }

Re: Bind C++ class to DLang : undefined reference to `Canvas::Foo()'

2020-07-13 Thread Boris Carvajal via Digitalmars-d-learn
On Monday, 13 July 2020 at 16:17:55 UTC, zoujiaqing wrote: On Monday, 13 July 2020 at 12:57:52 UTC, Adam D. Ruppe wrote: On Monday, 13 July 2020 at 09:34:35 UTC, zoujiaqing wrote: # dmd source/main.d Canvas.o -L-lstdc++ && ./main [1]49078 segmentation fault ./main On my computer I got

Re: final switch problem

2020-06-13 Thread Boris Carvajal via Digitalmars-d-learn
On Saturday, 13 June 2020 at 09:02:21 UTC, John Chapman wrote: Is this a bug or have I made a mistake? This worked a few days ago and I haven't changed my setup since then. https://issues.dlang.org/show_bug.cgi?id=19548 Your code triggers it by using "-debug" option on https://run.dlang.io/

Re: DMD: invalid UTF character `\U0000d800`

2020-11-09 Thread Boris Carvajal via Digitalmars-d-learn
On Sunday, 8 November 2020 at 10:47:34 UTC, Per Nordlöw wrote: Can I just do, for instance, cast(dchar)0xd8000 for `\Ud800` to accomplish this? There's also: dchar(0xd8000)

Re: How to profile compile times of a source code?

2021-01-31 Thread Boris Carvajal via Digitalmars-d-learn
On Sunday, 31 January 2021 at 16:13:24 UTC, Anonymouse wrote: On Sunday, 31 January 2021 at 12:31:59 UTC, Johan Engelen wrote: Try LDC 1.25 (now in beta testing) with --ftime-trace. Clang has the same option, so you can read more about it online in that context. Be sure to check out the

Re: Does is(f == function) work?

2021-03-09 Thread Boris Carvajal via Digitalmars-d-learn
On Tuesday, 9 March 2021 at 11:58:45 UTC, Andrey Zherikov wrote: On Tuesday, 9 March 2021 at 02:57:46 UTC, Adam D. Ruppe wrote: try is(typeof(f) == function) it is kinda weird but that's the trick Thanks! Should it work for in this case as well? alias f = (){};

Re: ioctl to set mixer volume

2021-04-16 Thread Boris Carvajal via Digitalmars-d-learn
On Saturday, 17 April 2021 at 00:05:41 UTC, Alain De Vos wrote: After some fiddling i finally got it. A d-lang program which sets my volume to zero. ``` import std.stdio; import core.sys.posix.ioctl; import core.stdc.config; import core.stdc.stdio; void main() { writeln("Set vol to min"); char

Re: Constructor called instead of opAssign()

2021-02-16 Thread Boris Carvajal via Digitalmars-d-learn
On Sunday, 14 February 2021 at 08:46:34 UTC, frame wrote: The first instance is in A - and why opAssign then works there? Sorry I didn't pay too much attention. It seems the detection of first assignment only happens when the field and constructor have the same parent, so it doesn't work

Re: Constructor called instead of opAssign()

2021-02-14 Thread Boris Carvajal via Digitalmars-d-learn
On Sunday, 14 February 2021 at 07:09:20 UTC, frame wrote: Although x is well initialized by A by calling opAssign(), the compiler doesn't care and calls the S!T ctor() on B again and opAssign() is ignored. Is this a bug or a rule? It's a rule described here:

Re: How can I check if template variable parameter is iterable before handle it?

2021-02-21 Thread Boris Carvajal via Digitalmars-d-learn
On Sunday, 21 February 2021 at 11:58:11 UTC, Marcone wrote: import std; void foo(T)(T bar){ static if (bar.isiterable()) // Need Somethin to check if bar is iterable. { // Execute it if bar is iterable. foreach (i; bar) {