Re: KQueue and Fibers

2021-04-09 Thread Jacob Carlborg via Digitalmars-d-learn
On 2021-04-09 11:00, rashir wrote: Goodmorning everyone, I'm trying to understand both Kqueue and Fiber's operation on Mac. Why don't I get the correct data as long as I read from the socket? It seems to be reading too early, but Kquue tells me that the socket is readable. ```D    const

Re: Gui toolkits alive and gui toolkits dead

2021-04-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2021-04-06 21:57, Alain De Vos wrote: Can we say tk ang gtk toolkits are alive. But wxwidgets , fox an fltk are dead ? Do you mean these libraries in general or D bindings to these libraries? -- /Jacob Carlborg

Re: Contributing CDF bindings to Deimos

2021-03-31 Thread Jacob Carlborg via Digitalmars-d-learn
On 2021-03-25 05:00, Chris Piker wrote: I've attempted to follow all guidelines as best I understood them, but this is my first package.  It likely has some style and functionality issues. There's a general convention to name the top level module or package the same as the project. To avoid

Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-17 Thread Jacob Carlborg via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 15:16:36 UTC, Jacob Carlborg wrote: macOS doesn't support static linking. The proper way to solve this is to bundle the dynamic libraries with the application. If it's a GUI application it can be located in the application bundle. It seems like David already

Re: Is it possible to suppress standard lib and dlang symbols in dylib (macos)

2021-03-17 Thread Jacob Carlborg via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 13:52:48 UTC, Guillaume Piolat wrote: On Sunday, 14 March 2021 at 11:33:00 UTC, David wrote: Anyone else done this? Pointers welcome. Sorry for delay. Just add "dflags-osx-ldc": ["-static"], macOS doesn't support static linking. -- /Jacob Carlborg

Re: lockstep works with .each, but fails with .map

2021-03-05 Thread Jacob Carlborg via Digitalmars-d-learn
On 2021-03-05 19:49, realhet wrote: Why it works with each (or foreach), but not with map? o.O `lockstep` is specifically designed to work with `foreach`. I think `each` has a special case to work with `lockstep`. If you want to use other range functions, you should use `zip` instead of

Re: ldc on a raspberry pi 3 running freebsd

2021-02-26 Thread Jacob Carlborg via Digitalmars-d-learn
On 2021-02-23 16:34, Decabytes wrote: ldc2 is the winner thank you! I'd like to get gdc and dmd up and running to at some point Unfortunately, DMD doesn't support ARM. -- /Jacob Carlborg

Re: How can I get this UDA at compile time?

2021-02-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 2021-02-21 07:12, Jack wrote: I've had a struct like this: struct Attr { string value; } struct Foo { @(Attr("a attr")) enum a = Foo(10); @(Attr("b attr")) enum b = Foo(11); int x; int y; bool doY = true; int value() {     return

Re: Type of string literal concatenated with non-immutable char array

