Re: Deriving a struct from another one via template: Easy way to propagate UDAs?

2024-03-17 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 16 March 2024 at 20:34:57 UTC, Inkrementator wrote: Nice. Btw I vaguely remember you also wrote about how and why to reduce the usage string mixins, with some real example of alternative techniques you used go to the main page: http://dpldocs.info/this-week-in-d/Blog.html and

Re: Deriving a struct from another one via template: Easy way to propagate UDAs?

2024-03-16 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 14 March 2024 at 23:19:37 UTC, Inkrementator wrote: * Is UDA propagation possible without string mixins? @(__traits(getAttributes, thingYouWantToForward)) void yourNewThing() {} * Are template mixins vulnerable to name collisions?

Re: Non-blocking keyboard input

2023-12-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 27 December 2023 at 05:07:04 UTC, Joe wrote: ??? Surely there there is a one liner library solution for this? It is not one line because it needs a bit of setup (and teardown, but the objects' destructors do that for you) but it is close:

Re: SIGSEGV (Segmentation Fault) upon setting character in char array (object member var)

2023-12-19 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 19 December 2023 at 13:10:40 UTC, John Kiro wrote: class Test { static enum MAX = 10; uint index = 0; auto intArray = new int[MAX]; auto charArray = new char[MAX]; This is run at compile time, and the compiler treats any char array at compile time

Re: Operator "+=" overloading for class?

2023-12-16 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 17 December 2023 at 04:13:20 UTC, Ki Rill wrote: auto opOpAssign(string op)(in ElementType rhs) { mixin("return this" ~ op ~ "rhs;"); } ``` check what `op` is. pretty sure it is "+" not "+=" so your element isnt' saved anywhere. also a bit iffy there isn't a member here to

Re: Is it possible to set/override the name of the source file when piping it into DMD via stdin?

2023-12-13 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 13 December 2023 at 19:37:09 UTC, Siarhei Siamashka wrote: Now I'm curious. Is it possible to somehow communicate the real source file name to `dmd`, so that it shows up in the error log instead of "__stdin.d"? the sequence `#line "filename.d" 1` at the top of the thing might

Re: question

2023-12-13 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 13 December 2023 at 12:49:14 UTC, fred wrote: a bug ? It helps if you explain what you're talking about so we don't have to guess. I tried the code on my computer and it worked fine. But then figuring, you must be saying something doesn't work right, I tried it on another

Re: union default initialization values

2023-12-05 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 5 December 2023 at 19:24:51 UTC, confuzzled wrote: Given the following union union F { double x; struct { ulong lo; ulong hi; } } The default value of this would be `double.init`, since the first member of the union is a `double`, which is a kind of

Re: struct initializer

2023-12-01 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 1 December 2023 at 13:02:06 UTC, Dom DiSc wrote: Either allow it for all initializations, or get rid of it, like DIP 1031 suggested. I thought the decision actually was made to just get rid of it.

Re: 'typeof' question

2023-11-28 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 28 November 2023 at 18:41:49 UTC, DLearner wrote: A* A_Ptr; struct B { int BFld2; typeof(A_Ptr)[0..($-1)] ASUB; // Idea is ASUB of type A, from A_Ptr of type A*. I think what you really want is typeof(*A_Ptr) ASUB; the typeof thing returns the type you'd get from the

Re: Why this compiles?

2023-11-26 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 26 November 2023 at 21:45:21 UTC, Antonio wrote: In this example, ```a``` and ```b``` vars are not of the same type and don't implement the same interface. **why ```assert(a==b)``` compiles?** They're both subclasses of Object and inherit a generic opEquals from that base.

Re: mixin under -betterC

2023-11-26 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 23 November 2023 at 16:33:52 UTC, DLearner wrote: string mxnTest(string strVar1, string strVar2) { return `(int Var1, int Var2) { if (Var1 > Var2) { return true; } else { return false; } }(` ~ strVar1 ~ `,` ~ strVar2 ~ `)`; } ``` This

Re: under gdb: received signal SIG34, Real-time event 34.; received signal SIG35, Real-time event 35

2023-11-14 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 14 November 2023 at 21:31:39 UTC, mw wrote: handle SIGUSR1 noprint handle SIGUSR2 noprint These are what the GC used to use to stop/start threads. received signal SIG34, Real-time event 34. received signal SIG35, Real-time event 35. And this is what it uses now. druntime just

Re: D: How do I pipe (|) through three programs using std.process?

2023-11-12 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 12 November 2023 at 13:39:25 UTC, BoQsc wrote: However the question of why `spawnProcess(["find", "string to find"]` is not working and produces error is still unresolved. spawnProcess always encodes its arguments in a very specific way and the receiving programs are not always

Re: why remove octal literal support?

2023-11-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 3 November 2023 at 15:07:41 UTC, d007 wrote: dlang is know for compile speed, but in reality d project compile slow because so much ctfe and tempalte. Some ctfe and templates are slow. Usually larger functions or array/string append loops end up being to blame. Octal literals

Re: Keyword "package" prevents from importing a package module "package.d"

2023-11-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 3 November 2023 at 00:19:48 UTC, Andrey Zherikov wrote: Is there any guide how one can refactor single-module package into multi-module package with distinction between public and private modules? Call the modules literally anything else and it works better. So say you have module

Re: Keyword "package" prevents from importing a package module "package.d"

2023-11-02 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 2 November 2023 at 19:30:58 UTC, Jonathan M Davis wrote: The entire reason that it was added to the language was to be able to split up existing modules without breaking code. And it does that well. No, it doesn't do that well at all. In fact, it does that so extremely poorly

Re: Keyword "package" prevents from importing a package module "package.d"

2023-11-02 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 2 November 2023 at 12:52:35 UTC, BoQsc wrote: Therefore the need to import `package.d` is needed and I can't see a solution, which means tbh package.d should never be used. It is a poorly designed, buggy misfeature of the language with plenty of better working alternatives (it

Re: use dmd for bare metal i386

2023-10-13 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 13 October 2023 at 22:14:36 UTC, Dmitry Ponyatov wrote: Is dmd able to be forced not include some unneeded information into target object files to make bare metal 32-bit code? Need some samples and build scripts to do it. Make an empty file called object.d in your build directory

Re: Straight Forward Arrays

2023-10-01 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 1 October 2023 at 09:01:53 UTC, dhs wrote: When D creates a dynamic array, it returns a slice. Functions that add or remove elements begin by asking the memory manager for the dynamic array that the slice belongs to. Only then can they go on and add elements. Why is this a

Re: Is this a ctfe bugs ? ref scope const(ubyte)[32]

2023-09-06 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 6 September 2023 at 12:04:40 UTC, d007 wrote: extern(C) int test(ref scope const(ubyte)[32] b); extern(C) int test(ref scope const(ubyte[32]) b); These are the same thing since the ref cannot be rebound anyway; a static array just is its contents.

Re: parallel threads stalls until all thread batches are finished.

2023-08-25 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 23 August 2023 at 13:03:36 UTC, Joe wrote: to download files from the internet. Are they particularly big files? You might consider using one of the other libs that does it all in one thread. (i ask about size cuz mine ive never tested doing big files at once, i usually use it

Re: How to create an .exe without execute the terminal in Windows?

2023-08-12 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 12 August 2023 at 23:13:39 UTC, thePengüin wrote: I would know how to make some this but in Dlang: best way is to use the linker switch. On Win32, you can pass -L/subsystem:windows if you don't want a console to be automatically allocated. Please note when compiling on

Re: pragma lib doesn't support static libraries?

2023-07-30 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 30 July 2023 at 05:53:55 UTC, Mike Parker wrote: And I'm unaware of any mechanism for embedding static library names in an object file for a linker to read later. There is a mechanism on Windows, so it tends to work there, but yeah no luck on the other platforms.

Re: Unicode in strings

2023-07-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 27 July 2023 at 22:15:47 UTC, Cecil Ward wrote: How do I get a wstring or dstring with a code point of 0xA0 in it ? note that you don't need wstring and dstring to express all unicode strings.

Re: array index out of bound may not throw exception?

2023-07-21 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 21 July 2023 at 21:27:45 UTC, mw wrote: However, I just debugged a case, where out of bound array index didn't throw exception, and just hang the thread Uncaught exceptions in a thread terminate that thread and are reported when you call the `join` method of the thread. I think

Re: Redirecting standard streams in Windows

2023-07-18 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 18 July 2023 at 23:52:06 UTC, Alexander Zhirov wrote: PS C:\dlang\test> cat .\stderr.txt How does the cat program know what the encoding of the file is? Try opening it in notepad or something and specifying the encoding. I betcha it is perfectly fine.

Re: Redirecting standard streams in Windows

2023-07-18 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 18 July 2023 at 21:31:54 UTC, Alexander Zhirov wrote: HANDLE h_stdout = GetStdHandle(STD_OUTPUT_HANDLE); WriteConsoleW(h_stderr, str.ptr, cast(DWORD)str.length, NULL, NULL); If you checked the return value of this call, you'd find it fails since WriteConsole only works

Re: Inlined functions and their original bodies - bloat

2023-07-09 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 9 July 2023 at 18:05:48 UTC, Cecil Ward wrote: This is with full -O3 optimisation try -fvisibility=hidden -release sux btw

Re: Reading an environment variable value

2023-06-29 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 29 June 2023 at 18:47:48 UTC, Josh Holtrop wrote: $ ldc2 -of environment environment.d Since you named the file `environment.d` and didn't use an explicit `module name.thing;` declaration, the compiler assumes it should match the filename. So it injects an implicit `module

Re: pragma msg field name?

2023-06-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 27 June 2023 at 22:20:22 UTC, Chris Katko wrote: pragma(msg, t.stringof); // does not see any new fields! D's declarations are all order-independent, in theory those foreaches are done simultaneously, so it is kinda a race condition. In practice, the compiler

Re: pragma msg field name?

2023-06-27 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 27 June 2023 at 04:25:13 UTC, Chris Katko wrote: How do I get just the field name? __traits(identifier, field) And why does it think this is a run-time value? It is the same as if you wrote `Class.field`

Re: Mixin and compile-time functions for code generation

2023-06-24 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 24 June 2023 at 17:31:31 UTC, Cecil Ward wrote: Can I get mixin whatever to do this for me? Mixin with a function that runs at compile-time and creates the required source ? have you tried it?

Re: Union with bits ?

2023-06-14 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 14 June 2023 at 08:51:19 UTC, Rene Zwanenburg wrote: You can do something like this if you don't mind compiling with -preview=bitfields: That doesn't do what you think it does. There's no guarantee the bits will actually line up with the status byte. The best way to do what

Re: How get struct value by member name string ?

2023-05-29 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 29 May 2023 at 09:35:11 UTC, John Xu wrote: Error: variable `column` cannot be read at compile time you should generally getMember on a variable T t; __traits(getMember, t, "name") like that, that's as if you wrote t.name

Re: Complicated @property access only works when I write an extra parenthesis "()"

2023-05-26 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 26 May 2023 at 21:00:20 UTC, realhet wrote: Only the extra () let it compile successfuly. No way to fix it. If the function takes an extra argument you can kinda trick it but for zero arg function pointer return from a property it is just plain broken and has been the whole time.

Re: Given an object, how to call an alias to a member function on it?

2023-05-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 2 May 2023 at 13:57:23 UTC, Steven Schveighoffer wrote: Isn't that what `__traits(child)` is for? https://dlang.org/spec/traits.html#child Yes, __traits(child, object, method_alias)(args) is the way to do it.

Re: std.socket tutorials? examples?

2023-04-30 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 30 April 2023 at 22:10:31 UTC, Cecil Ward wrote: How do we wait for an ‘or’ of multiple asynchronous events in this kind of code? You can set a timeout value for Socket.select, but Phobos isn't going to help you with anything other than sockets and timeouts (despite the fact the

Re: A Programmer's Dilema: juggling with C, BetterC, D, Macros and Cross Compiling, etc.

2023-04-30 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 30 April 2023 at 17:51:15 UTC, Eric P626 wrote: * Use D for everything, no C compatibility. This is a false dilemma: D has full C compatibility.

Re: std.socket tutorials? examples?

2023-04-29 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 29 April 2023 at 10:56:46 UTC, Jan Allersma wrote: auto clientResult = Socket.select(clientSet, null, null); There's probably nothing in clientSet, so it is waiting for nothing you almost always want to have just one call to select in the program, not two, the whole point

Re: DlangUI Layout Justification

2023-04-07 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 7 April 2023 at 15:52:02 UTC, Ali Çehreli wrote: I don't know how relevant it is but there is also Hipreme Engine that supports Android: I think the question is if you are doing games vs doing other applications. There's some overlap between game and gui, but not actually that

Re: Why are globals set to tls by default? and why is fast code ugly by default?

2023-04-01 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 1 April 2023 at 13:11:46 UTC, Guillaume Piolat wrote: TLS could be explicit and we wouldn't need a -vtls flag. Yeah, I think what we should do is make each thing be explicitly marked. When I want tls, I tend to comment that it was intentional anyway to make it clear I didn't

Re: Read a text file at once for regex searching

2023-03-20 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 20 March 2023 at 17:42:17 UTC, Paul wrote: Do we have some such function in our std library? Try static import std.file; string s = std.file.readText("filename.txt"); http://phobos.dpldocs.info/std.file.readText.html

Re: Code organization, dub, etc.

2023-03-13 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 13 March 2023 at 13:20:21 UTC, Joe wrote: Yeah, it seems like it's *only* for libraries (and a few single-exe utilities). Looking at code.dlang.org, under "Stand-alone applications/Server software", the top rated item is "handy-httpd" which according to its dub.json builds a

Re: 'auto' keyword

2023-03-12 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 12 March 2023 at 13:07:58 UTC, DLearner wrote: Is it correct that this _single_ keyword is used to indicate _two_ quite different things: No, it only actually does #2 in your thing. The type is optional meaning *any* storage class will work for type inference. `auto` is not

Re: Desiring bool any_key_pressed()

2023-03-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 3 March 2023 at 03:38:56 UTC, Daren Scot Wilson wrote: Here is a very simple version of the program I'm working on. Is there a way to write is_any_key_pressed() that doesn't block, doesn't require the Enter key, and doesn't require dragging in any complex libraries or dealing with

Re: Can't load FreeImage.dll with Windows

2023-03-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 3 March 2023 at 19:07:14 UTC, WhatMeWorry wrote: loadFreeImage(`c:\Users\Admin\Downloads\FreeImage3180Win32Win64\FreeImage\Dist\x64\FreeImage.dll`); is your application build 64 bit too?

Re: How to get only the field name from an alias?

2023-02-21 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 21 February 2023 at 02:41:34 UTC, Elfstone wrote: apparently F.stringof You almost never want to use .stringof, instead try __traits(identifier, F) and see what it gives you. Alternatively, loop over __traits(allMembers) which gives you the member names and pass that down. You

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-18 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 18 February 2023 at 21:23:24 UTC, ProtectAndHide wrote: The more I look at D, the more I like C++. cya

Re: Want a module to import from a sister directork; How?

2023-02-14 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 14 February 2023 at 21:23:26 UTC, ryuukk_ wrote: module name must correspond to its path this is not true.

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-09 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 9 February 2023 at 13:00:04 UTC, thebluepandabear wrote: For my school I am commissioned to create many types of software. I tried to have a look at some of the gui kits in D but there was no tutorial for how to use them and they seemed as if they are lacking features in

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-02-09 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 9 February 2023 at 12:31:03 UTC, thebluepandabear wrote: I am actually taking a computer science class and I need to create desktop apps to pass and get through school. This is pretty easy in D. Like what specific kind of desktop app?

Re: betterC DLL in Windows

2023-02-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 4 February 2023 at 18:40:51 UTC, Tamas wrote: I do take your word for it, but now I have to re-evaluate my expectations towards D and perhaps use it for another project. I've got most of my project working in C already, but I was hoping to add some safety and better

Re: betterC DLL in Windows

2023-02-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 4 February 2023 at 19:49:41 UTC, bachmeier wrote: I'm not sure what Adam's getting at when he says "hopelessly broken" but it's basically a subset of D. You're almost guaranteed to hit some wall with it and have no solution. Some of these are bugs but some of them are by design;

Re: betterC DLL in Windows

2023-02-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 4 February 2023 at 18:11:05 UTC, Tamas wrote: Well, as I'm new to D this isn't something I have insight into. Then you'd probably be better off taking my word for it (or even trusting your own limited experience where things worked until you added the switch) and just not using

Re: betterC DLL in Windows

2023-02-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 4 February 2023 at 16:45:31 UTC, Tamas wrote: and they compile without `-betterC`, but fail with link errors when using the switch. then don't use the switch lol -betterC is barely supported and completely useless so better to just not use it. export extern (C) void main()

Re: Which TOML package, or SDLang?

2023-01-30 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 30 January 2023 at 15:37:56 UTC, Guillaume Piolat wrote: Why not XML? :) It has comments, you can use backslashes too. no kidding, xml is an underrated format.

Re: Non-ugly ways to implement a 'static' class or namespace?

2023-01-22 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 23 January 2023 at 00:21:12 UTC, thebluepandabear wrote: there's nothing in the language currently that would 'force' the user Why do you hate freedom?

Re: How to write a library

2023-01-21 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 21 January 2023 at 22:53:19 UTC, Matt wrote: but what is the D equivalent to header files, and what do I have to do to prepare and use my library in another project? The most common and easiest thing in D is to just distribute the source files, the compiler can pull whatever it

Re: Is there a way to get a template’s parameters and constraints?

2023-01-20 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 20 January 2023 at 17:15:31 UTC, Quirin Schroll wrote: Is there a trait (or a combination of traits) that gives me the constraints of a template? No, reflection over templates is very limited.

Re: D Static Array

2023-01-15 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 15 January 2023 at 14:23:59 UTC, Salih Dincer wrote:    int[0] arr = 40; // ? The = 40 means fill all array entries with the number 40. The [0] means there are no array elements. So it filled all the 0 elements with the number 40. If it was like int[3] arr = 40, then arr[0],

Re: Mixin helper help

2023-01-14 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 14 January 2023 at 18:57:21 UTC, John Chapman wrote: I wanted to remove the double braces in my static foreach (needed as I declared some aliases inside but since it creates a scope those new variables can't be referred to outside of it). Inside a function, you can often just use

Re: Failed to archive JPEG (ArchiveMember): Invalid UTF-8 sequence (at index 1)

2023-01-13 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 14 January 2023 at 01:08:25 UTC, Ki Rill wrote: a JPEG image. member.expandedData(file.readText().dup().representation()); A jpeg image is not a text file. Read it with `std.file.read()` instead of `readText`. Then you can get rid of those useless dup.representation calls

Re: enum functions

2023-01-10 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 8 January 2023 at 18:42:58 UTC, Salih Dincer wrote: I'm wondering 2 things; firstly, does having an enum mean there is no auto-return? Or could it be CTFE? It means nothing. The keyword tells the parser a function is about to begin, which triggers return type inference (exactly the

Re: Error "Outer Function Context is Needed" when class declared in unittest

2023-01-05 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 5 January 2023 at 16:38:49 UTC, Vijay Nayar wrote: Does that class inherit the scope of the function it is inside, similar to how an inner class does with an outer class? yup. They can see the local variables from the function.

Re: Error "Outer Function Context is Needed" when class declared in unittest

2023-01-05 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 5 January 2023 at 13:27:23 UTC, Vijay Nayar wrote: Why is this error only found when declaring a class in the unittest? A unittest is just a special function, it can run code and have local variables. classes and structs declared inside it have access to those local contexts,

Re: Vibe.d MongoDB database connection

2022-12-26 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 26 December 2022 at 21:32:51 UTC, eXodiquas wrote: I looked a bit closer into the problem and I found an issue in the vibe.d repository that states that the current version of vibe.d is not compatible with MongoDB version >= 5.1 the mongo driver in the standalone package shares

Re: [Win32 API] MessageBox Example without MSVCR120.dll dependency

2022-12-25 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 25 December 2022 at 18:30:12 UTC, BoQsc wrote: This is a working Hello World example without dependency on Microsoft C Runtime Library you might also consider using `-m32omf` switch to dmd which will make it bundle the old digital mars c lib. this is generally worse but since it

Re: How to create a API server?

2022-12-18 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 18 December 2022 at 09:34:06 UTC, TTK Ciar wrote: Oops, wrong module!! I meant arsd.cgi, very sorry! Yes, http2.d is the client side for http, arsd.cgi implements the http server.

Re: _Symbols _with _leading _underscores

2022-12-17 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 17 December 2022 at 02:42:22 UTC, Paul wrote: Are the leading underscores significant, in general, in the D language? The code you linked is a copy/paste from some C runtime library code, where the leading __ is the convention to indicate it is part of the private platform

Re: arsd.jni

2022-12-12 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 12 December 2022 at 11:17:47 UTC, jni wrote: It's good. But you did the java bindings by hand or is there a generator in arsd.jni for that too? It does it automatically. You compile jni.d with `-version=WithClassLoadSupport` and then write a main function that calls

Re: arsd.jni

2022-12-11 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 12 December 2022 at 01:19:23 UTC, jni wrote: The boilerplate is easy but Then the other part is a problem for me is the necessary other Java classes. They are not part of the NDK so the only way to load the jar is to use jni? Is that correct? I haven't updated this for a

Re: arsd.jni

2022-12-11 Thread Adam D Ruppe via Digitalmars-d-learn
I don't know how to do much of anything on Android, but if you can post a small Java code example, I can suggest how to use it from D. You can bind many classes through the jni. The biggest limitation is you can't do callbacks or subclasses through android jni, so it is kinda limited for

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 4 December 2022 at 22:46:52 UTC, Ali Çehreli wrote: That's way beyond my pay grade. Explain please. :) The reason that the GC stops threads right now is to ensure that something doesn't change in the middle of its analysis. Consider for example, the GC scans address 0 - 1000 and

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 4 December 2022 at 21:55:52 UTC, Siarhei Siamashka wrote: Do you mean the top of the https://code.dlang.org/?sort=score=library list? Well, I was referring to the five that appear on the homepage, which shows silly instead of emsi containers. How do you know that they embrace

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 4 December 2022 at 17:53:00 UTC, Adam D Ruppe wrote: Interesting... you know, maybe D's GC should formally expose a mutex that you can synchronize on for when it is running. .. or compile in write barriers. then it doesn't matter if the thread is unregistered, the write

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 4 December 2022 at 16:02:28 UTC, Ali Çehreli wrote: D's GC needed to stop the world, which meant it would have to know what threads were running. You can never be sure whether your D library function is being called from a thread you've known or whether the Java runtime (or other

Re: Idiomatic D using GC as a library writer

2022-12-04 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 4 December 2022 at 09:53:41 UTC, vushu wrote: What are your thoughts about using GC as a library writer? Do it. It is lots of gain for very little loss. If you wan't to include a library into your project aren't you more inclined to use a library which is gc free? No, GC free

Re: How do you print all Unicode characters in a range - I want the subscripts, can't google a range of Unicode.

2022-12-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 3 December 2022 at 14:43:15 UTC, Adam D Ruppe wrote: The problem is just that writeln to the console is broken. You can either write to a function instead and load it in a text editor aaargh not to a "function" i meant to a "file". like auto f = File("test.txt", "wt");

Re: How do you print all Unicode characters in a range - I want the subscripts, can't google a range of Unicode.

2022-12-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 2 December 2022 at 05:27:40 UTC, Daniel Donnelly, Jr. wrote: Doesn't work. The result I get is shit: The problem is just that writeln to the console is broken. You can either write to a function instead and load it in a text editor, or use a non-broken writeln like my

Re: How do you print all Unicode characters in a range - I want the subscripts, can't google a range of Unicode.

2022-12-03 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 3 December 2022 at 14:43:15 UTC, Adam D Ruppe wrote: import arsd.terminal; oh yeah my module: can download direct and compile with your program https://github.com/adamdruppe/arsd/blob/master/terminal.d or it is also on dub

Re: Why can't D store all UTF-8 code units in char type? (not really understanding explanation)

2022-12-02 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 2 December 2022 at 21:26:40 UTC, rikki cattermole wrote: char is always UTF-8 codepoint and therefore exactly 1 byte. wchar is always UTF-16 codepoint and therefore exactly 2 bytes. dchar is always UTF-32 codepoint and therefore exactly 4 bytes; You mean "code unit". There's no such

Re: Why can't D store all UTF-8 code units in char type? (not really understanding explanation)

2022-12-02 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 2 December 2022 at 21:18:44 UTC, thebluepandabear wrote: It's his explanation as to why this code doesn't compile even though Ğ is a UTF-8 code unit: That's not a utf-8 code unit. A utf-8 code unit is just a single byte with a particular interpretation. If I do `char.sizeof`

Re: Is it just me, or does vibe.d's api doc look strange?

2022-12-02 Thread Adam D Ruppe via Digitalmars-d-learn
On Friday, 2 December 2022 at 20:46:35 UTC, Christian Köstlin wrote: Please see this screenshot: https://imgur.com/Ez9TcqD of my browser (firefox or chrome) of https://vibed.org/api/vibe.web.auth/ Not just you, there's something broken in their html. You can use my website for vibe docs

Re: Syntax Sugar for Initializing a Fixed float Array as void*?

2022-11-30 Thread Adam D Ruppe via Digitalmars-d-learn
On Thursday, 1 December 2022 at 00:39:21 UTC, jwatson-CO-edu wrote: Is there a way to write a single statement that creates a void pointer that points to an initialized float array? void* f = [1.0f, 1.0f, 1.0f].ptr; Though I'd recommend keeping it typed as float[] until the last

Re: pragma(linkerDirective,_) removes double quotes, dmd ignores LIB

2022-11-28 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 28 November 2022 at 14:19:46 UTC, NonNull wrote: double quotes whatsoever into the linker command line via pragma(linkerDirective,_). linkerDirective doesn't add things to the linker command line at all. https://dlang.org/spec/pragma.html#linkerDirective "Implementation Defined:

Re: Seeking in arsd.simpleaudio?

2022-11-20 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 20 November 2022 at 23:03:49 UTC, Adam D Ruppe wrote: Looking at doing it for mp3 is why I didn't put it in the interface yet... my mp3 code ported to D doesn't have a seek function! This is fixed on my computer now too, just need to check the rest of the bugs. So mp3 support will

Re: Seeking in arsd.simpleaudio?

2022-11-20 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 20 November 2022 at 20:23:28 UTC, TheZipCreator wrote: and it appears that arsd.simpleaudio doesn't have a seek function. Is there a way to do this via other means? I want something like: Here's the patch for ogg, you can download those two files off git master too (i can't tag

Re: Seeking in arsd.simpleaudio?

2022-11-20 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 20 November 2022 at 22:26:26 UTC, TheZipCreator wrote: I guess in the meantime I'll just use a python script to cut the audio before execution i found the problem the library called seek(-thing) and my seek had a if(x <= 0) return; when it should have been if(x == 0) return. so

Re: Seeking in arsd.simpleaudio?

2022-11-20 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 20 November 2022 at 20:34:44 UTC, Adam D Ruppe wrote: i'll get back to you in a lil i went overbudget lol. but yeah the seek function in the underlying lib fails and idk why it is so hard to even trace what error actually happened in these C codebases

Re: Seeking in arsd.simpleaudio?

2022-11-20 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 20 November 2022 at 20:23:28 UTC, TheZipCreator wrote: so how would you implement this hypothetical `seek` function? (or if you could tell me a different library that already has this functionality that'd be great too) My underlying vorbis lib has it, but haven't added to the

Re: Can we ease WASM in D ?

2022-11-16 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 16 November 2022 at 23:16:26 UTC, H. S. Teoh wrote: You mean with Phobos and everything included? I think there may be issues with that... Yes, this is a problem, but I think I have a solution: defer GC runs until javascript is running. There's also some llvm features that

Re: Can we ease WASM in D ?

2022-11-16 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 16 November 2022 at 22:51:31 UTC, bioinfornatics wrote: And since then I ask myself can we at compile time convert a D code to an extern C code for wasm ? It would be pretty cool if you could just mark `@wasm` on a function and have it magically convert... the dcompute thing i

Re: Why am I getting different array size depending where I calling?

2022-11-14 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 14 November 2022 at 21:00:38 UTC, matheus wrote: void[] getFoo(){ writeln(cast(int[])bar); auto foo = getFoo(); writeln(foo); Prints: [1, 0] [2, 0, 0, 0, 0, 0, 0, 0] Looking through godbolt.org the ASM generated with both So why the array generated from getFoo() is 4

Re: Using glibc headers with ImportC

2022-11-12 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 12 November 2022 at 14:39:14 UTC, qua wrote: Do I have to do anything else? I've read that importc doesn't have a preprocessor and I assume it is related to that, however "ImportC can automatically run the C preprocessor associated with the Associated C Compiler". I still don't

Re: Using glibc headers with ImportC

2022-11-12 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 12 November 2022 at 13:46:27 UTC, qua wrote: This is supposed to work, right? No, it isn't. And it probably never will. importC looks for a .c file in the current directory. It is that .c file's responsibility to #include whatever .h files you want.

Re: My new programming book ...

2022-11-08 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 7 November 2022 at 06:10:46 UTC, zjh wrote: How is your `minigui`? Please write an `introduction` when you have time. It is on my list but minigui is a pretty simple class collection of basic widgets. It works pretty well now. I don't have too many intro examples yet though. My

Re: My new programming book ...

2022-11-08 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 7 November 2022 at 04:54:05 UTC, ikelaiah wrote: I'm aware of the publication date. However, I find the content still highly relevant to many day-to-day tasks (my use case). Yeah, I tried to focus more on the ideas behind it than the specifics of a library. My thought is if you

Re: Passing a string by reference

2022-11-08 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 8 November 2022 at 12:30:50 UTC, Alexander Zhirov wrote: Do I understand correctly that in order for me to pass a string when creating an object, I must pass it by value? You should almost never use `ref string`. Just use plain `string`. In fact, ref in general in D is a lot more

Re: My new programming book ...

2022-11-06 Thread Adam D Ruppe via Digitalmars-d-learn
On Monday, 7 November 2022 at 00:55:33 UTC, zjh wrote: Is there a second edition? After all, it has been many years. No, but not that much has changed and you can always post here with questions.

  1   2   3   4   5   6   7   8   9   10   >