Re: Creating DLL

2022-06-16 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 16 June 2022 at 16:19:22 UTC, Ali Çehreli wrote: pragma (crt_constructor) You have to be pretty careful about this since it might not run in the order you expect. If there's two things in the program with a equal-priority crt constructor, they are run in arbitrary order. In a

Re: Creating DLL

2022-06-16 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 16 June 2022 at 16:07:41 UTC, Sergeant wrote: May I ask one more question: why a code like this would work in D-application but not in D-DLL? (also I notice some other D functions don't work in DLL): Probably because the runtime not initialized properly. Export an Initialize()

Re: Creating DLL

2022-06-16 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 16 June 2022 at 13:57:48 UTC, Sergeant wrote: export int my(int a, int b) the name here is going to be mangled, so like "_D5mydll2myiiZi" or something like that. You might want to add `extern(C)` to it so it keeps the simple name "my", that might help.

Re: UI Library

2022-06-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 11 June 2022 at 21:44:17 UTC, harakim wrote: I tried the solution I suggested and it did not work because the child would occlude the parent (which is in the comments now that I see it.) yeah minigui's model is to tile the widgets; they aren't supposed to overlap (except their

Re: UI Library

2022-06-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 11 June 2022 at 01:20:17 UTC, harakim wrote: The issue I'm having is that I don't understand how to assign bounds in the nested widget. I'm sure there's a very clean solution. I basically want a paintContent method but with the bounds dynamically assigned by the parent. Well the

Re: 'each' can take static arrays

2022-06-10 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 10 June 2022 at 16:59:04 UTC, Ali Çehreli wrote: Why the inconsistency? Phobos has dozens of random special cases throughout. I'd prefer if these were all removed, but right now there's just some functions that special case to allow it and others that don't. Apparently each is

Re: How to map machine instctions in memory and execute them? (Aka, how to create a loader)

2022-06-06 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 6 June 2022 at 15:13:45 UTC, rempas wrote: void* code = mmap(null, cast(ulong)500, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); On a lot of systems, it can't be executable and writable at the same time, it is a security measure. see

Re: Comparing Exceptions and Errors

2022-06-05 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 5 June 2022 at 10:38:44 UTC, Ola Fosheim Grøstad wrote: That is a workaround that makes other languages more attractive. It is what a lot of real world things do since it provides additional layers of protection while still being pretty easy to use. *Correctness **is**

Re: Dynamic Arrays Capacity

2022-06-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 3 June 2022 at 12:49:07 UTC, bauss wrote: I believe it's only true in unicode for utf-32 since all characters do fit in the 4 byte space they have Depends how you define "character".

Re: Basic SQLite Application

2022-06-01 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 1 June 2022 at 15:40:43 UTC, harakim wrote: It's been a long time since I did any C development, and I have never done any on windows, but I thought I could statically link to the .lib at compile time and then I wouldn't need a dll. You sometimes can, it depends on how the

Re: Basic SQLite Application

2022-06-01 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 1 June 2022 at 03:46:38 UTC, harakim wrote: I started trying to get it to compile in another directory structure but since I've switched to dub It should work the way you have it, just with dub you can also the dub version instead of copying the files:

Re: gdc 12.1: undefined references when linking separately compiled files

2022-05-28 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 28 May 2022 at 14:16:51 UTC, kdevel wrote: $ gdc -o ppinsta ppinsta.d parser.d Compiling together is faster anyway this is prolly what you want most the time. But I know what's going on now, it is the template emission thing, the compiler thinks, since it is from std, it was

Re: gdc 12.1: undefined references when linking separately compiled files

2022-05-28 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 28 May 2022 at 13:12:46 UTC, kdevel wrote: gdc -o ppinsta ppinsta.o esah.o evaluate.o jsr.o jsw.o parser.o ptvr.o stack.o testdatagenerator.o You might need to add -lgphobos or -lgphobos2 or whatever it is called too explicitly.

Re: Cannot check function address

2022-05-24 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 24 May 2022 at 22:10:21 UTC, frame wrote: To also anwser to Adam: no, this symbol is unique. The first line of the error says: ``` Error: function `a.fun(string param)` is not callable using argument types `()`. ``` There's a big difference between a function and a function

Re: How are delegate attributes in fn signature inferred?

2022-05-23 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 23 May 2022 at 13:44:53 UTC, wjoe wrote: i.construct((ulong i) {return cast(int)(i+i);}).print; You can actually make this work with `construct!(int[])` rather than plain `construct`. This is a (really annoying) deficiency in dmd's implementation. (that sdc solved btw proving it

Re: Allocate a string via the GC

2022-05-23 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 23 May 2022 at 12:20:11 UTC, JG wrote: I am writing an interpreter and I needed access to a string via a pointer of type void* I ended up wrapping it in a struct since I needed another value anyway. Seems odd that one can't do it in a less unusual way. OK yeah, that's the main use

Re: Allocate a string via the GC

2022-05-23 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 23 May 2022 at 09:38:07 UTC, JG wrote: Hi, Is there any more standard way to achieve something to the effect of: ```d import std.experimental.allocator; string* name = theAllocator.make!string; ``` Why do you want that? Easiest way I know of is to just wrap it in a struct,

Re: Install DCD language server on Raspberrry PI4 (aarch64) requires rdmd , command not found.

2022-05-21 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 21 May 2022 at 22:44:55 UTC, Alain De Vos wrote: Can I compile rdmd from source ? Yes, rdmd is a trivial program. https://github.com/dlang/tools/blob/master/rdmd.d

Re: Sleep in a cycle

2022-05-20 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 20 May 2022 at 14:59:07 UTC, Alexander Zhirov wrote: I have a loop spinning, I want to pause in it in order to repeat the next iteration. An error is displayed during compilation. The error has nothing to do with the sleep source/app.d(32,5): Warning: statement is not reachable

Re: template? mixin? template mixins? for modifying a struct setup

2022-05-20 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 20 May 2022 at 14:54:31 UTC, Christopher Katko wrote: If the declarations are at module scope, `static` has no effect, and CTFE will be used for initialization. It won't use CTFE? Why is there a local module requirement? "module scope" just means at the top level in a module. so

Re: UI Library

2022-05-20 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 20 May 2022 at 03:47:14 UTC, harakim wrote: Thank you. I will definitely give that a try. My minigui uses the normal Windows controls so it works well there. On linux it uses a custom thing of my own design so your mileage may vary. The docs don't have a lot of examples but

Re: Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-19 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 19 May 2022 at 20:20:49 UTC, Marcone wrote: I am using a main() function. I am compiling on Windows x86 32 bits. I am using DMD 2.100.0 This error is only in version 2.100.0 of DMD. Are you using the `-L/entry:mainCRTStartup` or the `L/entry:wmainCRTStartup` ?

Re: Error: undefined symbol: _WinMain@16 When try compile no console

2022-05-19 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 19 May 2022 at 19:29:25 UTC, Marcone wrote: Using -L/SUBSYSTEM:windows user32.lib you using a main() function right? Please note when compiling on Win64, you need to explicitly list -Lgdi32.lib -Luser32.lib on the build command. If you want the Windows subsystem too, use

Re: Why are structs and classes so different?

2022-05-17 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 14:40:48 UTC, Kevin Bailey wrote: Foo foo; is undefined behavior waiting to happen, that I can't detect at a glance. It is actually perfectly well defined - for the class, it will be null, and this will kill the program if you use it. You might not like that

Re: D WebAssembly working differently than C++, Zig

2022-05-17 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 11:43:45 UTC, Siarhei Siamashka wrote: Looks like you forgot to increment the pointer and need "*d++ = cast(ubyte) c;" there. hahaha yup. And filling the buffer one byte at a time is likely slow. prolly but meh, that's where the intrinsics are nice.

Re: D WebAssembly working differently than C++, Zig

2022-05-17 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 16 May 2022 at 18:17:03 UTC, Allen Garvey wrote: Thanks so much, that fixed the problem! You have no idea have long I have spent trying to debug this! Oh I should have checked my impl, where I did all this already!

Re: D WebAssembly working differently than C++, Zig

2022-05-16 Thread Adam D Ruppe via Digitalmars-d-learn
I would suspect it is something to do with your memset... even if it needs to take the int (wtf but ldc is weird) you might want to reinterpret cast it to float to avoid any extra conversions.

Re: What are (were) the most difficult parts of D?

2022-05-13 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 13 May 2022 at 18:23:58 UTC, H. S. Teoh wrote: On Thu, May 12, 2022 at 11:45:47PM +, Guillaume Piolat via It's a problem because it goes from solving "no accidental race condition" and you get "people forget to add shared or __gshared and their shared library silently fail"

Re: What are (were) the most difficult parts of D?

2022-05-12 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 12 May 2022 at 15:18:34 UTC, jmh530 wrote: What's the difference between a Type and Type Identifier? The is expression roughly follows variable declaration style. You write int a; to declare a new symbol named `a` of type `int`. Similarly, static if(is(T a)) declares a new

Re: What are (were) the most difficult parts of D?

2022-05-12 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 12 May 2022 at 14:42:43 UTC, Anonymouse wrote: That said, one thing I cannot seem to firmly wrap my head around is `is` expressions. `is` does so many things. It is simpler than it looks, I wrote about it in my book and in a post here:

Re: What are (were) the most difficult parts of D?

2022-05-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 12 May 2022 at 01:06:02 UTC, Christopher Katko wrote: completely different semantics for a class vs a struct. Is it a reference? Is it a value? Look up the entire declaration and have the entire Dlang manual open to find out. As far as I remember, no automatic RAII support, even

Re: Release: serverino - please destroy it.

2022-05-10 Thread Adam D Ruppe via Digitalmars-d-announce
On Monday, 9 May 2022 at 20:37:50 UTC, Andrea Fontana wrote: The same goes for cgi/fastcgi/scgi and so on. Well, cgi does one process per request, so there is no worker pool (it is the original "serverless" lol). fastcgi is interesting because the Apache module for it will actually start

Re: Google Code Jam 2022

2022-05-06 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 6 May 2022 at 04:26:13 UTC, Siarhei Siamashka wrote: So it may seem that D should be a very good choice for programming competitions, but there's still no success. Programming competitions are a 100% waste of time. I'm too busy doing real work.

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 16:38:23 UTC, cc wrote: This is really interesting syntax, I'm surprised that works! Can read a little more on my blog about it: http://dpldocs.info/this-week-in-d/Blog.Posted_2019_06_10.html#tip-of-the-week pretty cool little pattern.

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 14:38:53 UTC, Arafel wrote: Actually, it would be cool to do it through an interface, although I don't think an interface's static constructors are invoked by the implementing classes... it would be cool, though. yeah interfaces can't have constructors. I'd try it

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 13:25:14 UTC, Arafel wrote: I'd like to do a runtime registration system myself, using a "template this" static constructor. A simple version supporting only default constructors would be: Yeah, you can't template this a static constructor, but you can just use a

Re: How to get compatible symbol names and runtime typeid names for templated classes?

2022-05-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 09:42:45 UTC, cc wrote: something I can pass to `Object.factory`. Object.factory is useless and will hopefully be removed someday. Instead, make your own factory registration function. Put a static constructor in the class which appends a factory delegate to an

Re: What's a good way to disassemble Phobos?

2022-04-30 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 30 April 2022 at 18:18:02 UTC, Dukc wrote: I'm looking for something where I could search for the call to the DRuntime functions in question, from an already combined .o or .a. What do you suggest? I'm on Linux. objdump -d works on .o files

Re: Beerconf April 2022

2022-04-29 Thread Adam D Ruppe via Digitalmars-d-announce
On Friday, 29 April 2022 at 17:07:27 UTC, rikki cattermole wrote: Password: `dub4life` I see you are gatekeeping to keep a certain clique out!

Re: CTFE and BetterC compatibility

2022-04-28 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 28 April 2022 at 12:36:56 UTC, Dennis wrote: In this case, it was actually a trailing whitespace in the changelog entry making the test suite fail, but the PR author Stefan's own `assert(__ctfe);` approach was better anyway...

Re: How do I get the screen resolution?

2022-04-28 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 28 April 2022 at 11:22:15 UTC, Alexander Zhirov wrote: Are there any methods to get the screen resolution? Call DisplayWidth/DisplayHeight on the X connection... my simpledisplay.d provides bindings (though not a high level helper function since both X and Windows calls are

Re: Library for image editing and text insertion

2022-04-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 27 April 2022 at 17:07:54 UTC, matheus wrote: I know about Adam Ruppe's work, I already used his terminal.d, but I think that unfortunately most people don't and I think it should be announced more in these parts. tbh sometimes i just don't feel like answering messages. even

Re: Library for image editing and text insertion

2022-04-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 27 April 2022 at 14:40:59 UTC, Alexander Zhirov wrote: Gorgeous! LDC has compressed my code at times! How small did it get? And with my libs if you import the other ones like `arsd.png` or `arsd.jpeg` directly instead of `arsd.image` that MIGHT help trim it down by removing

Re: CTFE and BetterC compatibility

2022-04-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 27 April 2022 at 14:21:15 UTC, Claude wrote: The operation requiring the D-runtime is appending the array, but it should **only** be done at compile-time. In that case, you want to prove to the compiler it is only called at compile time by encapsulating the function inside a

Re: arsd-minigui - couple of questions

2022-04-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 11 April 2022 at 12:40:29 UTC, sai wrote: One more request, is it possible for you to do to ImageBox what you did to Button to show the transparent images (png)? Because Imagebox is showing black color for transparent pixels. oh yeah this one is different because the imagebox

Re: Looking for a workaround

2022-04-06 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 6 April 2022 at 18:10:32 UTC, Guillaume Piolat wrote: Any idea how to workaround that? Works fine if you just use the language instead of the buggy phobos wrappers: --- struct MyUDA { } class A { @MyUDA int a; } class B : A {

Re: Mixin Templates and Operators

2022-04-06 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 6 April 2022 at 17:33:28 UTC, Steven Schveighoffer wrote: As I mentioned elsewhere, it does work. But the situation I think must be that it's only one mixin template. Probably also you can't have any overloads in the type itself. ooh yeah there's multiple here so the

Re: Mixin Templates and Operators

2022-04-06 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 6 April 2022 at 10:36:04 UTC, francesco.andreetto wrote: Am I doing something wrong or it is impossible to use mixin templates like that? mixin templates can't bring in operator overloads. The spec doesn't really say this I think, but that's the way it has been for a long time.

Re: D Language Foundation Monthly Meeting Summary for March 2022

2022-04-04 Thread Adam D Ruppe via Digitalmars-d-announce
On Monday, 4 April 2022 at 12:23:54 UTC, rikki cattermole wrote: +1 infer everything! Well, you *can't* infer everything, but private things I do think you can get away with since they're not allowed to be virtual. Inferring more on non-virtual things is a maybe, you still have to think

Re: arsd-minigui - couple of questions

2022-03-29 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 29 March 2022 at 14:24:13 UTC, sai wrote: Seems like a linker bug? So we have to wait for the fix to show up in dmd package. I just tried copying the lld-link from llvm version 14 upstream into the dmd directory and it does fix the problem, so will try to get the dmd release

Re: arsd-minigui - couple of questions

2022-03-29 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 29 March 2022 at 13:39:25 UTC, sai wrote: I searched for "manifestdependency" and "drectve" (w/o quotes) in arsd lib and couldn't find them so not sure how to debug this further. Ah sorry, you caught me in the middle of something. Yes, I remember seeing this before, lld-link is

Re: Windows Msys terminal not flushing on newlines

2022-03-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 27 March 2022 at 17:46:54 UTC, Anonymouse wrote: I installed Git for Windows which comes with the Msys terminal, and I noticed writeln lines aren't being flushed on linebreaks If the C library thinks it is talking to a pipe, it will switch to block buffering instead of line

Re: I like dlang but i don't like dub

2022-03-22 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 22 March 2022 at 14:44:59 UTC, Marcone wrote: Why is dmd unable to import modules installed by dub using the import command like it does with the Phobos library? He can't send these modules to Linker? Needing to be passed to dmd via command line. I think it could be all automatic.

Re: I like dlang but i don't like dub

2022-03-20 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 18 March 2022 at 18:16:51 UTC, Ali Çehreli wrote: As a long-time part of the D community, I am ashamed to admit that I don't use dub. I am ashamed because there is no particular reason, or my reasons may not be rational. dub is legitimately awful. I only use it when forced to, and

Re: argparse version 0.7.0 - a CLI parsing library

2022-03-18 Thread Adam D Ruppe via Digitalmars-d-announce
On Friday, 18 March 2022 at 18:21:46 UTC, Anonymouse wrote: One drawback is documentation; adrdox does *not* like these kinds of UDAs. It is on my list to run big UDAs through the auto-formatter at some point pretty soon to help with this. I just have a big work project I'm wrapping up

Re: Template with default parameter

2022-03-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 11 March 2022 at 12:01:27 UTC, Andrey Zherikov wrote: There is some inconsistency between templates and template functions as this works as I want to: Yeah, functions have the special feature of implicit instantiation from the function arguments. No other template do, if you want

Re: trash-d version 15

2022-03-08 Thread Adam D Ruppe via Digitalmars-d-announce
On Tuesday, 8 March 2022 at 16:19:13 UTC, rushsteve1 wrote: According to [the module documentation](https://dlang.org/spec/module.html) you can omit the `module x;` and it will implicitly be the file name. This is pretty flaky, I'd strongly recommend that for any module ever imported, use

Re: Source code for vibe.d listenTCP()

2022-02-26 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 26 February 2022 at 22:25:46 UTC, Chris Piker wrote: Anyway if someone can just help me find the source code to listenTCP inside vibe.d I'd be grateful. My dpldocs.info search engine is not great right now but it can sometimes help find these things:

Re: Will it be possible to write a GCC frontend in D?

2022-02-23 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 23 February 2022 at 20:42:10 UTC, rempas wrote: Do you know where is the updated GDC branch btw? There is no branch, it is just part of the upstream mainline. see: https://gcc.gnu.org/git/?p=gcc.git;a=tree;f=gcc/d/dmd;h=454baa71a0d270fb891acdda6fd0215a3d6cb588;hb=HEAD and yeah

Re: Will it be possible to write a GCC frontend in D?

2022-02-23 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 23 February 2022 at 19:58:45 UTC, rempas wrote: Will it be possible to write a GCC frontend in D? I should hope so, otherwise gdc wouldn't exist, yet it does.

Re: Odd behaviour of std.range

2022-02-22 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 22 February 2022 at 12:48:21 UTC, frame wrote: What am I missing here? Is this some UTF conversion issue? `front` is a phobos function. Phobos treats char as special than all other arrays. It was a naive design flaw that nobody has the courage to fix. Either just don't use

Re: DDoc Reference Links point to /docs/docs instead of /docs?

2022-02-21 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 21 February 2022 at 15:35:41 UTC, Vijay Nayar wrote: I'm a bit surprised I've never heard of `adrdox` before now. yeah i don't advertise much. it is what runs on my dpldocs.info website though which auto-generates docs for dub packages. Regarding ddoc, should I submit a bug

Re: DDoc Reference Links point to /docs/docs instead of /docs?

2022-02-21 Thread Adam D Ruppe via Digitalmars-d-learn
tbh ddoc is pretty bad, you should try my `dub run adrdox` instead which also creates html but its links actually work.

Re: Strange behavior of iota

2022-02-15 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 15 February 2022 at 21:48:29 UTC, bachmeier wrote: writeln(iota(v.length,-1,-1)); This would be like for(a = v.length; a > cast(size_t) -1, a += -1) That (cast(size_t) -1) is the same as thing.max, meaning a will never be greater than it. Why does the first argument to

Re: Is this Windows Win32 fileapi.h header accessible in D language?

2022-02-08 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 8 February 2022 at 16:10:19 UTC, BoQsc wrote: Unsure where to start, so I decided to ask here how to get use of this win32 header. https://docs.microsoft.com/en-us/windows/win32/api/fileapi/ There is this for all the upstream things: https://github.com/rumbu13/windows-d But for

Re: On the D Blog: A Gas Dynamics Toolkit in D

2022-02-02 Thread Adam D Ruppe via Digitalmars-d-announce
On Wednesday, 2 February 2022 at 16:32:26 UTC, H. S. Teoh wrote: Interesting that the author(s) found D error messages better than C++, in spite of frequent complaints about error messages here in the forums. :-P No incompatibility there: "better than C++" is a very low bar.

Re: The DIID series (Do It In D)

2022-01-26 Thread Adam D Ruppe via Digitalmars-d-announce
On Wednesday, 26 January 2022 at 15:53:44 UTC, Ola Fosheim Grøstad wrote: Is this list out of date? https://github.com/dlang-community/awesome-d You can tell it is very incomplete since it doesn't list arsd in every category. :P Well, I don't have a dedicated containers module. When I need

Re: gdc or ldc for faster programs?

2022-01-25 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 19:52:17 UTC, Ali Çehreli wrote: ldc: ~0.95 seconds gdc: ~0.79 seconds dmd: ~1.77 seconds Not surprising at all: gdc is excellent and underrated in the community.

Re: How to do same as 'nmap' command from within a D program?

2022-01-24 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 22 January 2022 at 20:55:38 UTC, Daren Scot Wilson wrote: I'm writing a command line program to control certain hardware devices. I can hardcode or have in a config file the IP addresses for the devices, if I know that info. If I don't? Depending on the hardware, you might be

Re: D Language Quarterly Meeting Summary for January 2021

2022-01-23 Thread Adam D Ruppe via Digitalmars-d-announce
On Sunday, 23 January 2022 at 04:12:30 UTC, H. S. Teoh wrote: On Sun, Jan 23, 2022 at 03:24:04AM +, Paul Backus via Digitalmars-d-announce wrote: [...] The way I envision it, `std` would be the "rolling release" namespace that allows breaking changes, and if you wanted stability, you'd

Re: Ensuring allocation isn't thread-local?

2022-01-22 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 22 January 2022 at 18:55:30 UTC, Jaime wrote: A) Do I need to worry about data being / not being in thread-local storage? No. Anything allocated with `new` is not thread local... and even if it was, you can send the pointer to other threads anyway. The only things in thread

Re: Using getSymbolsByUDA in a static foreach loop

2022-01-19 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 19 January 2022 at 21:44:57 UTC, Jack Stouffer wrote: The error is actually coming from trying to use the result of getSymbolsByUDA in the right part of the `static foreach` huh.. I never use most of std.traits, they just complicate things. Bleh idk, I wouldn't bother with

Re: Using getSymbolsByUDA in a static foreach loop

2022-01-19 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 19 January 2022 at 20:46:17 UTC, Jack Stouffer wrote: static foreach(system; getSymbolsByUDA!(Manager, Runnable)) { system.run(); onlineapp.d(16): Error: value of `this` is not known at compile time The getSymbols returns aliases, meaning you hit

Re: shared defaultlib with dmd

2022-01-18 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 18 January 2022 at 22:04:15 UTC, forkit wrote: so I use this compile command (on Windows, using ldc) On Linux dmd can do `-defaultlib=libphobos2.so` for the same thing. On Windows, dmd cannot handle a shared druntime.

Re: How to alias

2022-01-18 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 14 January 2022 at 18:04:35 UTC, kyle wrote: Thanks Adam. We need a repository of articles about stuff that doesn't do what people expect. I put this as a tip of the week in my late post: http://dpldocs.info/this-week-in-d/Blog.Posted_2022_01_10.html#tip-of-the-week My blog

Re: Throw stack trace from program kill

2022-01-16 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 16 January 2022 at 18:03:53 UTC, Paul Backus wrote: extern(C) void handleCtrlC(int) { throw new Error("Killed by CTRL+C"); } This is really iffy since signals can come to random threads at random times. The best thing to do is typically to just set a "user requested

Re: How to alias

2022-01-14 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 14 January 2022 at 17:48:41 UTC, kyle wrote: I'm trying to use ```alias``` in an operator overload to reduce typing, but what gets aliased is not what I expect. alias works in term of compile-time names, not values. This means the `this` value, being run time, gets discarded.

Re: Why I Like D

2022-01-12 Thread Adam D Ruppe via Digitalmars-d-announce
On Wednesday, 12 January 2022 at 15:25:37 UTC, H. S. Teoh wrote: However it turns out that unless you are writing a computer game, a high frequency trading system, a web server Most computer games and web servers use GC too. idk about hf trading.

Re: Undefined reference to "S_ISDIR" and "S_ISREG" when compiling with "-betterC"

2022-01-10 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 10 January 2022 at 20:28:43 UTC, rempas wrote: I'll write assembly and implement the system call be myself. It's not a system call, it just a bitflag tester.

Re: Undefined reference to "S_ISDIR" and "S_ISREG" when compiling with "-betterC"

2022-01-10 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 10 January 2022 at 19:33:36 UTC, rempas wrote: Thanks! It needs to be linked with which library? That segment of druntime. You can get dmd to do it for you by using the `-i -i=core.sys` flags (or maybe just the -i=core.sys thing im not sure i haven't actually tried). Or just

Re: Undefined reference to "S_ISDIR" and "S_ISREG" when compiling with "-betterC"

2022-01-10 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 10 January 2022 at 19:20:56 UTC, rempas wrote: If I'm not mistaken, "core*" should work with "-betterC". Any ideas? You are mistaken, -betterC's main mission is to exclude core. Declarations that just bind to something externally will still work, since it doesn't matter if they're

Re: Windows link trouble

2022-01-07 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 7 January 2022 at 20:48:17 UTC, mesni wrote: Windows: when creating dll file, ClassInfo and ModuleInfo are not exported? The linker swears specifically at *__Class or *__ModuleInfo symbols. nothing is exported unless you use the export keyword or a module definition file. but

Re: print ubyte[] as (ascii) string

2022-01-07 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 7 January 2022 at 20:33:05 UTC, eugene wrote: * python guys have memory leaks * js guys have memory leaks GC isn't actually there to prevent memory leaks. Its main job is to guard against use-after-free memory corruption bugs. Actually, technically, the paradigm is "infinite

Re: Libc functions undefined when linking

2022-01-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 4 January 2022 at 21:22:26 UTC, Ben Jones wrote: * frame #0: 0x That's null, meaning the library wasn't loaded. simpledisplay actually doesn't need -lX11 since it always dynamic loads the libraries. Normally it throws when this fails though instead of keeping

Re: Libc functions undefined when linking

2022-01-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 4 January 2022 at 19:10:25 UTC, Ben Jones wrote: All good, except now simpledisplay is segfaulting on XDisplayConnection.get again run it in the debugger; do a -g build and run it in gdb or lldb and do check the exact line it is on. could be that the Xlib things didn't

Re: Libc functions undefined when linking

2022-01-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 4 January 2022 at 18:13:56 UTC, Ben Jones wrote: clang -c -o source/assignment1.o source/assignment1.c you might have better luck just telling clang to link it too like clang source/assignment1.o -lphobos2 build/*.o # etc since there's a bunch of default search paths and libs

Re: what's the proper way to assign this?

2022-01-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 4 January 2022 at 17:23:11 UTC, Dr Machine Code wrote: I could fix just with ```d data.entries ~= entry.get; ``` This is what the original code was doing - it used to implicitly do this. So while this might be buggy, it wouldn't be a new bug at least.

Re: std.signals: Why emit() not extist?

2021-12-30 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 30 December 2021 at 19:13:10 UTC, Marcone wrote: I get this error: Error: undefined identifier `emit`, did you mean function `exit`? You need to call it on the signal. class A { mixin Signal thing; } A a = new A; a.thing.emit();

Re: Mixin a function into a struct only if no member with that name already exists

2021-12-29 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 29 December 2021 at 10:14:13 UTC, Tobias Pankrath wrote: How do I mixin a function only if it is not already present? This is the default behavior of template mixins.

Re: How to print unicode characters (no library)?

2021-12-28 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 06:51:52 UTC, rempas wrote: That's pretty nice. In this case is even better because at least for now, I will not work on Windows by myself because making the library work on Linux is a bit of a challenge itself. What is your library? You might be able to just

Re: How to print unicode characters (no library)?

2021-12-28 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 07:03:25 UTC, rempas wrote: I already knew about some of this "escape codes" but I full list of them will come in handy ;) https://invisible-island.net/xterm/ctlseqs/ctlseqs.html and that's not quite full either. it really is a mess from hell

Re: How to print unicode characters (no library)?

2021-12-28 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 06:46:57 UTC, ag0aep6g wrote: It's actually just the first byte that tells you how many are in the sequence. The continuation bytes don't have redundancies for that. Right, but they do have that high bit set and next bit clear so you can tell you're in the

Re: How to print unicode characters (no library)?

2021-12-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 27 December 2021 at 15:26:16 UTC, H. S. Teoh wrote: A lot of modern Linux applications don't even work properly under anything non-UTF-8 yeah, you're supposed to check the locale but since so many people just assume that's becoming the new de facto reality just like how people

Re: How to print unicode characters (no library)?

2021-12-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 27 December 2021 at 11:21:54 UTC, rempas wrote: So should I just use UTF-8 only for Linux? Most unix things do utf-8 more often than not, but technically you are supposed to check the locale and change the terminal settings to do it right. But what about Windows? You should

Re: How to print unicode characters (no library)?

2021-12-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 27 December 2021 at 07:12:24 UTC, rempas wrote: Oh yeah. About that, I wasn't given a demonstration of how it works so I forgot about it. I saw that in Unicode you can combine some code points to get different results but I never saw how that happens in practice. The emoji is one

Re: Double bracket "{{" for scoping static foreach is no longer part of D

2021-12-22 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 22 December 2021 at 15:57:29 UTC, data pulverizer wrote: I noticed that the double bracket `{{` for scoping `static foreach` is no longer part of D and it looks like it has been replaced with https://dlang.org/changelog/2.098.0.html#AliasAssign None of these things have

Re: How to properly use variadic templates (functions)?

2021-12-20 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 20 December 2021 at 21:26:45 UTC, rempas wrote: // Suppose all 'args' are of type "string" for this example still use foreach(arg; args) and skip that index variable.

Re: How to pass a class by (const) reference to C++

2021-12-15 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 10:54:45 UTC, Jan wrote: Someone with more in-depth knowledge told me, that Windows support in D and specifically DLL support is lacking quite a bit. gdc and ldc have the same full support you'd expect coming from microsoft c++. dmd doesn't though. You can

Re: Passing a derived class where base class is defined as ref parameter

2021-12-14 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 14 December 2021 at 17:20:18 UTC, chopchop wrote: I am using the "ref" here (I put tinyurl to avoid over-referencing the post instead of the github page itself): https://tinyurl.com/bdddkmub yeah D classes are automatically ref unlike c++ so you don't need the second level of it

Re: Passing a derived class where base class is defined as ref parameter

2021-12-13 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 13 December 2021 at 22:06:45 UTC, chopchop wrote: If I remove the ref, it works as expected, that is to say I can give a derived class as parameter. Why are you using the ref to begin with? What the logic here? Consider this: class C : A {} void incr(ref A a) { a = new C;

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