Re: How do I generate `setX` methods for all private mutable variables in a class?

2023-06-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/5/23 11:33 AM, Basile B. wrote: On Monday, 5 June 2023 at 15:13:43 UTC, Basile B. wrote: On Monday, 5 June 2023 at 13:57:20 UTC, Ki Rill wrote: How do I generate `setX` methods for all private mutable although I did not spent time on the setter body... I suppose the question was more

Re: how to skip empty field in csvReader?

2023-06-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/6/23 1:09 AM, mw wrote: Is there a way to tell csvReader to skip such empty fields? What I have done is specify that it's a string, and then handle the conversion myself. Possibly it can use Nullable, but I'm not sure. Or, is there another CSV reader library with this functionality

Re: What's dxml DOMEntity(R) type ?

2023-06-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/5/23 6:43 AM, Ferhat Kurtulmuş wrote: On Monday, 5 June 2023 at 10:01:01 UTC, John Xu wrote: The parseDOM returns a DOMEntity(R) type, how do I write a xmlRoot as global variable? I need its detailed type (auto / Variant doesn't work).     import dxml.dom;     ?? xmlRoot;    

Re: How get struct value by member name string ?

2023-06-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/1/23 10:58 PM, John Xu wrote: Ok, thanks for all you gentlemen's help. I tried following function, now it works like C/C++/Python way:     string getTMember(T t, string columnName) {     foreach(member; __traits(allMembers, T)){     if (member == columnName) {  

Re: How get struct value by member name string ?

2023-06-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/31/23 12:08 AM, John Xu wrote: When render vibe.d diet template,     string[] allMembers = __traits(allMembers, t); enum allMembers = __traits(allMembers, t);     res.render!("index.dt", t, allMembers) if I don't want write memberName one by one in diet template:     table  

Re: How get struct value by member name string ?

2023-05-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/30/23 4:46 AM, John Xu wrote: How to put above enum as a function parameter? Following code wouldn't work:     string getTMember(T t, enum string memberName) {     return __traits(getMember, t, memberName);     } compile time parameters come before runtime parameters: ```d

Re: Code duplication where you wish to have a routine called with either immutable or mutable arguments

2023-05-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/29/23 10:57 PM, Cecil Ward wrote: I have often come into difficulties where I wish to have one routine that can be called with either immutable or (possibly) mutable argument values. The argument(s) in question are in, readonly, passed by value or passed by const reference. Anyway, no one

jsoniopipe now supports JSON5

2023-05-29 Thread Steven Schveighoffer via Digitalmars-d-announce
https://code.dlang.org/packages/jsoniopipe This little project is one that I've tinkered with for a long time, I use it in a few places. I just updated it to support [JSON5](https://json5.org), which is a format much more suited to configuration than straight JSON. AFAIK, this is the first

Re: Concepts like c++20 with specialized overload resolution.

2023-05-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/27/23 9:50 AM, vushu wrote: On Saturday, 27 May 2023 at 13:42:29 UTC, Basile B. wrote: On Saturday, 27 May 2023 at 13:23:38 UTC, vushu wrote: [...] Is there something equivalent in dlang, doesn't seem like d support specialized overload? D solution is called [template

Re: Beerconf May 2023

2023-05-27 Thread Steven Schveighoffer via Digitalmars-d-announce
On 5/25/23 10:39 AM, Steven Schveighoffer wrote: Mike Parker is going to be doing a Q session around 15:00 UTC on Saturday on IVY! I'll send out a reminder here and elsewhere when it starts. Happening now! -Steve

Re: string to char[4] FourCC conversion

2023-05-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/26/23 8:19 AM, realhet wrote: Hello, Is there a way to do it nicer/better/faster/simpler? ``` char[4] fourC(string s) { uint res;//Zero initialized, not 0xff initialized. auto cnt = min(s.length, 4),     p = cast(char[4]*)(); (*p)[0..cnt] = s[0..cnt]; return

Re: Beerconf May 2023

2023-05-25 Thread Steven Schveighoffer via Digitalmars-d-announce
On Monday, 15 May 2023 at 15:42:02 UTC, Steven Schveighoffer wrote: # BEERCONF! Beerconf for May is happening 2 weeks from now, on the 27-28. A reminder that this is happening in 2 days! ## Presentations? As always, I'm interested in having people present some topic. If you have something

Re: As of 2023, we still cannot declaring a constant string[char] AA?

2023-05-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/16/23 7:17 PM, mw wrote: Hi, I just run into this problem again: https://stackoverflow.com/questions/26861708/what-is-the-syntax-for-declaring-a-constant-stringchar-aa So, the solution still is to use: ``` static this () {   ... } ``` What happened to this comments: """ It should be

Beerconf May 2023

2023-05-15 Thread Steven Schveighoffer via Digitalmars-d-announce
# BEERCONF! Beerconf for May is happening 2 weeks from now, on the 27-28. The topic is still the same -- D and other stuff. Hope you can all join us! Want a beerconf T shirt? We know you do. https://www.zazzle.com/store/dlang_swag/products?cg=196874696466206954 ## What is beerconf? Check

Re: DIP1044---"Enum Type Inference"---Formal Assessment

2023-05-11 Thread Steven Schveighoffer via Digitalmars-d-announce
On 5/11/23 10:10 AM, Paul Backus wrote: On Thursday, 11 May 2023 at 13:31:58 UTC, Steven Schveighoffer wrote: On 5/10/23 11:22 PM, Paul Backus wrote: In fact, for this particular example, there are actually two enums in the DMD source code that these symbols could be coming from: `enum

Re: DIP1044---"Enum Type Inference"---Formal Assessment

2023-05-11 Thread Steven Schveighoffer via Digitalmars-d-announce
On 5/10/23 11:22 PM, Paul Backus wrote: In fact, for this particular example, there are actually two enums in the DMD source code that these symbols could be coming from: `enum TargetOS` in `cli.d`, and `enum OS` in `target.d`. So you would have to scroll up and look at the imports to

Re: Beta 2.104.0

2023-05-10 Thread Steven Schveighoffer via Digitalmars-d-announce
This reminds me of an LDC bug fixed recently. I bet DMD suffers from a similar problem: https://github.com/ldc-developers/ldc/issues/3864 -Steve

Recording of last Beerconf presentation

2023-05-09 Thread Steven Schveighoffer via Digitalmars-d-announce
Hi everyone. At the last Beerconf, Hipreme showed us his build system for his new game engine. Cobbled together from various recording sources, here is the recording of that presentation. https://www.youtube.com/watch?v=QGwQ4uZp5I4 If you want to show off something during any beerconf,

Re: A New Era for the D Community

2023-05-03 Thread Steven Schveighoffer via Digitalmars-d-announce
On 5/3/23 7:13 AM, Mike Parker wrote: Our enthusiasm is high, and we're ready to get going. I think you'll like where we're headed. This all sounds awesome! -Steve

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

2023-05-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/2/23 8:52 AM, Quirin Schroll wrote: How do I invoke the member function in a reliable way? Given `obj` of the type of the object, I used `mixin("obj.", __traits(identifier, memberFunc), "(params)")`, but that has issues, among probably others, definitely with visibility. (The member

Re: Beerconf April 2023

2023-04-30 Thread Steven Schveighoffer via Digitalmars-d-announce
On 4/27/23 1:42 PM, Steven Schveighoffer wrote: On 4/16/23 11:39 AM, Steven Schveighoffer wrote: # BEERCONF! Beerconf for April is happening 2 weeks from now, on the 29-30. A reminder that this is happening in 2 days! ## Presentations? This beerconf, we have another presentation

Re: Beerconf April 2023

2023-04-29 Thread Steven Schveighoffer via Digitalmars-d-announce
On 4/16/23 11:39 AM, Steven Schveighoffer wrote: # BEERCONF! Beerconf is inviting you to a meeting! https://meet.jit.si/Dlang2023AprilBeerConf See you there -Steve

Re: D Language Foundation April 2023 Quarterly Meeting Summary

2023-04-28 Thread Steven Schveighoffer via Digitalmars-d-announce
On 4/28/23 11:42 AM, jmh530 wrote: 2) It would be cool to have a built-in way to profile unittests by module. So for instance, the output would be how long it took the unit tests to run, broken out by module and then with a total. This is a runtime thing. You can customize it:

Re: Beerconf April 2023

2023-04-28 Thread Steven Schveighoffer via Digitalmars-d-announce
On 4/28/23 2:37 AM, Greggor wrote: Darn, I'm working on Sunday until 2:40pm, so I can't make it. (the talk is 1:30 PM in my timezone) Any chance anyone can record it? I'll see if that can be done. I would not want to record it without Hipreme's approval. -Steve

Re: Making a D library for a C executable

2023-04-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/27/23 5:29 PM, Jan Allersma wrote: On Thursday, 27 April 2023 at 21:05:00 UTC, Mike Parker wrote: That's a compilation error, not a linker problem. You need to tell the compiler about the function with a prototype: Declaring the function does fix the compiler problem. However, I do get

Re: Beerconf April 2023

2023-04-27 Thread Steven Schveighoffer via Digitalmars-d-announce
On 4/27/23 2:17 PM, Sergey wrote: On Thursday, 27 April 2023 at 17:42:30 UTC, Steven Schveighoffer wrote: On 4/16/23 11:39 AM, Steven Schveighoffer wrote: # BEERCONF! Beerconf for April is happening 2 weeks from now, on the 29-30. A reminder that this is happening in 2 days

Re: Beerconf April 2023

2023-04-27 Thread Steven Schveighoffer via Digitalmars-d-announce
On 4/16/23 11:39 AM, Steven Schveighoffer wrote: # BEERCONF! Beerconf for April is happening 2 weeks from now, on the 29-30. A reminder that this is happening in 2 days! ## Presentations? This beerconf, we have another presentation! Hipreme will show off the HipremeEngine build system

Re: Article on incremental compilation

2023-04-23 Thread Steven Schveighoffer via Digitalmars-d-announce
On 4/22/23 7:33 PM, Zachary Yedidia wrote: Hi everyone, I've been tinkering with setting up incremental compilation in my D projects by using `.di` files to ensure that a module is only recompiled if its interface changes (not its implementation). I've written an article about it here:

Re: Getting a total from a user defined variable

2023-04-20 Thread Steven Schveighoffer via Digitalmars-d-learn
```d writeln("Total: ", p.fold!((a,b) => a+b.age)(0UL)); // or writeln("Total: ", reduce!((a,b) => a+b.age)(0UL, p)); ``` Note that `reduce` is the old version of `fold`, which happened when UFCS became a thing. -Steve

Re: Variable length arrays under -betterC?

2023-04-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/17/23 11:34 AM, DLearner wrote: Requirement is to write some D code (which avoids the GC), that will be called from C. So simple approach seemed to be to write D code under -betterC restrictions. However, also need variable length arrays - but D Dynamic Arrays not allowed under

Beerconf April 2023

2023-04-16 Thread Steven Schveighoffer via Digitalmars-d-announce
# BEERCONF! Beerconf for April is happening 2 weeks from now, on the 29-30. The topic is still the same -- D and other stuff. Hope you can all join us! Want a beerconf T shirt? We know you do. https://www.zazzle.com/store/dlang_swag/products?cg=196874696466206954 ## What is beerconf? Check

Re: class variable initialization

2023-04-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/15/23 7:05 AM, NonNull wrote: I want a way to default initialize a class variable to a default object (e.g. by wrapping it in a struct, because initialization to null cannot be changed directly). Such a default object is of course not available at compile time which seems to make this

Re: How come a count of a range becomes 0 before a foreach?

2023-04-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/10/23 6:43 PM, ikelaiah wrote: On Monday, 10 April 2023 at 01:01:59 UTC, Steven Schveighoffer wrote: On 4/9/23 9:16 AM, Ali Çehreli wrote:    auto entries = dirEntries(/* ... */).array; I'd be cautious of that. I don't know what the underlying code uses, it may reuse buffers for e.g

Re: mutable pointers as associative array keys

2023-04-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/10/23 4:25 PM, Steven Schveighoffer wrote: It's also completely useless. Having const keys does nothing to guarantee unchanging keys. Another half-assed attempt to be encode correct semantics but fails completely in its goal. In case you wonder how old this is: https://issues.dlang.org

Re: mutable pointers as associative array keys

2023-04-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/10/23 2:14 PM, John Colvin wrote: It seems that it isn't possible, am I missing something? alias Q = int[int*]; pragma(msg, Q); // int[const(int)*] Yep, it's been that way forever. Only with pointers and arrays. It's fine with mutable classes and structs (even if they contain pointers).

Re: How come a count of a range becomes 0 before a foreach?

2023-04-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/9/23 9:16 AM, Ali Çehreli wrote: On 4/8/23 21:38, ikelaiah wrote: > I will modify the code to construct it twice. Multiple iterations of dirEntries can produce different results, which may or may not be what your program will be happy with. Sticking an .array at the end will iterate a

Re: How come a count of a range becomes 0 before a foreach?

2023-04-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/8/23 9:38 PM, ikelaiah wrote: // Get files in specified inputPath variable with a specific extension     auto rmdFiles = file.dirEntries(inputPath, file.SpanMode.shallow)     .filter!(f => f.isFile)     .filter!(f => f.name.endsWith(fileEndsWith));     // LINE 72 -- WARNING --

Re: Prevent console line advancing on user input

2023-04-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/6/23 4:01 AM, anonymouse wrote: Wondering if this is possible? Ask a user at input and wait for response: write("Is the sky blue? "); readf!" %s\n"(response); If the user's response is correct, I'd like to change the color of provided response to indicate it was correct then advance to

Re: constant pointer failing to compile

2023-04-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/5/23 8:59 PM, Mathias LANG wrote: immutable ubyte[4] data = [1, 2, 3, 4]; Using a static array instead of a slice will do the trick. You can leave the `__gshared` if you want, but it is redundant on a global, initialized `immutable` variable. I found out the same thing. But I don't

Re: foreach (i; taskPool.parallel(0..2_000_000)

2023-04-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/5/23 6:34 PM, Paul wrote: On Tuesday, 4 April 2023 at 22:20:52 UTC, H. S. Teoh wrote: Best practices for arrays in hot loops: - Avoid appending if possible; instead, pre-allocate outside the loop. - Where possible, reuse existing arrays instead of discarding old ones   and allocating new

Re: Virtual method call from constructor

2023-04-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/4/23 3:08 AM, Chris Katko wrote: Second, could you give me some case examples where this problem occurs? Is the issue if I override refresh in a derived class, and the base class will accidentally use child.refresh()? An example of a problem: ```d class Base { this() {

Re: foreach (i; taskPool.parallel(0..2_000_000)

2023-04-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/4/23 11:34 AM, Salih Dincer wrote: On Tuesday, 4 April 2023 at 14:20:20 UTC, Steven Schveighoffer wrote: parallel is a shortcut to `TaskPool.parallel`, which is indeed a foreach-only construct, it does not return a range. I think what you want is `TaskPool.map`: ```d // untested, just

Re: foreach (i; taskPool.parallel(0..2_000_000)

2023-04-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/4/23 5:24 AM, Salih Dincer wrote: Is it necessary to enclose the code in `foreach()`? I invite Ali to tell me! Please explain why parallel isn't running. parallel is a shortcut to `TaskPool.parallel`, which is indeed a foreach-only construct, it does not return a range. I think what

Re: foreach (i; taskPool.parallel(0..2_000_000)

2023-04-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/3/23 7:22 PM, Paul wrote: ```d // Timed main() vvv void main(string[] args) { auto progStartTime = MonoTime.currTime; //- string filename =

Re: foreach (i; taskPool.parallel(0..2_000_000)

2023-04-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/3/23 6:56 PM, Paul wrote: On Monday, 3 April 2023 at 22:24:18 UTC, Steven Schveighoffer wrote: If your `foreach` body takes a global lock (like `writeln(i);`), then it's not going to run any faster (probably slower actually). **Ok I did have some debug writelns I commented out

Re: foreach (i; taskPool.parallel(0..2_000_000)

2023-04-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/3/23 6:02 PM, Paul wrote: On Sunday, 2 April 2023 at 15:32:05 UTC, Steven Schveighoffer wrote: It's important to note that parallel doesn't iterate the range in parallel, it just runs the body in parallel limited by your CPU count. **?!?** So for example, if you have: ```d foreach(i

Re: foreach (i; taskPool.parallel(0..2_000_000)

2023-04-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/1/23 6:32 PM, Paul wrote: On Saturday, 1 April 2023 at 18:30:32 UTC, Steven Schveighoffer wrote: On 4/1/23 2:25 PM, Paul wrote: ```d import std.range; foreach(i; iota(0, 2_000_000).parallel) ``` Is there a way to tell if the parallelism actually divided up the work? Both versions

Re: foreach (i; taskPool.parallel(0..2_000_000)

2023-04-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/1/23 2:25 PM, Paul wrote: Thanks in advance for any assistance. As the subject line suggests can I do something like? : ```d foreach (i; taskPool.parallel(0..2_000_000)) ``` Obviously this exact syntax doesn't work but I think it expresses the gist of my challenge. ```d import

Re: The Phobos Put

2023-03-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/30/23 11:44 AM, Paul Backus wrote: It should be fine to have both a `ref` and non-`ref` overload for `put`, though, right? If the non-`ref` overload is only called with rvalues, then it's fine to leave them in an undetermined state, because nothing can access them afterward anyway.

Re: The Phobos Put

2023-03-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/29/23 11:01 PM, Salih Dincer wrote: ```d import std.algorithm.mutation : copy; void main() {   int[8] buf;   auto dig = [1, 2, 3, 4];   auto rem = dig.copy(buf);   assert(rem.length == 4); } ``` Looks like 'copy' has the same overload issue. A static array is not a range of any

Re: The Phobos Put

2023-03-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/29/23 4:29 PM, ag0aep6g wrote: But regardless of Salih's exact intent, the broader point is: a non-ref overload could be added to Phobos. And that would enable `a[1..$-1].phobos_put([2, 3])`. Which is what he asked about originally. I think the idea of requiring ref output ranges is

Re: How to debug and watch globals in windows debugger?

2023-03-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/28/23 6:42 PM, ryuukk_ wrote: Am i the only want who want to improve things, is it a lost cause? I'm not one to use a debugger often, but it is very helpful for many people. I lament that the Windows debugging situation out of the box is dreadful. The students I teach D to I don't

Re: Convert binary to UUID from LDAP

2023-03-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/28/23 6:36 AM, WebFreak001 wrote: the formatting messed up here. Try this code: ```d auto uuid = UUID(     (cast(const(ubyte)[]) value.attributes["objectGUID"][0])     [0 .. 16] ); ``` Nice, I didn't think this would work actually! -Steve

Re: Convert binary to UUID from LDAP

2023-03-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/28/23 1:05 AM, Alexander Zhirov wrote: On Tuesday, 28 March 2023 at 00:51:43 UTC, Steven Schveighoffer wrote: `auto uuid = UUID(*cast(ubyte[16]*)youruuiddata.ptr);` (added quotes here) ```d ubyte[] arr = cast(ubyte[])value.attributes["objectGUID"][0].dup; writeln(UUID(cas

Re: como eliminar los caracteres nulos de las respuestas en socket?

2023-03-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/27/23 1:13 PM, Espartan Jhon wrote: hola a todos quisiera saber como es que puedo eliminar los caracteres nulos de las respuestas de mi socket In English (via google translate): Hello everyone, I would like to know how I can remove null characters from my socket responses My response

Re: Convert binary to UUID from LDAP

2023-03-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/27/23 1:56 PM, Alexander Zhirov wrote: I get `objectGUID` data from LDAP as binary data. I need to convert `ubyte[]` data into a readable `UUID`. As far as I understand, it is possible to do this via `toHexString()`, but I have reached a dead end. Is there a way to make it more elegant,

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

2023-03-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/26/23 4:41 PM, ryuukk_ wrote: On Sunday, 26 March 2023 at 19:08:32 UTC, Steven Schveighoffer wrote: On 3/26/23 2:07 PM, ryuukk_ wrote: Hi, It's common knowledge that accessing tls global is slow http://david-grs.github.io/tls_performance_overhead_cost_linux/ What i do not understand

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

2023-03-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/26/23 2:07 PM, ryuukk_ wrote: Hi, It's common knowledge that accessing tls global is slow http://david-grs.github.io/tls_performance_overhead_cost_linux/ What i do not understand is the reasoning behind choosing tls global by default in D If you know a variable is not `shared`, then

Re: Calling assumeSorted on const(std.container.Array)

2023-03-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/25/23 9:45 AM, Olivier Prat wrote: Would someone explain the exact nature of this error as I fail to understand as how just telling that an Array ConstRange is assumed to be sorted actually modifies anything?? It's because a Range keeps a copy of the array (Array is a reference counted

Re: Including parts of a diet template in another

2023-03-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/25/23 4:56 PM, seany wrote: Hello If we are creating a multipage Vibe.d application, we need to use diet templates. I can't find any info on how to include parts or whole of a diet template in another. You can include an entire other diet template like: ```pug include commondiv ```

Re: Beerconf March 2023

2023-03-24 Thread Steven Schveighoffer via Digitalmars-d-announce
On 3/13/23 11:58 AM, Steven Schveighoffer wrote: # BEERCONF! Beerconf for March is happening a little sooner than 2 weeks from now (sorry, was busy on Sat/Sun, so I didn't get to this post), on the 25-26. Missed sending out the reminder yesterday, but sending it today. This is happening

Re: Formatted date

2023-03-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/22/23 10:02 AM, Alexander Zhirov wrote: Tell me, how can I use such a date conversion mechanism? I didn't find [something](https://www.php.net/manual/en/datetime.format.php) similar on the forum. Convert date from received time ``` Clock.currTime().toSimpleString() ``` So that i can

Re: What makes vibe.d Incredibly Slow on a VPS?

2023-03-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/18/23 9:36 AM, seany wrote: But on a VPS server, the program outputs the first writeln line (not even the consequent req.form printouts), then apparently stops for several seconds ( 10 to 16) , and then suddenly starts working again. I see this in the log outputs. Why does this happen?

Beerconf March 2023

2023-03-13 Thread Steven Schveighoffer via Digitalmars-d-announce
# BEERCONF! Beerconf for March is happening a little sooner than 2 weeks from now (sorry, was busy on Sat/Sun, so I didn't get to this post), on the 25-26. Want a beerconf T shirt? We know you do. https://www.zazzle.com/store/dlang_swag/products?cg=196874696466206954 ## What is beerconf?

Re: Best way to read/write Chinese (GBK/GB18030) files?

2023-03-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/12/23 8:32 PM, zjh wrote: On Sunday, 12 March 2023 at 20:03:23 UTC, 0xEAB wrote: ... Thank you for your reply, but is there any way to output `gbk` code to the console? What is required is an addition to the `std.encoding` module, to allow such an encoding. Encodings are simply

Re: @nogc and Phobos

2023-03-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/11/23 7:04 AM, bomat wrote: Hi all, I am a C++ programmer in my "day job" and was playing around with D to maybe use it in a personal project. I'm using Dear ImGui for the graphical user interface, for which I use this port: https://github.com/KytoDragon/imgui/ It works fairly well

Re: Objective-C D metal binding

2023-03-11 Thread Steven Schveighoffer via Digitalmars-d-announce
On 3/10/23 4:10 PM, ryuukk_ wrote: On Friday, 10 March 2023 at 20:53:23 UTC, Hipreme wrote: Hello guys. I have been working for some time into binding Metal to D. This has been quite an interesting journey and today I've reached a point where it is usable. It is far from complete, but I

Re: vibe.d

2023-03-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/11/23 5:12 AM, seany wrote: email.headers["Sender"] = "<"; // valid mail Looks like an extra `<`, is that correct? Exception while handling request POST /createNewOwner: object.Exception@/home/monsoon/.dub/packages/vibe-d-0.9.6-alpha.1/vibe-d/tls/vibe/stream/openssl.d(668):

Re: help: Unresolvable dependencies to package openssl

2023-03-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/8/23 7:52 PM, mw wrote: Hi, In my dub.json, I have: ```     "dependencies": {     "apache-thrift": "==0.16.0",     ...     }     "subConfigurations": {     "apache-thrift": "use_openssl_1_1",   

Re: dub.sdl bindbc-glfw is returning a deprecation warming. So what do I do now?

2023-03-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/8/23 7:21 PM, WhatMeWorry wrote: my small dub.sdl project uses: dependency "bindbc-glfw"  version="~>1.0.1" versions "GLFW_33" and returns Building bindbc-glfw 1.0.1: building configuration [dynamic]

Re: Best way to read/write Chinese (GBK/GB18030) files?

2023-03-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/6/23 8:45 PM, John Xu wrote: I'm new to dlang. I didn't find much tutorials on internet about how to read/write Chinese easily. std.encoding doesn't seem to support GBK or GB18030: "Encodings currently supported are UTF-8, UTF-16, UTF-32, ASCII, ISO-8859-1 (also known as LATIN-1),

Re: How to build a static lib properly?

2023-03-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/5/23 9:09 PM, ryuukk_ wrote: On Monday, 6 March 2023 at 02:00:16 UTC, Mike Parker wrote: This is not dub's fault. When building a shared library, there's a link step, so any external dependencies are linked into the shared library just as they are with an executable. There is no link

Re: Use dub to create source lib and executables

2023-03-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/4/23 1:33 PM, Chris Piker wrote: Hi D I normally work in a *nix environment, typically on server-side code. For many projects I have gnu makefiles that build a small lib along with command line utilities. Up to now I've been creating a dub.json file for just the sourceLibrary, and

Re: dub.selections.json & optional dependencies: How's it work?

2023-02-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/24/23 2:01 PM, jmh530 wrote: I'm looking at the dub package format [1] about optional dependencies and it says: "With this set to true, the dependency will only be used if explicitly selected in dub.selections.json. If omitted, this attribute defaults to false." And it occurs to me

Re: Template alias parameter: error: need 'this' for ...

2023-02-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/24/23 7:00 AM, Elfstone wrote: Seems like the same bug is still there after ten years. `static` should not affect module-level functions, but also, this code should work without `static`. Reported, not sure if there's a previous bug, it was hard to come up with a good description:

Re: Beerconf February 2023

2023-02-23 Thread Steven Schveighoffer via Digitalmars-d-announce
On 2/11/23 11:05 AM, Steven Schveighoffer wrote: # BEERCONF! Beerconf for February is happening 2 weeks from now, on the 25-26. Just a friendly reminder that this is happening soon (in 2 days for me) Don't forget to tune in for Garrett's demo of tree-sitter-d on Saturday At UTC 18:00 (see

Re: Lazy and GC Allocations

2023-02-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/20/23 1:50 PM, Etienne wrote: On Monday, 20 February 2023 at 02:50:20 UTC, Steven Schveighoffer wrote: See Adam's bug report: https://issues.dlang.org/show_bug.cgi?id=23627 So, according to this bug report, the implementation is allocating a closure on the GC even though the spec says

Re: Lazy and GC Allocations

2023-02-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/19/23 9:15 PM, Steven Schveighoffer wrote: Indeed, you can't really "save" the hidden delegate somewhere, so the calling function knows that the delgate can't escape. I stand corrected, you can save it (by taking the address of it). And it's explicitly allowed b

Re: Lazy and GC Allocations

2023-02-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/19/23 7:50 PM, Etienne wrote: Hello, I'm wondering at which moment the following would make an allocation of the scope variables on the GC. Should I assume that the second parameter of enforce being lazy, we would get a delegate/literal that saves the current scope on the GC even if

Blog post on figuring out attribute inference failure

2023-02-19 Thread Steven Schveighoffer via Digitalmars-d-announce
Ever faced with an attribute inference fail, and you don't know what caused it? I have honed some techniques to try and figure it out. Just posted this: https://www.schveiguy.com/blog/2023/02/spelunking-attribute-inference-in-d/ Hopefully it helps. -Steve

Re: Big struct/class and T.init

2023-02-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/19/23 1:26 PM, Steven Schveighoffer wrote: Testing with run.dlang.io, switching between `char` and `int` changes the ASM output to show whether it's stored or not. And BTW, you can override this by assigning a zero default: ```d struct S { char[16384] array = 0; // no .init storage

Re: Big struct/class and T.init

2023-02-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/19/23 1:11 PM, Guillaume Piolat wrote: If my understanding is correct, the mere fact of having a:     struct S     {     char[16384] array;     } And then using it anywhere, will necessarily lead to a S.init being created and linked, leading to a binary size inflation of 16kb.

Re: Beerconf February 2023

2023-02-18 Thread Steven Schveighoffer via Digitalmars-d-announce
On 2/11/23 11:05 AM, Steven Schveighoffer wrote: ## Presentations? As always, I'm interested in having people present some topic. If you have something you want to reserve a time for, please send me a message in any of the channels (here, email, discord, slack, etc.) and I'll make sure

Re: mysql-native v3.2.0 - the safe update

2023-02-18 Thread Steven Schveighoffer via Digitalmars-d-announce
On 2/14/23 9:22 AM, Rey Valeza wrote: Hi Steve, I just want you to know that I updated the Vibe.d tutorial I wrote last year to emphasize database operations using mysql-native and is now viewable here: https://reyvaleza.gitbook.io/vibe.d-tutorial/ Nice! I see that you just import `mysql`.

Re: How can I easily determine the last charachter of a file?

2023-02-14 Thread Steven Schveighoffer via Digitalmars-d-learn
```d myFile.seek(-1, SEEK_END); ubyte c[1]; myFile.rawRead(c[]); if(c[0] == '\n') // ends in newline ``` -Steve

Re: Simplest way to convert an array into a set

2023-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/13/23 1:04 PM, Matt wrote: Obviously, there is no "set" object in D, but I was wondering what the quickest way to remove duplicates from an array would be. I was convinced I'd seen a "unique" method somewhere, but I've looked through the documentation for std.array, std.algorithm AND

Re: My vibe-d test app is crashing on Windows

2023-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/13/23 8:12 AM, Steve wrote: The app is just a test echo server. JSON sent in the body of a POST request is echoed back to the client. On Pop!_OS it works fine but on Windows it responds, there's a delay of about 10 seconds and then it crashes with the error: ``` Error Program exited

Re: ddbc with Vibe-d

2023-02-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/12/23 3:29 PM, Steve wrote: In my case args will just be the body of the HTTPServerRequest which is JSON. How can I get that JSON and pass it to async() in a manner that ensures I get a worker thread? I think it needs to be immutable if it's a reference. -Steve

Re: How does the function 'iota' get its name?

2023-02-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/12/23 2:17 PM, ccmywish wrote: Hi, everyone! I'm very new to D. I see a function called [iota](https://dlang.org/library/std/range/iota.html) `Iota` seems a [Greek letter](https://en.wikipedia.org/wiki/Iota). Why does it relate to range? It came from C++. See notes here:

Re: ddbc with Vibe-d

2023-02-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/12/23 1:01 PM, Steve wrote: On Sunday, 12 February 2023 at 15:24:14 UTC, Steven Schveighoffer wrote: Any synchronous calls will just be synchronous. They aren't going to participate in the async i/o that vibe uses. In other words, when you block on a call to sqlite, it will block

Re: ddbc with Vibe-d

2023-02-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/12/23 6:05 AM, Steve wrote: Hi, I'm trying D for the first time and so far I'm really impressed with both D and vibe-d. My test project is an application server and I want to use SQLite3 as its database. I understand Vibe.d uses an async model under the hood and so my question is are

Beerconf February 2023

2023-02-11 Thread Steven Schveighoffer via Digitalmars-d-announce
# BEERCONF! Beerconf for February is happening 2 weeks from now, on the 25-26. I'm hoping to join for this one, totally missed the last one. Want a beerconf T shirt? We know you do. https://www.zazzle.com/store/dlang_swag/products?cg=196874696466206954 ## What is beerconf? Check out the

Re: LDC 1.31.0

2023-02-11 Thread Steven Schveighoffer via Digitalmars-d-announce
On 2/11/23 8:47 AM, kinke wrote: Glad to announce LDC 1.31.0. Major changes: * Based on D 2.101.2.   * ImportC: The C preprocessor isn't invoked yet. * mac/iOS arm64: Linking with `-g` is working again without unaligned pointer warnings/errors. * *Preliminary* support for LLVM 15. Thanks

Re: Gneric linkedList range adaptor

2023-02-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/10/23 5:10 PM, Ben Jones wrote: I'm trying to write a range adaptor for linked list types.  The range type seems to work OK, but my helper function to deduce the node type has a compiler error.  My hunch is that `nextField` loses its association with T when I'm trying to pass it as a

Re: Release D 2.102.0

2023-02-02 Thread Steven Schveighoffer via Digitalmars-d-announce
On 2/2/23 10:01 AM, jmh530 wrote: I was reading through some of the PRs referenced in [issue 23548](https://issues.dlang.org/show_bug.cgi?id=23548), and a little confused by the takeaway. It currently searches for Di, then D files. If it finds none of them, then it searches for C/h files. Is

Re: Beerconf January 2023

2023-01-26 Thread Steven Schveighoffer via Digitalmars-d-announce
On 1/14/23 2:03 PM, Steven Schveighoffer wrote: # BEERCONF! Happy new year! Beerconf this month falls on January 28-29. Just a friendly reminder, this is happening soon. 2 days. I likely will be on late, but I'm sure someone will start it and post a message here with the link. -Steve

Re: How to write a library

2023-01-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/21/23 5:53 PM, Matt wrote: I am trying to write a graphics engine for my university capstone project, and really wanted to give it a try in D, as both a talking point, and because I love the language. I'm using dub to build the library, and the demo application that'll use it. However,

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

2023-01-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/20/23 12:15 PM, Quirin Schroll wrote: Is there a trait (or a combination of traits) that gives me the constraints of a template? Example: ```D void f(T1 : long, T2 : const(char)[])(T x) { } template constraintsOf(alias templ) { /*Magic here*/ } alias constraints = constraintsOf!f; //

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

2023-01-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/20/23 6:28 AM, thebluepandabear wrote: This type of semantics is not possible in D, which sucks. Well, static methods do exactly this. If you want to disable class creation, then use `@disable this();`, if you want to make all methods static, put `static:` at the top of the class.

Re: How to Add CSS and JS to vibe.d templates

2023-01-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/19/23 11:44 PM, seany wrote: Hi Howcan one add CSS and JS to vibe.d templates? Here is my setup (vibe.d project initiated with dub using dub init myproject vibe.d): ./public: main.css  main.js ./source: app.d ./views: auth2fa.dt  fail.dt  login.dt  pair.dt  passfail.dt  userfail.dt

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