2021-02-01 Thread Jacob Carlborg via Digitalmars-d-learn
On Sunday, 31 January 2021 at 21:48:09 UTC, Per Nordlöw wrote: Given char x[]; why is typeof("a" ~ x) `char[]` when typeof("a" ~ x.idup) is `string`? My case is class NameLookupException : Exception { this(string name) { super("Name " ~ name ~ " could not be

Re: Why are multiple instances of the single enum created?

2021-02-01 Thread Jacob Carlborg via Digitalmars-d-learn
On Monday, 1 February 2021 at 09:40:20 UTC, Per Nordlöw wrote: An enum only exists at compile-time, and does not occupy any space. Each time it's referenced, a new instance of the value is created. Why is that? Seems like a waste of resources to the compiler. It makes perfect sense for

Re: std.expreimantal.allocator deallocate

2021-01-25 Thread Jacob Carlborg via Digitalmars-d-learn
On Sunday, 24 January 2021 at 11:00:17 UTC, vitamin wrote: void destruct(Base base){ void[] x = (cast(void*)base)[0 .. __traits(classInstanceSize, Base)]; writeln("deallocate: ", x.length); theAllocator.deallocate(x); } You can get the dynamic size of an object using

Re: [Understanding] Classes and delegate inheritance vs function pointers

2021-01-09 Thread Jacob Carlborg via Digitalmars-d-learn
On 2021-01-09 19:16, Q. Schroll wrote: Say I have a class hierarchy like this:   class Base { }   class Derived : Base { } A Derived object cannot be referenced as a Base object, but as a const(Base) object. That makes sense to me. It can: Base b = new Derived(); One can replace Base by a

Re: DConf talk : Exceptions will disappear in the future?

2021-01-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2021-01-07 01:01, sighoya wrote: Thanks, reminds on swift error types which are enum cases. Swift can throw anything that implements the Error protocol. Classes, structs and enums can implement protocols. Oh, no please not. Interestingly we don't use longjmp in default exception

Re: DConf talk : Exceptions will disappear in the future?

2021-01-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2021-01-06 22:27, H. S. Teoh wrote: That's the whole point of Sutter's proposal: they are all unified with the universal Error struct. There is only one "backend": normal function return values, augmented as a tagged union to distinguish between normal return and error return. We are

Re: dmd 2.093.1: duplicate method definitions ignored altogether

2021-01-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2021-01-05 03:02, kdevel wrote: expected output: none. The compiler should have rejected the code after the duplicate definition def #2. dmd 2.093.1 ignores both definitions instead. Is this a bug or a bug? DMD 2.095.0 now reports an error for this. -- /Jacob Carlborg

Re: How to store a pointer to class contructor

2020-12-25 Thread Jacob Carlborg via Digitalmars-d-learn
On Thursday, 24 December 2020 at 10:23:09 UTC, Dmitriy Asondo wrote: I expect code like this: -- class OloloService {} class BlablaService {} auto servicesList = [OloloService, BlablaService]; auto serviceInstance = new servicesList[1](args); --

Re: extern(C) and name mangling

2020-12-16 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-12-16 16:18, Dave P. wrote: Is this a bug in the spec or in the implementation? Yeah, that's a good question. That's always problematic with D. The spec is incomplete. How do we get this fixed? The simplest would be to change the spec. -- /Jacob Carlborg

Re: extern(C) and name mangling

2020-12-15 Thread Jacob Carlborg via Digitalmars-d-learn
On Wednesday, 16 December 2020 at 04:17:13 UTC, Mike Parker wrote: So what you're asking for is a way to retain the D name mangling on an extern C function. The way to do that is with `pragma(mangle, "new_name")`. To match the original D function mangling, declare the function first without

Re: extern(C) and name mangling

2020-12-15 Thread Jacob Carlborg via Digitalmars-d-learn
On Wednesday, 16 December 2020 at 04:17:13 UTC, Mike Parker wrote: However, the D calling convention is defined to be identical to the C calling convention on the host system for everything except Windows x86. Also keep in mind that D supports other types than C does, like D arrays and

Re: extern(C) and name mangling

2020-12-15 Thread Jacob Carlborg via Digitalmars-d-learn
On Wednesday, 16 December 2020 at 04:17:13 UTC, Mike Parker wrote: However, the D calling convention is defined to be identical to the C calling convention on the host system for everything except Windows x86. That's what's specified, but that's not how DMD actually behaves. DMD passes the

Re: Hex constant method starts from ".a": 0xCCCCCC.argb

2020-12-14 Thread Jacob Carlborg via Digitalmars-d-learn
On Monday, 14 December 2020 at 05:51:28 UTC, Виталий Фадеев wrote: It's parsing the `.a` in `.argb` as part of the number: auto color = 0x00AABBCC.a rgb; // what the compiler sees You can fix it with parentheses: auto color = (0x00AABBCC).argb; Thanks! It is not perfect, but also beauty!

Re: Request assistance initializing struct instance at global scope

2020-12-08 Thread Jacob Carlborg via Digitalmars-d-learn
On Tuesday, 8 December 2020 at 01:47:51 UTC, Andrew Edwards wrote: Thanks Jacob. The extern(C) is temporary. I'm doing a direct port of the code to D using -betterC. Wanted to keep it as close to the original as possible until everything compiles. Yes, that's always a good idea. Do the

Re: Request assistance initializing struct instance at global scope

2020-12-07 Thread Jacob Carlborg via Digitalmars-d-learn
On Monday, 7 December 2020 at 04:13:16 UTC, Andrew Edwards wrote: Given: === extern(C): char*[] hldr; enum I = (1<<0); struct S { char* ft; char** fm; int f; } void main(){} === // Error Deprecation: static constructor can only be of D linkage S[] s; static this() {

Re: Ways to parse D code.

2020-11-26 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-11-25 17:27, Jan Hönig wrote: dmd has to do it somewhere as well. Although I don't know exactly where. I do know ldc uses dmd's frontend for parsing. https://dlang.org/phobos/dmd_parse.html Using DMD as a library will be most accurate and up to date. Because it's the same code as

Re: How can I convert Hexadecimal to RGB Color and vice-versa?

2020-11-24 Thread Jacob Carlborg via Digitalmars-d-learn
On Friday, 16 October 2020 at 20:10:58 UTC, Marcone wrote: How can I convert Hexadecimal to RGB Color and vice-versa? Not sure if this is what you're looking for: struct Color { private uint hex; int red() out(result; result >= 0 && result <= 255) // assert that the result is

Re: betterC question

2020-11-19 Thread Jacob Carlborg via Digitalmars-d-learn
On Thursday, 19 November 2020 at 00:20:50 UTC, Dibyendu Majumdar wrote: On Thursday, 19 November 2020 at 00:18:54 UTC, rikki cattermole You don't need the brackets to call a function (and with a little help from UFCS): void main() { import std.stdio;

Re: question as to when a new command gets executed

2020-11-10 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-11-11 06:29, WhatMeWorry wrote: Which begs the question, how would the statement, m_State = new BreakState() ever get executed? class DebuggerSession {     private BreakState m_State = new BreakState();     private UnrealCallback m_UnrealCallback;     this( )     {     }     //

Re: How add class or struct member after construction?

2020-11-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-11-05 23:48, Marcone wrote: How add class or struct member after construction? Is it possible in D? How? It depends on what needs you have. You can declare a free function that takes the class/struct as the first parameter and call it like a method [1]: class Foo { int a; }

Re: DMD: invalid UTF character `\U0000d800`

2020-11-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-11-08 13:39, Kagamin wrote: Surrogate pairs are used in rules because java strings are utf-16 encoded, it doesn't make much sense for other encodings. D supports the UTF-16 encoding as well. The compiler doesn't accept the surrogate pairs even for UTF-16 strings. -- /Jacob Carlborg

Re: DMD: invalid UTF character `\U0000d800`

2020-11-07 Thread Jacob Carlborg via Digitalmars-d-learn
On Saturday, 7 November 2020 at 16:12:06 UTC, Per Nordlöw wrote: CtoLexer_parser.d 665 57 error invalid UTF character \Ud800 CtoLexer_parser.d 665 67 error invalid UTF character \Udbff CtoLexer_parser.d 666 28 error invalid UTF character

Re: why `top` report is not consistent with the memory freed by core.stdc.stdlib : free?

2020-11-06 Thread Jacob Carlborg via Digitalmars-d-learn
On Friday, 6 November 2020 at 06:17:42 UTC, mw wrote: https://wiki.dlang.org/Memory_Management#Explicit_Class_Instance_Allocation using core.stdc.stdlib : malloc and free to manually manage memory, I tested two scenarios: -- malloc & free -- malloc only and I use Linux command `top` to

Re: Does dmd's -i "include imported modules in the compilation" switch generate object files?

2020-11-04 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-11-03 20:02, H. S. Teoh wrote: I believe -i behaves as though you manually typed the names of the source files on the command line. So it would do what the compiler would usually do in the latter case. Yes, this is correct. AFAIK, that means it loads everything into memory and

Re: synthesising instantiated template parameters and arguments

2020-10-29 Thread Jacob Carlborg via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 05:51:14 UTC, Nicholas Wilson wrote: but for a templated C this is tricker as I can't use a template sequence parameter (...) unless C uses it in the same position (I'm trying to generate a mangle from it so it needs to be exact). Given class

Re: Dynamic Template-Expansion of (Token) Strings

2020-10-27 Thread Jacob Carlborg via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 08:33:08 UTC, Per Nordlöw wrote: I'm looking for elegant ways of expressing expansion of parameterized strings written to a file at run-time. My primary use case is run-time generation of D code. In the lazy case, something like import std.file : write;

Re: this T / variadic template and interfaces

2020-10-27 Thread Jacob Carlborg via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 09:40:33 UTC, frame wrote: Hmm, a question of design. Is there also a convenient way to pass the arguments to a template or get a Variant[] from it? Convenient, no not that I know of. You can use a type safe variadic function that takes Variant, if you want to

Re: this T / variadic template and interfaces

2020-10-26 Thread Jacob Carlborg via Digitalmars-d-learn
On Monday, 26 October 2020 at 11:14:47 UTC, frame wrote: Is there any way to get this working? I know, I could use a known object to feed the arguments and use that instead - but I want to keep things simple as possible. As Simen mentioned, templates cannot be virtual. But you don't need to

Re: Template pattern delegate?

2020-10-26 Thread Jacob Carlborg via Digitalmars-d-learn
On Monday, 26 October 2020 at 00:56:26 UTC, frame wrote: I see that your approach can handle functions and delegates but isn't that not equivalent like this template for a function? auto myStuff(T)(T function() fn) { try { return fn(); } catch (Exception e) { //

Re: Can we do compile time reading part of a file using import?

2020-10-26 Thread Jacob Carlborg via Digitalmars-d-learn
On Sunday, 25 October 2020 at 16:50:09 UTC, Jack wrote: Which build tool are you refering to? an existing one or build one oneself to do this job? It should work with any build tool that has hooks to execute arbitrary commands. -- /Jacob Carlborg

Re: Two ways of receiving arrays on the C ABI

2020-10-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-10-20 02:16, Ali Çehreli wrote: Everything works at least on Linux. Is this kosher, or am I using some internal knowledge? Yes, you're using some internal knowledge. You cannot assume it works on any other platform or architecture. In theory, the D compiler could choose to change

Re: Can we do compile time reading part of a file using import?

2020-10-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-10-23 18:42, data pulverizer wrote: For me it's not make-or-break, it just something very useful and I think has clear use case. Please let me know if there are aspects or alternatives I am missing. You could always have the build tool split up the file in multiple smaller files and

Re: Druntime without pthreads?

2020-10-21 Thread Jacob Carlborg via Digitalmars-d-learn
On Tuesday, 20 October 2020 at 16:58:12 UTC, Severin Teona wrote: Hi guys. I have a curiosity, regarding [1] - I had encountered some "undefined reference" errors when trying to link the druntime (compiled for an embedded architecture) without some implementation of the POSIX thread calls

Re: Escape this in pure members

2020-09-22 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-19 21:50, Per Nordlöw wrote: On Saturday, 19 September 2020 at 18:48:31 UTC, Jacob Carlborg wrote: A nested class seems to be able to escape the `this` reference: Ahh, thanks. I just realized that it can escape into other parameters without the `scope` qualifier? This class

Re: Escape this in pure members

2020-09-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-19 18:07, Per Nordlöw wrote: If an aggregate member is pure but not scope when can it escape the `this` pointer?. Only via return? I'm not sure if returning the `this` pointer is considered escaping it. The caller already had access to it. Under the hood, the `this` pointer is

Re: Good repos to learn D

2020-09-19 Thread Jacob Carlborg via Digitalmars-d-learn
On Saturday, 19 September 2020 at 08:26:36 UTC, Imperatorn wrote: What are some good examples of pretty large/medium size, good structured repos in D? I'm looking for examples to learn from Thanks! Here are some examples of large projects: * DWT [1]. This is one of the largest D projects

Re: DDoc generation

2020-09-19 Thread Jacob Carlborg via Digitalmars-d-learn
On Saturday, 19 September 2020 at 07:43:24 UTC, Russel Winder wrote: Doesn't that then make the whole DDoc system fairly useless, despite it's use in Phobos? If you use Dub, you can run `dub build -b ddox` and it will use Ddox to build the documentation. This will include an index page

Re: DDoc generation

2020-09-19 Thread Jacob Carlborg via Digitalmars-d-learn
On Saturday, 19 September 2020 at 07:43:24 UTC, Russel Winder wrote: Doesn't that then make the whole DDoc system fairly useless, despite it's use in Phobos? Yes. The problem is that most things in D are compared with C or C++. People are praising that the built-in support for unit tests

Re: Question about linker errors when using slices

2020-09-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-19 04:45, tspike wrote: I’ve been using D for personal projects for almost a year now and I really love it. I recently ran across a linker error that I’m a little confused by. Consider the following files: platform.d:     module platform;     import app;     struct

Re: Proper way to exit with specific exit code?

2020-09-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-17 16:58, drathier wrote: What's the proper way to exit with a specific exit code? I found a bunch of old threads discussing this, making sure destructors run and the runtime terminates properly, all of which seemingly concluding that it's sad that there isn't a way to do this

Re: DDoc generation

2020-09-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-18 13:41, Russel Winder wrote: Hi, I am trying to get to grips with DDoc for documenting an application. Getting the individual module HTML files seems to be the easy bit. The question is how to get an index.html (or equivalent) so as to have an application level entry point to the

Re: get element index when using each!(x)

2020-09-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-17 05:16, Paul Backus wrote: Worth knowing that the tuples you get from enumerate actually have named members, so you can write:     s.enumerate.each!(x => writeln(x.index, ":", x.value)); It actually works out of the box for `each`: s.each!((index, value) => writeln(index,

Re: Neater "not version (...)" ?

2020-09-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-16 21:04, Vladimirs Nordholm wrote: Ah, I guess it boils down to this then. Doesn't really make it "neater", but thank you for the tip! You only need to declare the enums ones. -- /Jacob Carlborg

Re: Neater "not version (...)" ?

2020-09-16 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-16 19:53, Vladimirs Nordholm wrote: Hello. I wonder if there is a better way to compile something if the current operating system is _not_ a specific platform. For example, I only want some code to compile if the operating system is not Windows. Currently I do this:    

Re: tupleof seems to break encapsulation

2020-09-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-05 07:14, 60rntogo wrote: I wouldn't dispute that it is useful, but that's besides the point. If I declare something private, it's usually because I want to preserve certain invariants and I want the compiler to provide a guarantee that I don't accidentally violate them. As it

Re: tupleof seems to break encapsulation

2020-09-04 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-04 12:16, 60rntogo wrote: Consider the following code. foo.d --- module foo; struct Foo {   private int i; } --- main.d --- void main() {   import std.stdio;   import foo;   auto x = Foo();   writeln(x);   // ++x.i;   ++x.tupleof[0];   writeln(x); } --- As expected, the

Re: Install multiple executables with DUB

2020-09-03 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-09-03 14:41, glis-glis wrote: Yes I already tried that, but I get the error Error: only one main allowed. Previously found main at src/scripts/copy.d Looks like DUB doesn't like multiple binaries? Oh, multiple binaries, I missed that. You can try to add multiple configurations [1].

Re: Install multiple executables with DUB

2020-09-03 Thread Jacob Carlborg via Digitalmars-d-learn
On Thursday, 3 September 2020 at 08:22:25 UTC, glis-glis wrote: I usually would just write a makefile for that, but I thought I'd give DUB a go. Unfortunately, the DUB-documentation is a little thin and I cannot find a way to tell DUB "compile all the files in the scripts folder and put the

Re: Installing D on Fresh Windows 10 machine is a pain

2020-08-28 Thread Jacob Carlborg via Digitalmars-d-learn
On Friday, 28 August 2020 at 05:38:59 UTC, novice3 wrote: DMD x86 on Windows have no dependencies, just unpack .zip and use. It's a pitty, that DMD x64 depend on VS :( It does not. If VS is not installed the MinGW provided libraries, which are bundled, will be used. -- /Jacob Carlborg

Re: How does D's templated functions implementation differ from generics in C#/Java?

2020-08-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-08-07 23:03, aberba wrote: Syntactically they look the same (although D's can do more things) so I'm trying to understand how why in D it's called template but in languages like C#/Java they're generics. I guess I have fair understanding of D's code generation but isn't it same as

Re: How does D's templated functions implementation differ from generics in C#/Java?

2020-08-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-08-07 23:39, H. S. Teoh wrote: They are *very* different. Java generics are based on "type erasure", i.e., at the syntactic level, containers are parametrized with the element types, but at the implementation level, the element types are merely "erased" and replaced with Object (a top

Re: Invoking the compiler during runtime

2020-08-05 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-08-05 09:57, cy wrote: Well, I did find this: https://dlang.org/blog/2017/08/01/a-dub-case-study-compiling-dmd-as-a-library/ That is more for using the frontend, not the backend for generating code. But it's pretty advanced... probably just invoking dmd would be good... You can

Re: Using D within a rust codebase

2020-07-28 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-07-27 13:43, Ali Çehreli wrote: They should be taken care of when the program is linked with a D compiler. Just linking with a D compiler is not sufficient. There needs to be a D main function for the runtime to automatically be initialized. If you make the D code a bit more

Re: Using D within a rust codebase

2020-07-27 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-07-27 03:03, Paul Backus wrote: extern(C) void hello() { import std.stdio: writeln; writeln("Hello from D!"); } The D runtime needs to be initialized first [1]. Then it should be terminated as well [2]. [1] https://dlang.org/phobos/core_runtime.html#.rt_init [2]

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: misc questions about a DUB package

2020-07-15 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-07-15 04:20, 9il wrote: No. Usually, a DUB package supports a range of C library version or just a fixes set of C API. The version behavior of the dub package is up to you. Usually, D API changes more frequently than the underlying C library. If you support a specific version of the C

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

2020-07-15 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-07-14 05:33, Boris Carvajal wrote: Can you try passing -D_GLIBCXX_USE_CXX11_ABI=0 to g++ and -version=_GLIBCXX_USE_CXX98_ABI to dmd. That comes from: https://dlang.org/changelog/2.088.0.html#std_string C++11 ABI is currently not supported. I based on previous messages and the usage

Re: Choosing a non-default linker for dmd (via dub)

2020-07-15 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-07-12 18:36, Per Nordlöw wrote: The line dflags "-linker=gold" platform="linux-ldc" # use GNU gold linker in dub.sdl enables me to change linker for LDC. Is it possible to choose a specific linker for DMD aswell in a similar way? I only find the flag `-L` that sets flags but no

Re: App/lib config system

2020-07-09 Thread Jacob Carlborg via Digitalmars-d-learn
On Thursday, 9 July 2020 at 06:57:22 UTC, Kagamin wrote: If you suspect there's a contradiction in requirements, you need to specify them with better precision. What are the contradictions in the requirements? I don't see any. -- /Jacob Carlborg

App/lib config system

2020-07-08 Thread Jacob Carlborg via Digitalmars-d-learn
I'm looking for a way to configure applications and libraries. I'm imagining a way for libraries to hook into a single point to provide the configuration parameters the library provides. These parameters can then be changed in one location from the user of the libraries (usually an

Re: How can I make DMD stop on the first fatal error? (-Wfatal-errors)

2020-07-08 Thread Jacob Carlborg via Digitalmars-d-learn
On Wednesday, 8 July 2020 at 00:54:40 UTC, Marcone wrote: How can I make DMD stop on the first fatal error like -Wfatal-errors on C++? With the `-verrors=1` flag. You can specify exactly how many errors the compiler should emit before halting the compilation. Specify `0` for unlimited. --

Re: Construct an used-defined hash table container type from an AA-literal expression

2020-07-08 Thread Jacob Carlborg via Digitalmars-d-learn
On Tuesday, 7 July 2020 at 12:41:23 UTC, Per Nordlöw wrote: What about construction and assignment from a static array of `Pair`'s? Wouldn't that be easier on the compiler? I you refer to it wouldn't be using templates, then yes, I guess so. -- /Jacob Carlborg

Re: Construct an used-defined hash table container type from an AA-literal expression

2020-07-06 Thread Jacob Carlborg via Digitalmars-d-learn
On Sunday, 5 July 2020 at 21:06:32 UTC, Per Nordlöw wrote: Is there a way to construct a custom written hash-table container (struct) from an AA-literal expression? I think your best bet is a tuple of pairs, because then you're not limited to compile time values, but it won't look pretty:

Re: Construct an used-defined hash table container type from an AA-literal expression

2020-07-06 Thread Jacob Carlborg via Digitalmars-d-learn
On Monday, 6 July 2020 at 01:43:43 UTC, user1234 wrote: --- import std; struct AA { void opIndexAssign(int v, string k) @nogc {} } void main(string[] args) @nogc { AA myCustom; enum literal = ["one":1, "two":2].stringof[1..$-1]; enum pairs = literal.split(',').array;

Re: Construct an used-defined hash table container type from an AA-literal expression

2020-07-06 Thread Jacob Carlborg via Digitalmars-d-learn
On Monday, 6 July 2020 at 01:43:43 UTC, user1234 wrote: Hereh we go ;) --- import std; struct AA { void opIndexAssign(int v, string k) @nogc {} } void main(string[] args) @nogc { AA myCustom; enum literal = ["one":1, "two":2].stringof[1..$-1]; enum pairs =

Re: Print only part of a stack trace

2020-07-01 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-07-01 19:44, Dennis wrote: On assertion failure, the default error handler prints a stack trace that looks like this [library functions] [application functions] [druntime start-up functions] I'm only interested in application functions, the rest is noise. I could easily filter

Re: Calling C functions

2020-06-30 Thread Jacob Carlborg via Digitalmars-d-learn
On Tuesday, 30 June 2020 at 12:22:15 UTC, Steven Schveighoffer wrote: (i.e. one cannot use extern(D) functions for C callbacks). I don't think that's a big issue. Honestly, I don't think it's an issue at all. BTW, the order of arguments is not the only thing. Variadic functions in D and

Re: Calling C functions

2020-06-29 Thread Jacob Carlborg via Digitalmars-d-learn
On Monday, 29 June 2020 at 16:34:33 UTC, Steven Schveighoffer wrote: Are you sure? On the ABI page [1] , it says "The extern (C) and extern (D) calling convention matches the C calling convention used by the supported C compiler on the host system." In that case the documentation is wrong.

Re: Calling C functions

2020-06-26 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-06-26 18:54, Denis wrote: OK, now this makes sense. I tested calling the same callback function directly from D: it compiled and worked correctly. So at least prefixing the callback function with `extern(C)` doesn't prevent the rest of the D program from calling it too. No, of

Re: Downloading files over TLS

2020-06-26 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-06-26 15:16, Adam D. Ruppe wrote: Yeah, I've been wanting to change that and use the native apis for years but like I just haven't been able to figure out the documentation of them. That would be nice. That's the problem of everything Apple makes. Kinda drives me nuts trying to keep

Re: Downloading files over TLS

2020-06-26 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-06-26 14:43, User wrote: It is possible to statically link libcurl into your application. No need to use OpenSSL as libcurl can be built with SChannel. That sounds good. It looks like I remembered wrong. std.net.curl uses `dlopen` on libcurl, not OpenSSL. This might be less of an

Re: Downloading files over TLS

2020-06-26 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-06-26 14:41, Kagamin wrote: Maybe just start wget or something like that? The point was to avoid runtime dependencies. Since you want the latest certificate storage, you intend to support only the latest system. Many root certificates will timeout now. I didn't say the latest

Re: Downloading files over TLS

2020-06-26 Thread Jacob Carlborg via Digitalmars-d-learn
On Friday, 26 June 2020 at 11:10:27 UTC, ikod wrote: Hello, re `requests` - it uses dlopen (and variants for OSX and Windows, see https://github.com/ikod/dlang-requests/blob/master/source/requests/ssl_adapter.d#L50). The reason for dlopen is simple - compatibility with both openssl ver 1.0

Downloading files over TLS

2020-06-26 Thread Jacob Carlborg via Digitalmars-d-learn
Downloading files over TLS. This seems that it's something that should be quite simple to do. My high level goals are cross-platform and easy distribution. I don't need anything fancy just a simple API like this: download("https://url.com;, "/local/file"); Because of these goals, I have a

Re: Calling C functions

2020-06-26 Thread Jacob Carlborg via Digitalmars-d-learn
On Friday, 26 June 2020 at 00:30:22 UTC, Denis wrote: I have a two questions about calling C functions from D. (1) When passing a D callback to a C function, is there a way to write the code without having to prefix the callback declaration with "extern(C)"? It's not a big deal adding the

Re: How to correctly integrate D library to Swift/Obj-C mobile project?

2020-06-24 Thread Jacob Carlborg via Digitalmars-d-learn
On Monday, 22 June 2020 at 14:32:21 UTC, Anton wrote: I have a static library (.a) compiled with LDC for iOS platform. But I can't figure out how to correctly connect it to the project and call its functions. I've already linked binary with library to the project but IDE still doesn't see its

Re: How to correctly integrate D library to Swift/Obj-C mobile project?

2020-06-24 Thread Jacob Carlborg via Digitalmars-d-learn
On Monday, 22 June 2020 at 19:41:22 UTC, Vlad wrote: Is it even possible to compile D for iOS and use it the same way as compiled C++ static library? (We do need a D runtime) Yes, druntime/Phobos will need to be linked like any other static library. -- /Jacob Carlborg

Re: Some questions about strings

2020-06-22 Thread Jacob Carlborg via Digitalmars-d-learn
On Monday, 22 June 2020 at 04:08:10 UTC, Denis wrote: The terminating null character was one of the reasons I thought strings were different from char arrays. Now I know better. String **literals** have a terminating null character, to help with integrating with C functions. But this null

Re: Dub Error Message "Invalid variable: DUB"

2020-06-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-06-07 11:24, Russel Winder wrote: Hi, Why on earth is Dub sending out this error message (Invalid variable: DUB) on GitLab but not on Travis-CI or locally? OK, that was slightly rhetorical, more reasonably, why is dub sending out this message at all? Dub is supposed to make an

Re: Objective C protocols

2020-05-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-05-17 11:32, John Colvin wrote: On Saturday, 16 May 2020 at 19:14:51 UTC, John Colvin wrote: What's the best way to implement an Objective C protocol in D? I see mention here https://dlang.org/changelog/2.085.0.html#4_deprecated_objc_interfaces but it's not clear where things are

Re: Get unknown symbol (struct, method, class) tagged with User Defined Attributes

2020-05-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-05-12 06:02, Steven Schveighoffer wrote: If you want a list of ALL symbols that have the UDA in the application, that would require some form of runtime reflection (like Java). D has very limited support for runtime reflection. In D, you would use some form of registration to tell the

Re: D and Async I/O

2020-05-12 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-05-12 11:23, Russel Winder wrote: As far as I can tell D has no futures… Future and async in vibe.d [1]. Future in Mecca [2]. [1] https://vibed.org/api/vibe.core.concurrency/async [2]

Re: Error running concurrent process and storing results in array

2020-05-11 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-05-07 02:17, data pulverizer wrote: What is the difference between -O2 and -O3 ldc2 compiler optimizations? `--help` says -O2 is "Good optimizations" and -O3 "Aggressive optimizations". Not very specific. -- /Jacob Carlborg

Re: D and Async I/O

2020-05-11 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-05-11 16:44, Russel Winder wrote: Crickey, a third option. This wil increase my dithering! ;-) Forth: Mecca [1] :) [1] https://github.com/weka-io/mecca -- /Jacob Carlborg

Re: Error running concurrent process and storing results in array

2020-05-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-05-06 12:23, data pulverizer wrote: Yes, I'll do a blog or something on GitHub and link it. It would be nice if you could get it published on the Dlang blog [1]. One usually get paid for that. Contact Mike Parker. [1] https://blog.dlang.org -- /Jacob Carlborg

Re: Retrieve the return type of the current function

2020-05-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-05-05 19:11, learner wrote: On Tuesday, 5 May 2020 at 16:41:06 UTC, Adam D. Ruppe wrote: typeof(return) Thank you, that was indeed easy! Is it possible to retrieve also the caller return type? Something like: Yes, kind of: void foo(string caller = __FUNCTION__)() { import

Re: Error running concurrent process and storing results in array

2020-05-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-05-06 06:04, Mathias LANG wrote: In general, if you want to parallelize something, you should aim to have as many threads as you have cores. That should be _logical_ cores. If the CPU supports hyper threading it can run two threads per core. -- /Jacob Carlborg

Re: Error running concurrent process and storing results in array

2020-05-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-05-06 08:54, drug wrote: Do you try `--fast-math` in ldc? Don't know if 05 use this flag Try the following flags as well: `-mcpu=native -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto` -- /Jacob Carlborg

Re: Error running concurrent process and storing results in array

2020-05-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-05-06 05:25, data pulverizer wrote: I have been using std.parallelism and that has worked quite nicely but it is not fully utilising all the cpu resources in my computation If you happen to be using macOS, I know that when std.parallelism checks how many cores the computer has, it

Re: DConf 2017 Videos

2020-04-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-04-24 22:24, matheus wrote: Hi, please could someone tell me where can I find videos from DConf 2017? I pretty sure I watched them on Youtube sometime ago, but I can't find anymore. By the way, I'm looking from one video where someone shows some "C flaws" and how to D as Better C

Re: Array fill performance differences between for, foreach, slice

2020-04-01 Thread Jacob Carlborg via Digitalmars-d-learn
On 2020-03-31 23:30, data pulverizer wrote: $ dmd fill.d && ./fill You have not enabled optimizations. You should compile with `-O -release -inline` to enable all optimizations. Without optimizations I get numbers like these: Slice: Mean time(usecs): 92.91, Standard Deviation: 49.8002

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    

  1   2   3   4   5   6   7   >