Re: Weird std.path API?

2024-07-07 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 7 July 2024 at 14:41:31 UTC, Andrey Zherikov wrote: ```d import std.path; // Error: no property `asNormaliedPath` for `dirName("/sandbox/onlineapp.d")` of type `string` auto p = __FILE_FULL_PATH__.dirName.asNormaliedPath; ``` `asNormalizedPath` is misspelled.

Re: How to assign and compare arrays to SumType?

2024-06-11 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 11 June 2024 at 18:26:50 UTC, confuzzled wrote: On Tuesday, 11 June 2024 at 16:41:46 UTC, confuzzled wrote: Comparison between a Variant and an array is straightforward. How does one accomplish the same between a SumType and an array? Okay, this is what I came up with. Just a

Re: Scripting with Variant from std.variant: parameter passing

2024-02-03 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 3 February 2024 at 08:04:40 UTC, Danilo wrote: To be honest, this doesn't make sense. `if (!is(T : Variant))` returns true for inputs like 42, "hello", 3.14f, but the input is not a Variant but a random type. Yes, it's nice that it works in this case. It's just not logical, it

Re: Scripting with Variant from std.variant: parameter passing

2024-02-02 Thread Anonymouse via Digitalmars-d-learn
On Friday, 2 February 2024 at 08:22:42 UTC, Carl Sturtivant wrote: It seems I cannot pass e.g. an int argument to a Variant function parameter. What's the simplest way to work around this restriction? The easiest thing would be to actually pass it a `Variant` with

Re: Setting field of struct object

