Re: What is the 'Result' type even for?

2023-01-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/19/23 10:11 PM, Ruby The Roobster wrote: Take this example: ```d import std; void main() {     auto c = "a|b|c|d|e".splitter('|');     c.writeln;     string[] e = ["a", "b", "c", "d", "e"];     assert(c.equal(e));     typeof(c).stringof.writeln; } ``` The program prints: ["a", "b",

Re: Vibe.d Diet Templatesand Forms

2023-01-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/19/23 6:24 PM, seany wrote: Hello Please consider this diet template:     doctype html     html(lang="es", dir="ltr")     head     meta(name="viewport", content="width=device-width, user-scalable=no, initial-scale=1.0")    

Beerconf January 2023

2023-01-14 Thread Steven Schveighoffer via Digitalmars-d-announce
# BEERCONF! Happy new year! Beerconf this month falls on January 28-29. It may seem like it's been a while, and that's because it has. Dconf online last month moved up the gathering by a couple weeks, and so we will be 6 weeks out from the last one. The last one was pretty good, with many of

Re: Nested sibling classes

2023-01-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/12/23 12:05 PM, seany wrote: How can I make it, that classes b and c can access each other, and create instances of each other freely? Thank you. So to just point out something that wasn't discussed by Salih: When you declare a field of a class with an initializer, *that initializer

Re: enum functions

2023-01-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/10/23 7:55 AM, Adam D Ruppe wrote: 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

Re: what wrong with this alias

2023-01-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/8/23 12:42 AM, Qusatlegadus wrote:     auto s = 1234.to!string.map!q{a - '0'}.sum; works fine. but if i do an alias     alias comb = to!string.map!q{a - '0'}     Error: unknown, please file report on issues.dlang.org What's wrong with this alias? Aside from the problem with the

Re: Address of a class object

2023-01-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/4/23 2:27 PM, Ali Çehreli wrote: On 1/4/23 10:48, H. S. Teoh wrote: > Allocations are not necessarily consecutive; the GC may have its own > strategy of allocation that doesn't follow a linear sequence. That was one of my guesses. So, I put the objects into a 2-length static array but

Re: Is there such a JSON parser?

2023-01-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/1/23 6:28 PM, torhu wrote: I need to parse some JSON data into various data structures, so I'm looking for a parser based on events or ranges. One that doesn't just load the file and build a data structure that represents the whole thing. So not std.json, at least. It's pretty

Re: Compile time vs run time -- what is the difference?

2022-12-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/27/22 9:31 PM, thebluepandabear wrote: I am reading through the free book on learning D by Ali Çehreli and I am having difficulties understanding the difference between compile time execution and run time execution in D language. Compile time execution is running your code being

Re: Can you simplify nested Indexed types?

2022-12-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/27/22 10:31 AM, Sergei Nosov wrote: On Tuesday, 27 December 2022 at 15:20:24 UTC, Salih Dincer wrote: On Tuesday, 27 December 2022 at 15:09:11 UTC, Sergei Nosov wrote: Consider, I have the following code: ```d     auto a = [3, 6, 2, 1, 5, 4, 0];     auto indicies = iota(3);     auto ai

Re: Preventing nested struct destructor accessing stack frame

2022-12-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/16/22 7:17 AM, Nick Treleaven wrote: This code segfaults when the GC calls the dtor after the unittest succeeds: ```d unittest {     int i;     struct S     {     ~this() { i++; }     }     (*new S).destroy; } ``` It seems destroy clears the context pointer. Is there a way to

Re: Confusion about `Random`

2022-12-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/23/22 10:07 AM, jwatson-CO-edu wrote: On Friday, 23 December 2022 at 00:58:01 UTC, Steven Schveighoffer wrote: Without the rest of the code, and how random is called, I have a hunch... Are you using threads by any chance? If, for instance, your calls to rand01 are done in a new thread

Re: Confusion about `Random`

2022-12-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/22/22 11:23 AM, jwatson-CO-edu wrote: I am confused about why Program 1 produces random output but Program 2 does not. --- ### Program 1 ```d import std.stdio; import std.conv; import std.random; Mt19937 rnd; double rand01(){     // Uniform random sampling in [0,1)     return

Re: How to use version in dub?

2022-12-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/13/22 3:35 PM, ryuukk_ wrote: On Tuesday, 13 December 2022 at 20:01:40 UTC, torhu wrote: On Tuesday, 13 December 2022 at 19:50:15 UTC, torhu wrote: On Tuesday, 13 December 2022 at 19:28:44 UTC, Leonardo A wrote: Hello. How to use version in dub? https://dlang.org/spec/version.html "The

Re: How to compiler dlang code on Apple M1?

2022-12-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/13/22 10:20 AM, Steven Schveighoffer wrote: Yeah, that's a known issue: https://github.com/ldc-developers/ldc/issues/3864 Try building with `-b plain` to avoid the debug build Oh, also, I have MACOSX_DEPLOYMENT_TARGET=11 in my environment, that helps to avoid it as well. -Steve

Re: How to compiler dlang code on Apple M1?

2022-12-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/13/22 9:35 AM, zoujiaqing wrote: On Saturday, 3 December 2022 at 20:33:59 UTC, Steven Schveighoffer wrote: The issue is dub. Make sure you are using the dub built for ARM. What Apple does is if any program in the same process group is x86 specific, then all the executed programs

Re: Is remove safe using foreach

2022-12-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/13/22 6:22 AM, Per Nordlöw wrote: On Monday, 12 December 2022 at 17:29:00 UTC, Steven Schveighoffer wrote: Removing keys while iterating is not supported. It will break, in confusing ways, and possibly include a null pointer dereference. IRC, the specs says that it's an error to modify

Re: Is remove safe using foreach

2022-12-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/12/22 8:45 PM, Steven Schveighoffer wrote: for(auto r = aa.byKey, auto k = r.front; !r.empty; r.popFront) err... forgot the continual front assignment I think it's more like: for(auto r = aa.byKey; !r.empty; r.popFront) { auto k = r.front; // foreach body } -Steve

Re: Is remove safe using foreach

2022-12-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/12/22 7:54 PM, lili wrote: is foreach Syntactic sugar?, like for-range in C++, if it is, compiler how implement Yes it is syntax sugar. The lowering depends on what the item you're iterating is. For an associative array `byKey`, it is converting the AA into a range of keys, and

Re: Is remove safe using foreach

2022-12-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/12/22 12:23 PM, lili wrote: ``` int[string] aa = ["ok":1, "aaa":2, "ccc":3, "ddd":4]; foreach (k ; aa.byKey) {     if (k == "aaa") {     aa.remove(k);     aa["ww"] = 33;     }     if (k == "ww") {     aa.remove(k);     aa["vv"] = 33;     }

Re: Structure initializer VS lambda function

2022-12-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/12/22 3:54 AM, realhet wrote: Hi, I'm writing a DLang parser and got confused of this. What is a good way to distinguish lambda functions and structure initialization blocks. Both of them are {} blocks. I'm thinking of something like this: 1. checking inside (on the first hierarchy

Re: Advent of Code 2022

2022-12-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 10 December 2022 at 20:49:03 UTC, Christian Köstlin wrote: Is anybody participating with dlang in the advent of code 22? It would be interesting to discuss dlang specific things from the puzzles. Mine: https://github.com/schveiguy/adventofcode -Steve

Re: Is there such concept of a list in D?

2022-12-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/10/22 1:11 AM, thebluepandabear wrote: I was wondering more if there is an object oriented way of creating arrays, like in Java there is an `ArrayList`, in C++ there is `std::vector`, etc. In D, you just use `T[]` for an array, it's similar to `std::vector`. -Steve

Re: Is there such concept of a list in D?

2022-12-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/10/22 12:46 AM, thebluepandabear wrote: In most languages there is some sort of `List` type, is that the same for D? D doesn't focus on interfaces, we have concepts, like ranges. Sorry, it's hard to answer your question without asking more questions: are you looking for a linked list?

Re: How to compiler dlang code on Apple M1?

2022-12-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/3/22 1:59 PM, zoujiaqing wrote: ``` dub build --compiler=ldc2 --arch=arm64-apple-macos     Starting Performing "debug" build using ldc2 for aarch64, arm_hardfloat.     Building taggedalgebraic 0.11.22: building configuration [library]     Building eventcore 0.9.20+commit.4.g6744ae7:

Re: Release D 2.101.0

2022-12-03 Thread Steven Schveighoffer via Digitalmars-d-announce
On 12/3/22 2:17 PM, zoujiaqing wrote: Thank you!!! When will it support Apple M1 processors? My macbook has been unable to use D for months. I can use dmd and ldc on my M1. rosetta works great, and ldc supports arm. I have not tried gdc. -Steve

Beerconf for dconf online 2022

2022-12-02 Thread Steven Schveighoffer via Digitalmars-d-announce
# BEERCONF! As it was last year, and the year before, this month's beerconf will coincide with the annual [Dconf Online](https://dconf.org/2022/online/index.html). That means December 17-18. Everything will be mostly the same, except we will probably be spending a lot of time on the actual

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

2022-12-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/2/22 4:18 PM, thebluepandabear wrote: Hello (noob question), I am reading a book about D by Ali, and he talks about the different char types: char, wchar, and dchar. He says that char stores a UTF-8 code unit, wchar stores a UTF-16 code unit, and dchar stores a UTF-32 code unit, this

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

2022-12-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/2/22 3:46 PM, 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. And Sonke is aware (there's a conversation on the dlang slack). -Steve

Re: raylib-d Gamepad Detection Fails

2022-12-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/1/22 5:50 PM, jwatson-CO-edu wrote: On Thursday, 1 December 2022 at 22:16:30 UTC, jwatson-CO-edu wrote: That was the trick, [inside the loop it detects the gamepad](https://github.com/jwatson-CO-edu/nanoverse/blob/main/d/raylib/04_jsInput/source/app.d#L35).  No other changes needed. I

Re: raylib-d Gamepad Detection Fails

2022-12-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/1/22 11:10 AM, ryuukk_ wrote: Can you try with this page: https://www.raylib.com/examples/core/loader.html?name=core_input_gamepad Does it detect your gamepad? It should work because the `IsGamepadAvailable` function call is inside the loop. That's most certainly the problem with the

Re: raylib-d Gamepad Detection Fails

2022-12-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/1/22 3:24 AM, bauss wrote: But probably not on every frame, have a delay between checks. It's not anything controllable by the user. The library does the check every frame regardless of whether you use it or not. When you call the raylib function, you are not actually querying the

Re: raylib-d Gamepad Detection Fails

2022-11-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/30/22 8:49 PM, jwatson-CO-edu wrote: Yes, following your instructions I have raylib 4.2.0 and raylib-d 4.2.4 in the project directory.  I am now using the latest version of raylib-d, but this did not resolve the gamepad issue. I can ask around on the raylib channels. Oh, I think I

Re: raylib-d Create Light Sources

2022-11-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/30/22 7:56 PM, jwatson-CO-edu wrote: uint MAX_LIGHTS = 4; This needs to be an `enum`. //... Light[MAX_LIGHTS] lights; // Error: undefined identifier `Light` The rlights header file is not part of the raylib library, but is in the examples directory, you will need to port it. It's

Re: raylib-d Gamepad Detection Fails

2022-11-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/30/22 7:28 PM, jwatson-CO-edu wrote: On Wednesday, 30 November 2022 at 23:18:33 UTC, ryuukk_ wrote: On Wednesday, 30 November 2022 at 22:46:52 UTC, jwatson-CO-edu wrote: Hello, I have this small [gamepad input test

Re: How do I _really_ implement opApply?

2022-11-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/29/22 7:50 PM, WebFreak001 wrote: (note: I don't want to use a template, this way of writing it has the advantage that the compiler checks all different code paths for errors, so the errors aren't delayed until someone actually tries to iterate over my data structure) 1. use the

Re: Beerconf Noveber 2022 -- Turkey edition

2022-11-26 Thread Steven Schveighoffer via Digitalmars-d-announce
On 11/25/22 11:40 AM, Steven Schveighoffer wrote: On 11/12/22 4:51 PM, Steven Schveighoffer wrote: ## Presentations? With dconf online so close, I'm pretty sure no presentations would be forthcoming, but if you have something, let me know, and I'll schedule it. In this upcoming beerconf

Re: Beerconf Noveber 2022 -- Turkey edition

2022-11-25 Thread Steven Schveighoffer via Digitalmars-d-announce
On 11/12/22 4:51 PM, Steven Schveighoffer wrote: ## Presentations? With dconf online so close, I'm pretty sure no presentations would be forthcoming, but if you have something, let me know, and I'll schedule it. In this upcoming beerconf, Stefan Koch is going to have a talk about meta

Re: Beerconf Noveber 2022 -- Turkey edition

2022-11-24 Thread Steven Schveighoffer via Digitalmars-d-announce
On 11/12/22 4:51 PM, Steven Schveighoffer wrote: # BEERCONF! Let's hope my US compatriots can drag themselves out of their turkey-induced comas to have some D discussions! The dates are November 26-27. Forthcoming! Happy Thanksgiving everyone! 旅 See you in a couple days.  -Steve

Re: How do you return a subclass instance from a base class method?

2022-11-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/16/22 11:25 PM, Daniel Donnelly wrote: I have SubclassOf derived from PosetRelation.  For any poset relation, the transitivity law applies, however, I'd like to return the correct type: ```    PosetRelation transitivity(PosetRelation R, PosetRelation S)    {   if (R.op == S.op)   

Re: Release D 2.101.0

2022-11-15 Thread Steven Schveighoffer via Digitalmars-d-announce
On 11/15/22 7:41 PM, zjh wrote: On Tuesday, 15 November 2022 at 20:54:03 UTC, Iain Buclaw wrote: Glad to announce D 2.101.0, ♥ to the 63 contributors. ... Thank you very much, but can we have commands like `'dmd update'` to update dmd directly? https://github.com/jacob-carlborg/dvm `dvm

Beerconf Noveber 2022 -- Turkey edition

2022-11-12 Thread Steven Schveighoffer via Digitalmars-d-announce
# BEERCONF! Let's hope my US compatriots can drag themselves out of their turkey-induced comas to have some D discussions! The dates are November 26-27. This is the last beerconf before actual [Dconf online](https://dconf.org/2022/online/index.html), which will coincide once again with

Re: Makefiles and dub

2022-11-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/4/22 7:19 PM, Anonymouse wrote: [#20699](https://issues.dlang.org/show_bug.cgi?id=20699) must be non-trivial to fix, so I'm exploring makefiles. If possible I'd like to keep dub for dependency management though, just not for actual compilation. Is it at all possible (or even desireable)

Re: Hipreme's #4 Tip of the day - Don't use package.d

2022-11-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/4/22 3:49 PM, Adam D Ruppe wrote: On Friday, 4 November 2022 at 19:34:58 UTC, jmh530 wrote: Oh really, then what's the point of package.d? It was originally added because Phobos had `std.algorithm` and `std.datetime` and some people wanted to break them up into pieces, but not break

Re: What's the correct way of creating an instance of class in D?

2022-11-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/3/22 1:46 PM, Tejas wrote: Check my post, `A& a;` refuses to compile in C++20 atleast, asking to be explicitly initialized, thus averting the problem altogether That's different, `A&` cannot be rebound in C++, whereas a class reference can. Try `A* a;` and see if it compiles -Steve

Re: raylib-d v4.2.1 - introducing install script

2022-11-03 Thread Steven Schveighoffer via Digitalmars-d-announce
On 11/3/22 6:25 AM, bauss wrote: Thanks for this project Steve, Just trying it out and already enjoying it :) You're welcome! I should also mention that I fixed the issue with the macos binaries not properly installing, so my note about that not working is moot. I still have not figured

Re: D Language Foundation October 2022 Quarterly Meeting Summary

2022-11-02 Thread Steven Schveighoffer via Digitalmars-d-announce
On 11/2/22 6:06 PM, Walter Bright wrote: On 11/2/2022 4:19 AM, Steven Schveighoffer wrote: On one of the only articles using ImportC (which otherwise shines a positive light on the feature), this specific issue is the only one that comes up as a blocker: The easiest option would be to simply

Re: D Language Foundation October 2022 Quarterly Meeting Summary

2022-11-02 Thread Steven Schveighoffer via Digitalmars-d-announce
On 11/2/22 8:58 AM, ryuukk_ wrote: On Wednesday, 2 November 2022 at 04:42:06 UTC, Mike Parker wrote: Following that, he had begun adding colors in the stack trace because he thought they were unreadable, and adding colors was not that much work. He had a proof-of-concept but still had a few

Re: D Language Foundation October 2022 Quarterly Meeting Summary

2022-11-02 Thread Steven Schveighoffer via Digitalmars-d-announce
On 11/2/22 12:42 AM, Mike Parker wrote: Walter said that ImportC doesn't support head const. His experience with C is that people generally mean const in C to be transitive. So in ImportC, he turned the head const cases into transitive const and it appears to work well. On one of the only

Re: druntime thread (from foreach parallel?) cleanup bug

2022-11-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 1 November 2022 at 18:18:45 UTC, Steven Schveighoffer wrote: Oh yeah, isDaemon detaches the thread from the GC. Don't do that unless you know what you are doing. As discussed on discord, this isn't actually true. All it does is prevent the thread from being joined before exiting

Re: druntime thread (from foreach parallel?) cleanup bug

2022-11-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 1 November 2022 at 18:18:45 UTC, Steven Schveighoffer wrote: Oh yeah, isDaemon detaches the thread from the GC. Don't do that unless you know what you are doing. As discussed on discord, this isn't true actually. All it does is prevent the thread from being joined before exiting

Re: druntime thread (from foreach parallel?) cleanup bug

2022-11-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/1/22 1:47 PM, mw wrote: Can you show a code snippet that includes the parallel foreach? (It's just a very straight forward foreach on an array; as I said it may not be relevant.) And I just noticed, one of the thread trace points to here:

Re: Beerconf October 2022

2022-11-01 Thread Steven Schveighoffer via Digitalmars-d-announce
On 11/1/22 12:02 PM, data pulverizer wrote: On Tuesday, 1 November 2022 at 15:05:48 UTC, Mike Parker wrote: I don't think anyone involved in organizing BeerConf knew that was there. That's the first I've seen it. I'd suggest that it is either removed or replaced with something more

Re: A strange DMD error

2022-11-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/1/22 11:40 AM, Keivan Shah wrote: Hello, Today I came across a strange bug while using D with `dmd`. I have still not been able to figure out under what conditions does it happen but it seems to be a DMD related bug to me. Here is a reproducible snippet of the code ```D import std;

Re: Beerconf October 2022

2022-11-01 Thread Steven Schveighoffer via Digitalmars-d-announce
On 11/1/22 7:54 AM, data pulverizer wrote: It might just be my browser (Chrome) but I've noticed that there's nothing in the events calendar (https://dlang.org/calendar.html). Wouldn't it be helpful to include these sorts of things in the calendar so that people visiting the site would be

Re: Beerconf October 2022

2022-10-29 Thread Steven Schveighoffer via Digitalmars-d-announce
On 10/29/22 2:00 PM, FeepingCreature wrote: On Saturday, 29 October 2022 at 10:14:31 UTC, rikki cattermole wrote: And now for some good news! Its almost Halloween, so grab your candy and any spooky brews you may have, and join us for a ghostly chat!

Re: ImportC in a Dub project

2022-10-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/28/22 2:43 PM, Carsten Schlote wrote: On Friday, 28 October 2022 at 18:31:25 UTC, Steven Schveighoffer wrote: Are you passing the c file to the compiler? Also, you must be using dmd for ImportC currently. What is your build line? ``` $ cat dub.json { "au

Re: ImportC in a Dub project

2022-10-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/28/22 1:45 PM, Carsten Schlote wrote: Hi, I created a Dub project containing two files: app.d and zstd_binding.c ``` $ cat source/zstd_binding.c #include #include #include void relatedCode(void) { printf("Hallo! This is some output from C code!\n"); } ``` and ``` $ cat

Re: Beerconf October 2022

2022-10-27 Thread Steven Schveighoffer via Digitalmars-d-announce
On 10/16/22 8:04 AM, Steven Schveighoffer wrote: # BEERCONF! Beerconf this month is on October 29-30, one day before Halloween. Beerconf in 2 days, see you then! -Steve

Re: auto scope question?

2022-10-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/25/22 6:07 PM, WhatMeWorry wrote: I'm naturally getting a undefined identifier `s` error in the return. Is there some way to refactor my code?  I tried to declare s outside of the else brackets like: auto screen = executeShell(cmdLine); auto s; ... {     s =

Re: Is "auto t=T();" not the same as "T t;"?

2022-10-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/25/22 2:03 PM, Ali Çehreli wrote: On 10/25/22 11:01, Ali Çehreli wrote: > static arrays don't have .ptr to point > to any member. Why do I say incorrect things like that? :) Of course static arrays have .ptr as well but that always point to their own body of N elements. They own

Re: Real simple question... for good programmers

2022-10-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/22/22 5:53 PM, WhatMeWorry wrote: string[] tokens = userSID.output.split!isWhite; writeln("tokens = ", tokens); tokens = ["SID", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",

Re: Find in assoc array then iterate

2022-10-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/22/22 12:53 AM, Kevin Bailey wrote: Steven, Just because you don't see the value doesn't mean I don't. You should try to be more helpful, or don't bother. I just mean that I don't understand what iterating from a random position in the AA is. Why not iterate from the beginning? It

Re: Find in assoc array then iterate

2022-10-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/21/22 6:03 PM, Kevin Bailey wrote: I'm trying to do this equivalent C++:     unordered_map map;     for (auto i = map.find(something); i != map.end(); ++i)     ...do something with i... in D, but obviously with an associative array. It seems that it's quite easy to iterate

Re: Compiler Error while using Validation in the hunt-framework

2022-10-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/19/22 3:00 PM, Roman Funk wrote: Hello, I started playing with D and the hunt-framework. But I bumped into an error using Validation. ```d module app.forms.LoginForm; import hunt.validation; import hunt.framework.http.Form; class LoginForm : Form {     mixin MakeForm;     @Email    

Beerconf October 2022

2022-10-16 Thread Steven Schveighoffer via Digitalmars-d-announce
# BEERCONF! Beerconf this month is on October 29-30, one day before Halloween. Feel free to wear your D costume, might I suggest a beerconf T shirt? https://www.zazzle.com/store/dlang_swag/products?cg=196874696466206954 ## What is beerconf? Check out the [wiki

Re: ctod: a tool that translates C code to D

2022-10-13 Thread Steven Schveighoffer via Digitalmars-d-announce
On 10/13/22 3:18 PM, Dennis wrote: The output is supposed to be a good starting point for manual translation: tedious syntax changes are done for you, but you're left with the task of translating (non-trivial) macros, fixing errors because of D's stricter type system, and other misc things

Re: Float rounding (in JSON)

2022-10-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/13/22 3:00 PM, Sergey wrote: I'm not a professional of IEEE 754, but just found this behavior at rounding in comparison with other languages. I supose it happened because in D float numbers parsed as double and have a full length of double while rounding. But this is just doesn't match

Re: How to workaround assignment not allowed in a condition?

2022-10-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/12/22 7:46 AM, Dennis wrote: On Wednesday, 12 October 2022 at 10:09:31 UTC, Steven Schveighoffer wrote: I'm actually very surprised that just wrapping the statement in an == expression doesn't do the trick, what is the possible logic behind outlawing that? I looked

Re: How to workaround assignment not allowed in a condition?

2022-10-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/12/22 9:17 AM, Rene Zwanenburg wrote: On Wednesday, 12 October 2022 at 02:15:55 UTC, Steven Schveighoffer wrote: Am I missing something? Perhaps I am, but why not turn it into a numeric comparison, like: ``` while((i = 5) == 0) ``` Yes, that is the answer, that was eluding me. What

Re: How to workaround assignment not allowed in a condition?

2022-10-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/12/22 5:24 AM, Dennis wrote: On Wednesday, 12 October 2022 at 02:15:55 UTC, Steven Schveighoffer wrote: Porting some C code to D This results in an error: I had the same issue, where the pattern was this: ```C void f() {     int err;     if (err = some_api_call

How to workaround assignment not allowed in a condition?

2022-10-11 Thread Steven Schveighoffer via Digitalmars-d-learn
Porting some C code to D This results in an error: ```d int x; while(!(x = 5)) { break; } ``` Error is: assignment cannot be used as a condition, perhaps `==` was meant? OK, fine, I'll use `==`: ```d int x; while(!(x = 5) == true) { break; } ``` Nope, same error. I tried reversing the

Re: Replacing tango.text.Ascii.isearch

2022-10-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/5/22 12:59 PM, torhu wrote: I need a case-insensitive check to see if a string contains another string for a "quick filter" feature. It should preferrably be perceived as instant by the user, and needs to check a few thousand strings in typical cases. Is a regex the best option, or what

Re: Convert int to dchar

2022-10-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/5/22 12:57 PM, Paul wrote:    I'm sure I'm making this more difficult than it needs to be. I'm trying to convert an integer to a dchar.  The solution below works but seems like overkill.     dstring dstrValue = to!dstring(5);     dchar dcharValue = to!dchar(dstrValue); ... this,   

Re: Remove elements without losing capacity

2022-10-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/4/22 11:22 AM, Riccardo M wrote: Is it possible to remove elements from a range without losing its capacity? ``` void main() {     import std.algorithm.mutation : remove, SwapStrategy;     import std.stdio : writeln;     int[] arr = [1, 2, 3, 2, 4, 2, 5, 2];     assert(arr.length ==

Re: Stop writeln from calling object destructor

2022-10-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/2/22 12:21 PM, data pulverizer wrote: I've noticed that `writeln` calls the destructor of a struct multiple times and would like to know how to stop this from happening. It has become a very serious problem when working with objects that have memory management external to D. I know you

Re: How to do alligned allocation?

2022-10-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/1/22 12:57 AM, tsbockman wrote: On Saturday, 1 October 2022 at 01:37:00 UTC, Steven Schveighoffer wrote: The list of bit sizes is currently here: I'm pretty sure those are in **bytes** not **bits**. Yes, I meant bytes, sorry. That's not a list of alignments, it is block sizes

Re: How to do alligned allocation?

2022-09-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/30/22 11:57 AM, Quirin Schroll wrote: When I do `new void[](n)`, is that buffer allocated with an alignment of 1 or what are the guarantees? How can I set an alignment? Also, is the alignment of any type guaranteed to be a power of 2? In practice, it's not necessarily a power of 2, but

Re: Is there a way to mark a dub package as linux only?

2022-09-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/26/22 4:57 PM, Christian Köstlin wrote: Or posix only? Or not windows? Kind regards, Christian We have specific directives based on os, I had an idea that you could say something like: ```json "dependencies-windows": { "not-available" : "*" } ``` But it still tries to find this

Re: Is this a new bug ?

2022-09-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 24 September 2022 at 06:13:55 UTC, test123 wrote: If so please report it for me to bugs platform. I can not register one. ```d package { version(TEST) { static: } else { __gshared: } uint test = 0; } ``` ldmd2 -betterC -vtls -c ./test.d

Re: Beerconf September 2022

2022-09-22 Thread Steven Schveighoffer via Digitalmars-d-announce
On Sunday, 11 September 2022 at 23:44:45 UTC, Steven Schveighoffer wrote: # BEERCONF! This month, beerconf is going to be happening without me, unfortunately. But it is still happening! The dates are Sept 24-25, 2 weeks from yesterday. A quick reminder that this is coming up in 2 days

Re: how to use dub to run all / chosen dependency lib's unittests

2022-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/19/22 7:48 PM, mw wrote: Hi, I'm using dub.json to specify the dependencies libs for my project. I'm just wondering how I can use dub to run all the tests of those dependencies libs (of the transitive closure of *all* the libs) to make sure my project is built on a very solid

Re: Setting import paths - project (dub) and also rdmd or dmd

2022-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/19/22 10:24 AM, David wrote: TLDR: How do I automatically specify the -I to the compilers so I don't need to specify it manually each time ? For dmd, dmd.conf: https://dlang.org/dmd-osx.html#dmd-conf I believe for all compilers, there's an equivalent config file. -Steve

raylib-d v4.2.1 - introducing install script

2022-09-18 Thread Steven Schveighoffer via Digitalmars-d-announce
Hi everyone, I've released version 4.2.1 of raylib-d. This version is an attempt to fix the issues with linking on Windows. It introduces a new subproject, `raylib-d:install`, which will copy a pre-built binary library of the appropriate version to your project directory. While this is far

Re: Does the GC prioritize same-class when looking for things to free?

2022-09-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/15/22 1:12 PM, cc wrote: Why is Foo never deallocated here? (`DMD32 D Compiler v2.099.0-dirty` win64) In answer to your title question, no. It does not prioritize anything. If it thinks something is ready to be freed, it is freed. If it thinks something is not ready to be freed, it is

Re: Building Example Project with `raylib-d`

2022-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/14/22 4:17 PM, jwatson-CO-edu wrote: Hello, I used the following steps to build the example `raylib-d` program. (https://github.com/schveiguy/raylib-d#example) ### Install Raylib (Ubuntu/Debian) 1. `sudo apt install libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev

Re: can not take const struct member address at CTFE , is this a bug?

2022-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/14/22 12:53 AM, test123 wrote: On Wednesday, 14 September 2022 at 00:40:38 UTC, Ruby The Roobster wrote: The addresses of items stored in memory are by definition not constant.  This isn't a bug. If so why this can work ? ```d struct c { uint a, b;} __gshared const c d = { 3, 4};

Re: Function attribute best practices

2022-09-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/12/22 1:08 PM, Ali Çehreli wrote: On 9/12/22 09:48, H. S. Teoh wrote: >> @nogc nothrow pure @safe >> unittest >> { >>  // ... >> } >> >> No, it isn't because unless my unittest code is impure, I can't catch >> my incorrect 'pure' etc. on my member functions. > [...] > > Sure

Re: Function attribute best practices

2022-09-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/12/22 12:14 PM, Ali Çehreli wrote: What are best practices here? attributes such as `pure`, `@nogc`, `nothrow`, `@safe` should all be left to inference. Either the function can do those attributes, or it cannot. attributes such as `const` or `inout` are different -- these are *not*

Beerconf September 2022

2022-09-11 Thread Steven Schveighoffer via Digitalmars-d-announce
# BEERCONF! This month, beerconf is going to be happening without me, unfortunately. But it is still happening! The dates are Sept 24-25, 2 weeks from yesterday. Nothing really special to report, just a regular-old beerconf. Oh, and October 9th would be the deadline for submitting a

Re: Using .require for struct types

2022-09-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/10/22 12:33 PM, Erdem Demir wrote: Can you please suggest alternatives? Use a pointer. ```d DListOfA *returnVal = (...); returnVal.insert(a); ``` -Steve

Re: Validate static asserts

2022-09-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/9/22 10:35 AM, Andrey Zherikov wrote: I have bunch of `static assert(, )` in my code and would like to validate that specific code triggers specific assert by checking what `` is thrown. Right now I do `static assert(!__traits(compiles, { }));` but since `` might not compile due to

Re: Walter's Edited DConf Talk Video -- Feedback Request

2022-09-08 Thread Steven Schveighoffer via Digitalmars-d-announce
On 9/8/22 11:34 AM, Ali Çehreli wrote: I agree that the slides should take more room. The speaker can get more space at the start, at the end, and occasionally as he/she is not talking directly on any slide. Other than that, I think Mike is overdoing a great work! ;) Agreed! None of this

Re: Walter's Edited DConf Talk Video -- Feedback Request

2022-09-08 Thread Steven Schveighoffer via Digitalmars-d-announce
On 9/8/22 6:40 AM, Mike Parker wrote: On Thursday, 8 September 2022 at 10:19:00 UTC, matheus. wrote: My tip is for the next DConf, people in charge of recording should watch all the previous Conferences and take what went right (The conference at facebook was well done), because this was new

Re: How include header file?

2022-09-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/7/22 4:23 PM, Injeckt wrote: On Wednesday, 7 September 2022 at 19:38:52 UTC, H. S. Teoh wrote: On Wed, Sep 07, 2022 at 06:11:14PM +, Injeckt via Digitalmars-d-learn wrote: I need to include this Ws2tcpip.h header file to my project. How can I do this? It's all because I need inet_ntop

Re: Walter's Edited DConf Talk Video -- Feedback Request

2022-09-07 Thread Steven Schveighoffer via Digitalmars-d-announce
On 9/7/22 8:42 AM, Mike Parker wrote: If you haven't seen Walter's talk yet (or would like to watch it again), please give it a look and let me know if you uncover any major problems: Also note that the first 3 1/2 minutes were never streamed before as the live stream started a bit late

Re: Forked GC explained

2022-09-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/6/22 6:31 PM, frame wrote: Well, of course it would be the fault of the programmer. I did ask this because I just want to know if there is any catch of this (probably not intended/yet noticed) violation of some third party lib. I don't want do debug this :D You can be confident that if

Re: Forked GC explained

2022-09-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/5/22 7:12 AM, frame wrote: And what if the programmer has no actual reference but wrongly forced a `free()` through a pointer cast? https://dlang.org/spec/garbage.html#pointers_and_gc * Do not store pointers into non-pointer variables using casts and other tricks. ```d void* p; ... int

Re: synchronized/shared associative array .require error

2022-09-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/4/22 11:24 PM, cc wrote: On Saturday, 3 September 2022 at 14:37:16 UTC, Steven Schveighoffer wrote: On 9/2/22 3:15 PM, cc wrote: Tried casting away shared as a workaround but I assume that will cause some kind of TLS catastrophe. I think it will be fine, but you may have an issue

Re: synchronized/shared associative array .require error

2022-09-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/2/22 3:15 PM, cc wrote: Tried casting away shared as a workaround but I assume that will cause some kind of TLS catastrophe. I think it will be fine, but you may have an issue. You are returning a non-shared `VAL`, but your class is `shared`, which means `table`, and all the `VAL`

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