2024-02-01 Thread Anonymouse via Digitalmars-d-learn
On Monday, 22 January 2024 at 08:27:36 UTC, Joel wrote: ```d import std; struct Person { string name, email; ulong age; auto withName(string name) { this.name=name; return this; } auto withEmail(string email) { this.email=email; return this; } auto withAge(ulong age) {

Re: Delegates and values captured inside loops

2024-01-21 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 20 January 2024 at 16:32:42 UTC, FeepingCreature wrote: ``` foreach (name; names) { dgs ~= ((name) => () => writeln(name))(name); } ``` lol Thanks, I'll try that.

Re: Nested delegates and closure allocations

2024-01-17 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 16 January 2024 at 17:21:12 UTC, FeepingCreature wrote: Correct. [...] Thanks, I think I understand.

Re: Nested delegates and closure allocations

2024-01-16 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 16 January 2024 at 13:45:22 UTC, FeepingCreature wrote: Am I safe as long as I don't do something like, pass `` as an argument to `std.concurrency.receive`? Yes. Thank you. And to make sure I don't misunderstand the spec; in the case I *do* have a delegate I want to pass

Nested delegates and closure allocations

2024-01-16 Thread Anonymouse via Digitalmars-d-learn
I'm increasingly using nested delegates to partition code. ```d void foo(Thing thing) { void sendThing(const string where, int i) { send(thing, where, i); } sendThing("bar", 42); } ``` ...where the nested `sendThing` sometimes returns something, sometimes doesn't.

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-14 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 13 January 2024 at 23:20:32 UTC, Sergey wrote: I would suggest to rewrite in the same way as Rust implemented. Probably you would like to try: [...] I would strongly argue for profiling first instead of optimising based on conjecture. If you profile you have solid evidence on

Re: Help optimize D solution to phone encoding problem: extremely slow performace.

2024-01-13 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 13 January 2024 at 12:55:27 UTC, Renato wrote: [...] Not a great profiling experience :). Anyone has a better suggestion to "parse" the trace file? As a drive-by suggestion and I hope it doesn't derail anything, but if you have the opportunity to run it on linux, have you tried

Re: Synchronisation help

2024-01-03 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 2 January 2024 at 18:01:55 UTC, Jonathan M Davis wrote: [...] That clarifies a lot. If nothing else, I realise now I can't have `opBinaryRight(string op : "in")` the way I had hoped. What I have now probably doesn't cover 100% of every use-case, but it should do for my scope.

Re: Synchronisation help

2024-01-02 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 2 January 2024 at 11:05:33 UTC, user1234 wrote: Do not use `shared` AA. Use `__gshared` + sync primitives. `shared` AA will lead to all sort of bugs: - https://issues.dlang.org/show_bug.cgi?id=20484#c1 - https://issues.dlang.org/show_bug.cgi?id=17088 -

Re: Synchronisation help

2024-01-02 Thread Anonymouse via Digitalmars-d-learn
On Monday, 1 January 2024 at 19:49:28 UTC, Jonathan M Davis wrote: [...] Thank you. Yes, `Foo` is a class for the purposes of inheritance -- I left that out of the example. So a completely valid solution is to write a struct wrapper around an AA of the type I need, overload the required

Synchronisation help

2024-01-01 Thread Anonymouse via Digitalmars-d-learn
I have a `shared string[int]` AA that I access from two different threads. The function I spawn to start the second thread takes the AA as an argument. ```d class Foo { shared string[int] bucket; Tid worker; } void workerFn(shared string[int] bucket) { while (true) {

Re: Checking path name

2023-12-14 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 14 December 2023 at 03:58:37 UTC, Joel wrote: If I get user input, for example, how do I check to see if it's a valid path, like, file name. ```d // something like this: if (getUserInput.isValidPath) { ... } ``` Is that not how it works?

Re: Meaning of the dot-function syntax

2023-10-01 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 1 October 2023 at 08:22:48 UTC, dhs wrote: Hi, What's the meaning of the dot in the call to writeln() below? ```d .writeln("Hello there!"); ``` I haven't found this in the spec or anywhere else. This is used very often in the source code for Phobos. Thanks, dhs Quote

Re: aarch64 plans for D lang ?

2023-08-28 Thread Anonymouse via Digitalmars-d-learn
On Monday, 28 August 2023 at 15:14:52 UTC, BrianLinuxing wrote: Thank you that looks good :) But is it the full installer and all of the bits? The official [`install.sh`](https://dlang.org/install.html) script will download ldc on ARM too, just as well as on x86. I use it on my Pi400.

Re: Recommendation on plotting library

2023-07-20 Thread anonymouse via Digitalmars-d-learn
On Thursday, 20 July 2023 at 04:41:48 UTC, Chris Piker wrote: On Thursday, 20 July 2023 at 03:58:05 UTC, Andrew wrote: I just tried ggplotd and it was easy to make it work on Linux, only one external apt command needed, but on Windows, even that is a deal breaker. Package management on

Re: Public visible entities published by a module

2023-07-07 Thread Anonymouse via Digitalmars-d-learn
On Friday, 7 July 2023 at 17:46:09 UTC, Cecil Ward wrote: A bit of a weird question, and I’m not sure how to word it. Say I have a module, and I’d like to list / enumerate all the public visible things that the module exports / publishes ‘ makes visible. Is there a way of doing that ? Of

Graphing

2023-06-30 Thread anonymouse via Digitalmars-d-learn
How would I go about graphing time series data (specifically, candles, moving averages, etc) in D and dynamically updating such charts? Thanks, --anonymouse

Re: GC doesn't collect where expected

2023-06-19 Thread Anonymouse via Digitalmars-d-learn
On Monday, 19 June 2023 at 16:43:30 UTC, Steven Schveighoffer wrote: In this specific case, most likely it's a stale register or stack reference. One way I usually use to ensure such things is to call a function that destroys the existing stack: ```d void clobber() { int[2048] x; } ```

Re: Private nested class instance accessed via outer class public interface

2023-06-16 Thread Anonymouse via Digitalmars-d-learn
On Friday, 16 June 2023 at 07:47:50 UTC, Murloc wrote: And since classes can be declared locally inside methods, you can also do something similar this way: ```d import std.stdio; import std.conv; Object getB() { class B { private int field = 30; override string

Re: looking for work-around: _d_assocarrayliteralTX segfault assigning a shared associative array an AA literal

2023-06-13 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 13 June 2023 at 17:06:55 UTC, mw wrote: Does anyone know how to fix it? or any work-around? Thanks. I don't know if it's *correct* or not, but I think I did this at the time to work around it. ``` shared string[string] aa; void main() { auto aaTemp = [ "abc" : "123" ];

Re: iota where step is a function

2023-05-24 Thread anonymouse via Digitalmars-d-learn
On Thursday, 25 May 2023 at 00:18:44 UTC, anonymouse wrote: On Wednesday, 24 May 2023 at 16:39:36 UTC, Ben Jones wrote: Is there a range like iota in phobos where step is a function? I want to specify begin/end and have the "step" be next = fun(prev). Should be easy to write, but don't want

Re: request assistance resolving a std.net.curl segmentation fault

2023-05-24 Thread anonymouse via Digitalmars-d-learn
On Saturday, 20 May 2023 at 09:20:54 UTC, kdevel wrote: What if the internet connection is not re-established within an reasonable amount of time? What if the resource is no longer available on the server (HTTP eror 404 [1])? If there is an interactive user: Wouldn't it be better have the

Re: iota where step is a function

2023-05-24 Thread anonymouse via Digitalmars-d-learn
On Wednesday, 24 May 2023 at 16:39:36 UTC, Ben Jones wrote: Is there a range like iota in phobos where step is a function? I want to specify begin/end and have the "step" be next = fun(prev). Should be easy to write, but don't want to reinvent the wheel. D import std.stdio; import

Re: request assistance resolving a std.net.curl segmentation fault

2023-05-19 Thread anonymouse via Digitalmars-d-learn
On Friday, 19 May 2023 at 12:40:29 UTC, Danny Arends wrote: On Friday, 19 May 2023 at 11:07:01 UTC, anonymouse wrote: What am I doing wrong here? [SNIP] You're running the whole thing in a while(TRUE) loop, recreating the curl object re-initiating the transfer and file pointer, etc. The

Re: request assistance resolving a std.net.curl segmentation fault

2023-05-19 Thread anonymouse via Digitalmars-d-learn
On Friday, 19 May 2023 at 12:28:20 UTC, kdevel wrote: On Friday, 19 May 2023 at 11:07:01 UTC, anonymouse wrote: What am I doing wrong here? [...] curl.set(CurlOption.writedata, ); According to [1] this line must read ``` curl.set(CurlOption.writedata, cast (void *)

Re: request assistance resolving a std.net.curl segmentation fault

2023-05-19 Thread anonymouse via Digitalmars-d-learn
On Friday, 19 May 2023 at 12:28:20 UTC, kdevel wrote: On Friday, 19 May 2023 at 11:07:01 UTC, anonymouse wrote: What am I doing wrong here? [...] curl.set(CurlOption.writedata, ); According to [1] this line must read ``` curl.set(CurlOption.writedata, cast (void *)

request assistance resolving a std.net.curl segmentation fault

2023-05-19 Thread anonymouse via Digitalmars-d-learn
What am I doing wrong here? ```D import std.net.curl: Curl, CurlOption, CurlException; import std.file: exists; import std.stdio: File, writefln; import core.thread: Thread; void downloadFile(string url, string filename) { while (true) { try { File fp; if

request assistance resolving a std.net.curl sementation fault

2023-05-19 Thread anonymouse via Digitalmars-d-learn
What am I doing wrong here? ```D import std.net.curl: Curl, CurlOption, CurlException; import std.file: exists; import std.stdio: File, writefln; import core.thread: Thread; void downloadFile(string url, string filename) { while (true) { try { File fp; if

Re: Prevent console line advancing on user input

2023-04-06 Thread anonymouse via Digitalmars-d-learn
On Thursday, 6 April 2023 at 14:51:43 UTC, Steven Schveighoffer wrote: On 4/6/23 4:01 AM, anonymouse wrote: Wondering if this is possible? [snip] You need to use a terminal-control library, such as `arsd.terminal` https://github.com/adamdruppe/arsd/blob/master/terminal.d -Steve That

Prevent console line advancing on user input

2023-04-06 Thread anonymouse via Digitalmars-d-learn
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 the next line and ask a different

Re: Formatted date

2023-03-22 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 22 March 2023 at 14:02:53 UTC, Alexander Zhirov wrote: Convert date from received time ``` Clock.currTime().toSimpleString() ``` I missed the part about receiving the time, so ignore my previous post.

Re: Formatted date

2023-03-22 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 22 March 2023 at 14:02:53 UTC, Alexander Zhirov wrote: So that i can get a more readable look: `2023-Mar-22 16:53:42.2507395` => `2023.03.22 16:53:42` Maybe there's a better way but I just do this. ``` import std; void main() { const now = Clock.currTime(); enum

Re: Comparison of multidimensional associative arrays

2023-02-08 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 19:04:15 UTC, Alexander Zhirov wrote: [...] I would write a data structure and use struct members to reason about things, but that's probably just preference. ``` import std; struct DatabaseEntry { int id = -1; string deleted; string name;

Re: Comparison of multidimensional associative arrays

2023-02-08 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 8 February 2023 at 17:55:03 UTC, Alexander Zhirov wrote: Not an easy task for me, maybe you can advise your compact solution. There are two associative arrays of type `string[string][int]`. It is necessary to find the differences and return them when comparing: Can you explain

Re: hasUDA alternatives?

2023-01-31 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 28 January 2023 at 17:16:07 UTC, Hipreme wrote: [...] Thank you. I incorporated some of these ideas and looked up how to profile the compilation with tracy, and now dmd memory requirements are down to ~2100 Mb. It's still a far cry from your 250 Mb, however. I changed it to

hasUDA alternatives?

2023-01-28 Thread Anonymouse via Digitalmars-d-learn
I use `hasUDA`, `getUDAs` and `getSymbolsByUDA` fairly heavily in my project. dmd requires some 3.2Gb to compile it, a dub recompilation taking somewhere around 8-14 seconds, depending on the phase of the moon. It's not too bad, admittedly. Stuff like this, naturally taken out of all context:

Re: /usr/bin/ld: [...] undefined reference to _D3std6format6internal6write...

2022-12-22 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 20 December 2022 at 20:55:08 UTC, Paul Backus wrote: Apologies for the late reply. On Tuesday, 20 December 2022 at 20:01:04 UTC, Anonymouse wrote: What does `-allinst` even do `-allinst` tells the compiler to generate code for all instantiated templates, even if it thinks that

/usr/bin/ld: [...] undefined reference to _D3std6format6internal6write...

2022-12-20 Thread Anonymouse via Digitalmars-d-learn
I'm trying to build my thing with gdc. It (now) compiles, but fails to link on this Manjaro/Arch laptop with gdc 12.2.0. ``` /usr/bin/ld: /tmp/ccstWTAS.o: in function `_D3std6format8internal5write__T8getWidthTAyaZQoFNaNfQlZl':

Makefiles and dub

2022-11-04 Thread Anonymouse via Digitalmars-d-learn
[#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) to construct a makefile that builds

Re: dub ldc2 static linking

2022-10-27 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 27 October 2022 at 08:08:38 UTC, Yura wrote: What am I doing wrong? Any way to fix it? https://forum.dlang.org/thread/gghcyaapjwfcpnvks...@forum.dlang.org worked for me.

Re: Static executable (ldc, linux)

2022-10-25 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 25 October 2022 at 10:55:33 UTC, Kagamin wrote: ldc2 -link-defaultlib-shared=false or something like that Thanks.

Static executable (ldc, linux)

2022-10-25 Thread Anonymouse via Digitalmars-d-learn
I'm having problems compiling my thing into an executable that doesn't require ldc's phobos/druntime .so's. I want to distribute it in a form where it's okay if `/usr/lib/libphobos2-ldc-shared.so.100` and friends don't exist. `--static` seems to do the trick in that the compiled file is no

Re: Explicit cast to @system?

2022-10-09 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 9 October 2022 at 17:42:57 UTC, user1234 wrote: But surely there has to be a better way? No. Darn. Okay, thanks.

Re: Explicit cast to @system?

2022-10-09 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 9 October 2022 at 16:25:22 UTC, tsbockman wrote: You might be templating more information than necessary. In your example `foo` doesn't need to be a template at all: ```D void foo(void function() @system fun) { pragma(msg, typeof(fun).stringof); } ``` Yes, it was a toy example.

Explicit cast to @system?

2022-10-08 Thread Anonymouse via Digitalmars-d-learn
I have some nested templated code that takes function pointers. In many cases I pass it functions of identical signatures, except some are `@safe` and others are `@system`. In those cases the templates end up getting instantiated twice. I don't care about the `@safe`-ness and I'd really like

Re: Comparing slices with std.variant.Algebraic

2022-09-07 Thread anonymouse via Digitalmars-d-learn
Thanks Paul. Gotta wrap my head around this well enough to update that module. However, this is a great start. Thank you very much. --anonymouse

Re: Comparing slices with std.variant.Algebraic

2022-09-05 Thread anonymouse via Digitalmars-d-learn
On Monday, 5 September 2022 at 10:30:32 UTC, Ali Çehreli wrote: On 9/5/22 01:58, anonymouse wrote: > array [1.7, 3.7, 5.7, 7.7, 9.7] in both cases, which is what is being > asserted by those two lines. None of those values can be represented precisely in a floating point type. Without looking

Comparing slices with std.variant.Algebraic

2022-09-05 Thread anonymouse via Digitalmars-d-learn
Observe the [implementation](https://github.com/Kriyszig/magpie/blob/master/source/magpie/axis.d) of ```d stuct Axis(U...){} ``` More specifically, observe its usage in the unittests for [Binary Ops on Variant

Re: Request assistance resolving linker error: Undefined symbol(s) for architecture x86_64

2022-08-03 Thread anonymouse via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 09:39:36 UTC, ryuukk_ wrote: Does adding ```-m64``` work I'm using macOS so I don't think that applies. But no, it doesn't do anything for me. Thanks, --anonymouse

Re: Request assistance resolving linker error: Undefined symbol(s) for architecture x86_64

2022-08-03 Thread anonymouse via Digitalmars-d-learn
On Wednesday, 3 August 2022 at 05:04:08 UTC, H. S. Teoh wrote: On Wed, Aug 03, 2022 at 04:28:57AM +, anonymouse via Digitalmars-d-learn wrote: How do I go about tracking down what's causing the following error: ``` Undefined symbols for architecture x86_64

Request assistance resolving linker error: Undefined symbol(s) for architecture x86_64

2022-08-02 Thread anonymouse via Digitalmars-d-learn
How do I go about tracking down what's causing the following error: ``` Undefined symbols for architecture x86_64: "__D3std8internal6memory12__ModuleInfoZ", referenced from: __D3loxQe12__ModuleInfoZ in dlux.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command

Re: Working with arrays (flatten, transpose, verfify rectangular)

2022-07-22 Thread anonymouse via Digitalmars-d-learn
On Friday, 22 July 2022 at 05:17:49 UTC, anonymouse wrote: On Wednesday, 20 July 2022 at 09:18:29 UTC, anonymouse wrote: As for task 3, while I understand the concept of transposing a matrix, I'm not sure how to even begin. By not knowing how to begin, I mean that I don't know how to

Re: Working with arrays (flatten, transpose, verfify rectangular)

2022-07-21 Thread anonymouse via Digitalmars-d-learn
On Wednesday, 20 July 2022 at 09:18:29 UTC, anonymouse wrote: As for task 3, while I understand the concept of transposing a matrix, I'm not sure how to even begin. By not knowing how to begin, I mean that I don't know how to generalize the algorithm so that it applies to an array of

Re: Working with arrays (flatten, transpose, verfify rectangular)

2022-07-21 Thread anonymouse via Digitalmars-d-learn
On Wednesday, 20 July 2022 at 16:15:33 UTC, Salih Dincer wrote: On Wednesday, 20 July 2022 at 09:18:29 UTC, anonymouse wrote: Given an array of arbitrary dimensions, I would like to accomplish three things: 1) verify that it is rectangular (e.g. all elements have the same length,

Re: Working with arrays (flatten, transpose, verfify rectangular)

2022-07-21 Thread anonymouse via Digitalmars-d-learn
On Wednesday, 20 July 2022 at 20:47:28 UTC, ag0aep6g wrote: (Aside: You don't need that many backticks to mark code fragments.) Thought I was following the instructions but it looks like I got a bit carried away. lol. You've got a bug there. This should pass, but fails with your version:

Working with arrays (flatten, transpose, verfify rectangular)

2022-07-20 Thread anonymouse via Digitalmars-d-learn
Given an array of arbitrary dimensions, I would like to accomplish three things: 1) verify that it is rectangular (e.g. all elements have the same length, all sub-elements have the same length, etc.) 2) flatten and return the flattened copy 3) transpose and return

Re: How to dynamically calculate an index?

2022-07-12 Thread anonymouse via Digitalmars-d-learn
On Tuesday, 12 July 2022 at 14:55:47 UTC, anonymouse wrote: I've tried using a foreach loop to achieve this but failed miserably. --anonymouse Wait, I think I've got it. This little snippet does the trick: int index; foreach(i, v; a) { int t = v; foreach(d;

Re: How to dynamically calculate an index?

2022-07-12 Thread anonymouse via Digitalmars-d-learn
On Tuesday, 12 July 2022 at 14:17:36 UTC, ananymouse wrote: Been racking my brain on this for hours. Please point me in the right direction. Thanks, --anonymouse My current implementation: ``` d // Allow for indexing to read a value, e.g a[0,0,0] T opIndex(A...)(A a) {

Re: How to obtain Variant underlying type?

2022-07-11 Thread anonymouse via Digitalmars-d-learn
On Monday, 11 July 2022 at 05:41:40 UTC, jfondren wrote: Oh, sorry. I didn't defend the code in any way because I assumed that the exceptional design would be seen as obviously bad (and that someone else would dig harder in order to find a better solution). And you were right. I did search

Re: How to obtain Variant underlying type?

2022-07-11 Thread anonymouse via Digitalmars-d-learn
On Sunday, 10 July 2022 at 19:14:34 UTC, Paul Backus wrote: For reference, this is the more correct way: ```d while (cast(TypeInfo_Array) v.type !is null) { Variant elem = v[0]; // etc. } ``` Hard to blame anyone for not coming up with that on their first try, especially since

Re: How to obtain Variant underlying type?

2022-07-10 Thread anonymouse via Digitalmars-d-learn
On Sunday, 10 July 2022 at 18:31:46 UTC, drug007 wrote: I'd like to say that using of exception to break loop is really bad. Exception is exceptional thing but in the case above the exception is ordinary completion of the loop happens on regular basis. Don't do that. Thanks for the advice.

Re: How to obtain Variant underlying type?

2022-07-10 Thread anonymouse via Digitalmars-d-learn
On Sunday, 10 July 2022 at 06:26:37 UTC, jfondren wrote: ```d import std.variant : Variant; size_t[] shape(Variant v) { import std.variant : VariantException; size_t[] s; try { while (true) { Variant elem = v[0]; s ~= v.length; v = elem;

Re: How to obtain Variant underlying type?

2022-07-09 Thread anonymouse via Digitalmars-d-learn
On Saturday, 9 July 2022 at 14:46:36 UTC, Adam D Ruppe wrote: Impossible; Variant's type is only known at runtime, and this would require compile time knowledge. Hmmm. Okay, thanks. What I really need to know is how many dimensions an array has and the total elements per dimension so that

How to obtain Variant underlying type?

2022-07-09 Thread anonymouse via Digitalmars-d-learn
std.variant; Variant v = [[1], [2], [3]]; writeln(v.type); // int[][] typeof(v.type); // TypeInfo assert(v.type == typeid(int[][]); As demonstrated by the assert statement, .type returns the typeid of the underlying type. How would I obtain the actual type such that: auto vb = v.base;

Closures over temporary variables

2022-06-14 Thread Anonymouse via Digitalmars-d-learn
What is the correct way of making this output `0 1 2`? ```d void delegate()[] dgs; foreach (immutable i; 0..3) { dgs ~= () => writeln(i); } foreach (dg; dgs) { dg(); // outputs: `2 2 2` } ```

Re: FTP LS

2022-05-15 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 15 May 2022 at 19:13:10 UTC, ikod wrote: Added LIST command in v2.0.8 Thanks!

FTP LS

2022-05-14 Thread Anonymouse via Digitalmars-d-learn
Before I go on duplicating effort, does anyone have anything that can access FTP beyond PUT and GET? I need to read file information from a NAS so I know if I should upload a file or not. `dlang-requests` has `Request.post` and `Request.get`, but seemingly no way to LS.

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

2022-05-12 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 12 May 2022 at 15:17:10 UTC, Adam D Ruppe wrote: It is simpler than it looks, I wrote about it in my book and in a post here: https://forum.dlang.org/post/xklcgjaqggihvhctc...@forum.dlang.org "Then commas separate the definitions of each placeholder variable, just as if they

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

2022-05-12 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 12 May 2022 at 16:48:05 UTC, H. S. Teoh wrote: static foreach isn't meant to handle large loops. Writing `static foreach (i; 0 .. 6)` is generally a bad idea; my suspicion is that the compiler ran out of stack space). It's more for unfolding groups of statements or

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

2022-05-12 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote: What are you stuck at? What was the most difficult features to understand? etc. I came from shell scripts. They grew too large and overly complex when I wanted to do non-trivial things in a neat way, so I looked to proper

Re: Exercises

2022-05-12 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 12 May 2022 at 13:04:51 UTC, Alain De Vos wrote: Is there a link to a webpage with some dlang exercises in order to see if i master the language, from simple to diffucult ? [Rosetta Code](https://www.rosettacode.org) has a bunch, with

Re: DMD failed with exit code -1073741819

2022-05-03 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 18:22:49 UTC, jmh530 wrote: I was leaning towards it being something related to running out of memory or something, but I'm using dub and I've tried turning on and off "lowmem". Note that dub cannot pass -lowmem to dmd. https://issues.dlang.org/show_bug.cgi?id=20699

Re: Install D lang on Windows 10 : an installation step by step tutorial made by a beginner who loves D !

2022-04-18 Thread Anonymouse via Digitalmars-d-learn
On Monday, 18 April 2022 at 09:04:24 UTC, Dennis wrote: What went wrong when you used the DMD installer? Installing Visual Studio should not be necessary, since DMD ships with the lld linker and MinGW Windows import libraries. If it doesn't work out of the box, it should be fixed. "Download

Re: Windows Msys terminal not flushing on newlines

2022-03-27 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 27 March 2022 at 18:09:30 UTC, Adam D Ruppe wrote: Normally the IOLBF thing does help there - that means line buffering - but my recommentation is to explicitly call `stdout.flush()` any time it is important in your code. Then you aren't depending on the relatively hidden config

Windows Msys terminal not flushing on newlines

2022-03-27 Thread Anonymouse via Digitalmars-d-learn
I installed Git for Windows which comes with the Msys terminal, and I noticed writeln lines aren't being flushed on linebreaks. I had this a long time ago and thought I fixed it with the following, but I guess I never confirmed that it actually worked. I'm not sure where I copied it from, a

Example of Windows SSL with Secure Channel?

2022-03-19 Thread Anonymouse via Digitalmars-d-learn
Does anyone have an example snippet code connecting to, reading from and writing to a server using SSL under Windows with Secure Channel? Something in a personal project you wouldn't mind sharing a part of to let me dissect? My project (IRC bot) supports connecting to a server using SSL, for

Re: dmd 2.099 regression: unittest -checkaction=context and import std.regex cause lots of undefined references

2022-03-18 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 17 March 2022 at 14:00:45 UTC, kdevel wrote: If ```import std.regex;``` is commented out or if ```-checkaction=context``` is removed from the cmd line the unittest passes. Can anybody reproduce this? https://run.dlang.io/is/GYDUBz File an issue, I'd say. The worst thing that can

Re: Detecting manifest contants

2022-03-12 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 12 March 2022 at 19:01:06 UTC, Paul Backus wrote: Typo: `.tupleof` I use `.tupleof` otherwise, but this is old stuff from when I didn't know of it. I'll have to refactor it some day, I had hoped for it to be just... not yet.

Detecting manifest contants

2022-03-12 Thread Anonymouse via Digitalmars-d-learn
I'm introspecting structs, and I ran into an issue where `__traits(derivedMembers)` includes manifest constant enums in the returned tuple. What is the correct way to statically detect these? The immediate thing that springs to mind is `is(symbol == enum)`, but it's not it. Currently I'm

Re: How to exclude function from being imported in D language?

2022-03-09 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 8 March 2022 at 22:28:27 UTC, bauss wrote: On Tuesday, 8 March 2022 at 20:12:40 UTC, BoQsc wrote: I think D Language needs and lacks conditional compilation condition and attribute of "exclude". The exclude keyword or code block in the exclude, would be made sure to not be

Re: How do I create a package?

2022-03-05 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 5 March 2022 at 15:30:19 UTC, M wrote: On Saturday, 5 March 2022 at 15:12:35 UTC, M wrote: THE DOCS ARE INADEQUATE TO THE TASK. I've created a directory bcm2835. Then within source/bcm2835 I have bcm2835.d. I run dub build, and file called libbcm2835.a gets built. I type

Re: How do I create a package?

2022-03-02 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 2 March 2022 at 16:38:58 UTC, M wrote: There doesn't seem to be any docs on how to actually create packages. Is there a description anywhere? https://dub.pm/getting_started.html is it, I think. It should get you started on creating a package, and then you have

Re: gcopt=fork:1

2022-03-02 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 1 March 2022 at 21:32:07 UTC, Ali Çehreli wrote: Have you tried this new GC option which seems to solve the stop-the-world issue: https://dlang.org/changelog/2.098.0.html#forkgc Any experience? Ali It didn't work well for me; the process hung in `__memcpy_avx_unaligned_erms`

Re: curl error msg

2022-02-20 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 19 February 2022 at 13:12:32 UTC, MichaelBi wrote: when running the example in the std.net.curl on my windows, got following msg: std.net.curl.CurlException@std\net\curl.d(4239): Failed to load curl, tried "libcurl.dll", "curl.dll" does it mean i don't have those dll files?

Re: Filling an array at compile time

2022-02-09 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 9 February 2022 at 08:12:52 UTC, Vindex wrote: Will the loop (foreach) run at compile time? How can I make it work at compile time? ``` import std.csv, std.stdio; alias Record = Tuple!(string, string, string); immutable string[][] table; shared static this() { string

dustmite and Windows file access errors

2022-01-24 Thread Anonymouse via Digitalmars-d-learn
This is maybe more a Windows (11) question than it is a dustmite one. Semi-OT. I'm trying to reduce https://forum.dlang.org/thread/muehtdyjabmjxosmj...@forum.dlang.org, and it's Windows so I don't know what I'm doing. After multiple attempts at piecing together a batch tester script that both

Re: ldc2 failed with exit code -1073741819.

2022-01-18 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 18 January 2022 at 17:37:27 UTC, H. S. Teoh wrote: Bypassing dub and calling the raw ldc command gives no output. What else can I do? What does `echo $?` print immediately after you run the raw ldc command? T It exits with 5. I could look for that, certainly.

Re: ldc2 failed with exit code -1073741819.

2022-01-18 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 18 January 2022 at 16:43:52 UTC, H. S. Teoh wrote: What's the dustmite command you used? In such cases, it's useful to check for this specific error message in your dustmite command, so that it doesn't reduce it past the actual problem case. T Yes, but the only thing I have

ldc2 failed with exit code -1073741819.

2022-01-18 Thread Anonymouse via Digitalmars-d-learn
I did a big sweep through my project and changed all `writefln`s and `format`s and the such to take their format patterns as compile-time parameters, and now ldc can no longer build it on Windows. It works on linux, and dmd has no problems with it. There is no error message beyond "failed

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

2021-12-21 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 21 December 2021 at 06:44:36 UTC, rempas wrote: This will not do for me because I want to do formatted output and I need the index. But thanks a lot for tying to help! I'm not certain I understand, but won't `foreach (i, a; args) { /* ... */ }` in his example do that? As in, if

Re: String "dequote" in phobos?

2021-05-13 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 13 May 2021 at 14:10:08 UTC, cc wrote: Does something to dequote (unquote? or what would you call it?) a string exist in the standard library? I didn't see one in std.string, just wondering before reinventing the wheel. Something like: ```d assert(dequote(`"foo"`) == "foo");

Re: Creating std.format.format warpper

2021-05-01 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 1 May 2021 at 09:10:09 UTC, novice2 wrote: Hello. Can please anybody help me create template format2 like std.format.format, so it can access to format string (change it for example) then instantiate std.format.format template in compile-time-checkable way Since

Re: is it posible to compile individual module separately?

2021-02-17 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 16 February 2021 at 18:54:08 UTC, Paul Backus wrote: I stand corrected. Shouldn't have trusted the documentation so much, I guess. It makes perfect sense to intuit that --single should be related to --build-mode=singleFile. As it is the build modes aren't explained in the

Re: is it posible to compile individual module separately?

2021-02-16 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 16 February 2021 at 17:26:06 UTC, Paul Backus wrote: On Tuesday, 16 February 2021 at 17:15:25 UTC, Anonymouse wrote: You can also use dub build --build-mode=singleFile, and it will compile one file at a time. It'll be slow but slow is better than OOM. singleFile is for

Re: is it posible to compile individual module separately?

2021-02-16 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 16 February 2021 at 17:06:21 UTC, evilrat wrote: On Tuesday, 16 February 2021 at 07:01:53 UTC, bokuno_D wrote: i run "dub build" on it. but OOM kill the compiler. - is there a way to reduce memory consumtion of the compiler? or maybe third party tool? alternative to dub? Assuming

Re: std.net.curl and HTTP.responseHeaders

2021-02-04 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 3 February 2021 at 19:25:18 UTC, Vindex wrote: Output: ``` std.net.curl.HTTPStatusException@/usr/include/dmd/phobos/std/net/curl.d(1097): HTTP request returned status code 405 () ``` Perhaps some special HTTP configuration is needed? Is this closer to what you want? import

  1   2   3   >