Re: Why is Phobos `Flag` so overthought ?

2024-05-08 Thread Dukc via Digitalmars-d-learn
Nick Treleaven kirjoitti 8.5.2024 klo 13.24: On Wednesday, 8 May 2024 at 04:27:13 UTC, cc wrote: It doesn't allow a simple boolean to be used as an argument, or any other Flag as they are different instantiations of a template rather than equivalent aliases. It is however awful, cumbersome, ann

Re: moving from classical lex/yacc to pegged parser

2024-05-10 Thread Dukc via Digitalmars-d-learn
Dmitry Ponyatov kirjoitti 9.5.2024 klo 11.30: > And I also can't figure out how to inherit `ParseTree` with all my script language objects to get AST right from pegged parser. Should I use some superloop with lot of matches to process parsed `pt` tree into something I need myself, to drop all u

Re: D doesn't have weak references. So how can I make a associative array of objects without preventing their destruction?

2024-05-10 Thread Dukc via Digitalmars-d-learn
evilrat kirjoitti 9.5.2024 klo 18.19: ```d struct WeakRef(T) {     private size_t _handle; // same size as a pointer     this(T* ptr) {     _handle = cast(size_t) ptr;     }     T* getRef() {     return cast(T*) _handle;     }     // do the rest ... } ``` [1] https://code.dlan

Re: D doesn't have weak references. So how can I make a associative array of objects without preventing their destruction?

2024-05-10 Thread Dukc via Digitalmars-d-learn
Steven Schveighoffer kirjoitti 10.5.2024 klo 16.01: On Friday, 10 May 2024 at 11:05:28 UTC, Dukc wrote: This also gets inferred as `pure` - meaning that if you use it twice for the same `WeakRef`, the compiler may reuse the result of the first dereference for the second call, without checking w

Re: bool passed by ref, safe or not ?

2024-06-05 Thread Dukc via Digitalmars-d-learn
Basile B. kirjoitti 4.6.2024 klo 19.58: I understand that the notion of `bool` doesn't exist on X86, hence what will be used is rather an instruction that write on the lower 8 bits, but with a 7 bits corruption. Do I corrupt memory here or not ? Is that a safety violation ? Viewing a valid boo

Re: How to use D without the GC ?

2024-06-12 Thread Dukc via Digitalmars-d-learn
bachmeier kirjoitti 12.6.2024 klo 18.21: You're splitting things into GC-allocated memory and manually managed memory. There's also SafeRefCounted, which handles the malloc and free for you. I suspect `SafeRefCounted` (or `RefCounted`) is not the best fit for this scenario. The problem with i

Re: How to use D without the GC ?

2024-06-13 Thread Dukc via Digitalmars-d-learn
Lance Bachmeier kirjoitti 13.6.2024 klo 1.32: Why would it be different from calling malloc and free manually? I guess I'm not understanding, because you put the same calls to malloc and free that you'd otherwise be doing inside this and ~this. Because with `SafeRefCounted`, you have to deci

Re: How to use D without the GC ?

2024-06-13 Thread Dukc via Digitalmars-d-learn
Dukc kirjoitti 13.6.2024 klo 10.18: So for example, if you have a program that sometimes needs 600Mib and sometimes needs 1100MiB, you can in any case allocate all that in one go with one `malloc` or one `new`, but you'll need at least 38/59 `SafeRefCounted` static arrays, and therefore `malloc

Re: How to use D without the GC ?

2024-06-14 Thread Dukc via Digitalmars-d-learn
Lance Bachmeier kirjoitti 14.6.2024 klo 4.23: We must be talking about different things. You could, for instance, call a function in a C library to allocate memory at runtime. That function returns a pointer and you pass it to SafeRefCounted to ensure it gets freed. Nothing is known about the a

Re: How to use D without the GC ?

2024-06-14 Thread Dukc via Digitalmars-d-learn
bachmeier kirjoitti 14.6.2024 klo 16.48: See the example I posted elsewhere in this thread: https://forum.dlang.org/post/mwerxaolbkuxlgfep...@forum.dlang.org I defined ``` @nogc ~this() {   free(ptr);   printf("Data has been freed\n"); } ``` and that gets called when the reference count hit

Re: Any way to automatically convert structs on return?

2024-08-01 Thread Dukc via Digitalmars-d-learn
Emma kirjoitti 1.8.2024 klo 10.25: This kind of prevents ergonomic code like the above. Instead you have to use a function like `Option!T None(T)() => Option!T()` and then you have to repeat yourself with `return None!int` and etc... it's quite annoying :( While this isn't exactly less verbos

Re: How to use destroy and free.

2022-04-30 Thread Dukc via Digitalmars-d-learn
On Sunday, 24 April 2022 at 21:00:50 UTC, Alain De Vod wrote: Is this a correct program to explicit call destroy & free ? ``` void main(){ int[] i=new int[1]; import object: destroy; destroy(i); import core.memory: GC; GC.free(GC.addrOf(cast(void *)(i.ptr))); } ``` A fe

Re: How to use destroy and free.

2022-04-30 Thread Dukc via Digitalmars-d-learn
On Saturday, 30 April 2022 at 11:37:32 UTC, Tejas wrote: Hell, just using `scope int[] i` should be enough to trigger deterministic destruction, no? `typecons`'s `Scoped!` template can be used if 100% guarantee is needed _and_ the memory has to be stack allocated Didn't think of that. To be f

What's a good way to disassemble Phobos?

2022-04-30 Thread Dukc via Digitalmars-d-learn
I have figured out that my development build of Phobos is for some reason including instances of `__cmp` and `dstrcmp` templates from DRuntime in the Phobos binary. Since `-betterC` client code does not link Phobos in, it fails if it tries to use those functions. The problem: how do I track d

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

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

Re: Bug in dmd?

2022-06-14 Thread Dukc via Digitalmars-d-learn
On Tuesday, 14 June 2022 at 13:39:12 UTC, Andrey Zherikov wrote: I have [pretty simple code in my library](https://github.com/andrey-zherikov/argparse/blob/bug/source/argparse/help.d#L27-L47): ```d alias CC = SumType!(AA,BB); struct AA {} struct BB { CC[] c; } private void ppp(T, Output)(au

Re: Bug in dmd?

2022-06-15 Thread Dukc via Digitalmars-d-learn
On Tuesday, 14 June 2022 at 23:56:58 UTC, Andrey Zherikov wrote: On Tuesday, 14 June 2022 at 21:44:48 UTC, Dukc wrote: No idea. The functions seems indeed to be exactly the same, so I assume this is a DMD bug. It cannot be a bug in `std.sumtype`, since that would trigger in both of the templat

Re: DIP1000

2022-06-24 Thread Dukc via Digitalmars-d-learn
On Friday, 24 June 2022 at 05:11:13 UTC, Ola Fosheim Grøstad wrote: No, the lifetime is the same if there is no destructor. Being counter intuitive is poor usability. It depends on whether you expect the rules to be smart or simple. Smart is not necessarily better, as the Unix philosophy tel

Re: How to use a non-static objects in string `mixin`?

2022-08-29 Thread Dukc via Digitalmars-d-learn
On Saturday, 27 August 2022 at 13:20:13 UTC, hype_editor wrote: I need to use function `eval` sometimes, but compiler throws an error: `Error: variable `firstOperand` cannot be read at compile time`. You're probably misunderstanding `mixin`. It does not work like an eval function at Lisp or

Re: How to build DMD/Phobos on Windows

2022-09-01 Thread Dukc via Digitalmars-d-learn
On Wednesday, 24 August 2022 at 18:06:29 UTC, Dmitry Olshansky wrote: It's been a long time but I've found some spare hours I want to devote to finally updating our std.uni to Unicode 14 (soon to migrate to 15 I guess). Thanks, much appreciated! So what is the canonical way to build D on Wind

Re: Making sense out of scope and function calls

2022-11-14 Thread Dukc via Digitalmars-d-learn
On Sunday, 13 November 2022 at 19:06:40 UTC, 0xEAB wrote: Why does only the latter sample compile? The former leads to the following warning: Are you using the `-preview=dip1000` compiler flag? I didn't manage to reproduce this in a simple example of my own. The closest I equivalent I accompl

Re: Is defining get/set methods for every field overkill?

2022-11-17 Thread Dukc via Digitalmars-d-learn
On Thursday, 17 November 2022 at 04:39:35 UTC, thebluepandabear wrote: I am debating whether or not I should add getter methods to these properties. On one hand, it will inflate the codebase by a lot, on the other hand -- in other languages like Java it is a good practice D has far less need

Re: Is defining get/set methods for every field overkill?

2022-11-19 Thread Dukc via Digitalmars-d-learn
On Saturday, 19 November 2022 at 03:52:41 UTC, thebluepandabear wrote: Say you want to write 'SET' now whenever someone sets a width/height value for the rect (as an example), and 'GET' when someone gets the width/height value for the rect, what you could do is do this: ``` class Rect2D {

Re: Is defining get/set methods for every field overkill?

2022-11-19 Thread Dukc via Digitalmars-d-learn
On Saturday, 19 November 2022 at 09:26:49 UTC, Andrey Zherikov wrote: On Saturday, 19 November 2022 at 09:12:26 UTC, thebluepandabear wrote: That's the point many people have given here which is not convincing him, even though it is quite great. I think we all know the answer here 😂 IMHO you

Re: Is defining get/set methods for every field overkill?

2022-11-19 Thread Dukc via Digitalmars-d-learn
On Saturday, 19 November 2022 at 09:49:18 UTC, thebluepandabear wrote: On Saturday, 19 November 2022 at 09:26:49 UTC, Andrey Zherikov wrote: On Saturday, 19 November 2022 at 09:12:26 UTC, thebluepandabear wrote: That's the point many people have given here which is not convincing him, even thou

Re: pointer escaping return scope bug?

2022-11-19 Thread Dukc via Digitalmars-d-learn
On Saturday, 19 November 2022 at 15:02:54 UTC, Nick Treleaven wrote: On Saturday, 19 November 2022 at 14:52:23 UTC, ag0aep6g wrote: That's essentially just a function that returns its pointer parameter. So the program boils down to this: ```D @safe: int* fp(return scope int* p) { return p; } v

Re: short guide on getting started with D

2023-04-18 Thread Dukc via Digitalmars-d-learn
On Monday, 3 April 2023 at 07:29:01 UTC, cgenie wrote: Hello, I created a short guide on getting started with D: https://blog.mmksoft.uk/#A%20short%20guide%20on%20getting%20started%20with%20D%20programming This is because I recently I started to explore the language and, having read the foru

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

2023-05-01 Thread Dukc via Digitalmars-d-learn
As others have said, you have no reason to restrict yourself to BetterC. If you dislike objects and/or other high-level features, you can simply use D in a low-level way like you'd use C. That works just as well from normal D as from BetterC. Both the C standard library and third-party C librar

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

2023-05-01 Thread Dukc via Digitalmars-d-learn
On Monday, 1 May 2023 at 09:17:14 UTC, Eric P626 wrote: This is a false dilemma: D has full C compatibility. From what I understand, D can use C, but C cannot use D? It's like C++: C++ can call C but C cannot call C++. 50% or more of my code will be put in re-usabled libraries. If I want pe

Re: Indenting standards religions K&R, whitesmiths etc

2023-06-01 Thread Dukc via Digitalmars-d-learn
On Wednesday, 31 May 2023 at 16:24:38 UTC, Cecil Ward wrote: I wanted to ask how some of the leaders of our group feel about D indentation standards. `i realise that this causes some religious fervour in C. I could be in trouble here because in all my years at work, we never used K & R ‘one tru

Re: Compiling to RiscV32

2023-07-06 Thread Dukc via Digitalmars-d-learn
On Wednesday, 5 July 2023 at 17:00:53 UTC, HuskyNator wrote: Using a simple single '.d' file with no imports: `Error: cannot find program 'cc'` I haven't tried to compile to RiscV32, nor do know how it works. But this reads like LDC is not finding the C compiler it's trying to use. LDC uses

Re: Advice on debugging possible exception or crash

2023-07-06 Thread Dukc via Digitalmars-d-learn
On Thursday, 6 July 2023 at 06:00:04 UTC, Cecil Ward wrote: In my limited experience, exceptions produce an error message though, and I’m not seeing anything. Any advice on how to debug this, silent termination ? If unsure on cases like this, test. Intentionally throw an exception and don't c

Re: pointer to std.algorithm.iteration : splitter

2023-08-31 Thread Dukc via Digitalmars-d-learn
On Thursday, 31 August 2023 at 05:16:02 UTC, Vino wrote: Hi All, Request your help on the below error Program ``` void main() { import std.stdio:writeln; import std.algorithm.iteration : splitter; auto splitter_ptr = &splitter!((a, b) => a.splitter(b).array);

Re: `static` function ... cannot access variable in frame of ...

2024-01-15 Thread Dukc via Digitalmars-d-learn
On Monday, 15 January 2024 at 18:16:44 UTC, Bastiaan Veelo wrote: Hey people, I can use some help understanding why the last line produces a compile error. ```d import std.stdio; struct S { static void foo(alias len)() { writeln(len); } } void S_foo(alias len)() { writ

Re: /usr/bin/ld.gold: error: failed to find object -lz

2019-08-06 Thread Dukc via Digitalmars-d-learn
On Tuesday, 6 August 2019 at 11:41:25 UTC, kinke wrote: LDC definitely doesn't add that. zlib shouldn't be necessary, as Phobos contains an (IIRC, outdated) version of it. Anyway, you should be able to please the linker by installing a zlib package, such as `zlib1g` on Debian/Ubuntu. Instal

Re: /usr/bin/ld.gold: error: failed to find object -lz

2019-08-07 Thread Dukc via Digitalmars-d-learn
On Wednesday, 7 August 2019 at 02:47:11 UTC, ?boing? wrote: On Tuesday, 6 August 2019 at 12:39:08 UTC, Dukc wrote: On Tuesday, 6 August 2019 at 11:41:25 UTC, kinke wrote: LDC definitely doesn't add that. zlib shouldn't be necessary, as Phobos contains an (IIRC, outdated) version of it. Anyway

Re: /usr/bin/ld.gold: error: failed to find object -lz

2019-08-07 Thread Dukc via Digitalmars-d-learn
On Wednesday, 7 August 2019 at 02:47:11 UTC, ?boing? wrote: On Tuesday, 6 August 2019 at 12:39:08 UTC, Dukc wrote: On Tuesday, 6 August 2019 at 11:41:25 UTC, kinke wrote: LDC definitely doesn't add that. zlib shouldn't be necessary, as Phobos contains an (IIRC, outdated) version of it. Anyway

Re: /usr/bin/ld.gold: error: failed to find object -lz

2019-08-07 Thread Dukc via Digitalmars-d-learn
Taking the LDC2 invocation and removing `-lz` and `-lresolv` seems to work around the problem. A bad long-term solution though.

Re: Module static constructor doesn't work?

2019-08-08 Thread Dukc via Digitalmars-d-learn
On Thursday, 8 August 2019 at 14:55:37 UTC, Andrey Zherikov wrote: I have the following code: // lib1/lib.d module lib; import std.stdio; static this() { writeln("+" ~ __FILE__); } static ~this() { writeln("-" ~ __FILE__); } // main.d int main() { import std.stdio; writeln("h

Getting a HTTP request body over wire for Vibe.d to process

2019-08-10 Thread Dukc via Digitalmars-d-learn
I am trying to use XMLHttpRequest[1] to send a request with a body for Vibe.D to process. However, it seems that I'm getting tripped up on serverside and client side api simultaenously, with no way to know what's really happening. I'm starting to be positive that I need a code example or I'll b

Re: LNK4255 warning - should I be concerned?

2019-08-10 Thread Dukc via Digitalmars-d-learn
On Thursday, 8 August 2019 at 18:14:22 UTC, DanielG wrote: "warning LNK4255: library contain multiple objects of the same name; linking object as if no debug info" Is there some way to get more detail about this warning? Might help to know which objects ... My program is working fine now, bu

Re: How to run the dub bundle with dmd

2019-08-10 Thread Dukc via Digitalmars-d-learn
On Saturday, 10 August 2019 at 13:18:19 UTC, greatsam4sure wrote: I came across the problem recently. I have dub 1.11.0 install on my windows 10 core i7 but does not support the command "dub add package name" since all the packages in dub package register now use this command. I cannot find win

Re: /usr/bin/ld.gold: error: failed to find object -lz

2019-08-15 Thread Dukc via Digitalmars-d-learn
Investigated this matter further. The most likely reason seems to be that the required library -zlib- (Yes, ld.gold was getting the arguments in correct form despite what I said. Sorry.) is installed only in dynamic form (.so), but ld.gold finds only static libraries (.a). Not 100% sure yet, be

Re: /usr/bin/ld.gold: error: failed to find object -lz

2019-08-15 Thread Dukc via Digitalmars-d-learn
On Thursday, 15 August 2019 at 12:02:00 UTC, kinke wrote: That's the library you need. You may have messed things up by installing a non-dev package from Fedora (!). Fortunately it's written in red at YAST, because it's not from the official repos. I can easily find it to get rid of it when I

Re: Pro programmer

2019-08-27 Thread Dukc via Digitalmars-d-learn
On Sunday, 25 August 2019 at 21:30:10 UTC, GreatSam4sure wrote: I am wondering as to what is the starting point of being a pro programmer. If I want to be a pro programmer what language must I start with? Any general purpose language will do. Basically everything can be expressed in any langu

Re: Good way let low-skill people edit CSV files with predefined row names?

2019-10-24 Thread Dukc via Digitalmars-d-learn
On Thursday, 24 October 2019 at 16:03:26 UTC, Dukc wrote: Even if it isn't CSV, it is going to be easier for me to write a translator than a GUI editor. Assuming the file format is simple, of course

Good way let low-skill people edit CSV files with predefined row names?

2019-10-24 Thread Dukc via Digitalmars-d-learn
We're planning to have our product preview program to calculate and suggest a price for the product displayed. There are a lot of variables to take into account, so it's essential the users can edit the price variables themselves. The problem is that many of them are not the best computer user

Re: Good way let low-skill people edit CSV files with predefined row names?

2019-10-24 Thread Dukc via Digitalmars-d-learn
On Thursday, 24 October 2019 at 16:20:50 UTC, jmh530 wrote: If they are only opening it in Excel, then you can lock cells. You should be able to do that with VBA. At least I know it works with xlsx files. Not sure on csv now that I think on it. Hmm, I need to check whether I can do that on L

Re: Good way let low-skill people edit CSV files with predefined row names?

2019-10-24 Thread Dukc via Digitalmars-d-learn
On Thursday, 24 October 2019 at 16:50:17 UTC, Dukc wrote: Hmm, I need to check whether I can do that on LibreOffice Calc. Unfortunately, no. If there's a way to do that, it's not obvious. I should be able to make an easy-to-use excel-to-csv translator using Atilas Excel utilites without too

Re: Good way let low-skill people edit CSV files with predefined row names?

2019-10-30 Thread Dukc via Digitalmars-d-learn
On Friday, 25 October 2019 at 21:58:27 UTC, Laeeth Isharc wrote: Another Symmetry project allows reading Excel files and a third is wrapper and bindings around a C library to write Excel files. We use them in production daily though there may be rough edges for features we don't use. I sho

Re: Good way let low-skill people edit CSV files with predefined row names?

2019-10-30 Thread Dukc via Digitalmars-d-learn
On Saturday, 26 October 2019 at 10:09:54 UTC, Robert M. Münch wrote: Hi, maybe you want to take a look what we do. We are creating price-predicting formulas for all kind of products. Our solution is used in B2B by sales, engineering and purchasing departments to predict prices for very complex

Troubleshooting DUB invocations

2019-11-12 Thread Dukc via Digitalmars-d-learn
When trying to compile a project including newest Spasm (DUB package) using the newest LDC via DUB, the result is: ``` lld: error: unknown argument: --no-as-needed ``` I then ran DUB with -v switch and it turned out the invocation contained `-L--no-as-needed` as first of all the -L arguments.

Re: Should I stop being interested in D language if I don't like to see template instantiation in my code?

2019-11-13 Thread Dukc via Digitalmars-d-learn
On Wednesday, 13 November 2019 at 14:01:13 UTC, BoQsc wrote: I don't like to see exclamation marks in my code in as weird syntax as these ones: to!ushort(args[1]) s.formattedRead!"%s!%s:%s"(a, b, c); No pressure to use templates. D is designed to be multi-paradigm, and in many was combines th

Re: Troubleshooting DUB invocations

2019-11-13 Thread Dukc via Digitalmars-d-learn
On Tuesday, 12 November 2019 at 18:32:32 UTC, kinke wrote: Dub is open-source, so you can grep the source. - Dub uses it for all 3 compilers (e.g., https://github.com/dlang/dub/blob/f87302dd206b0e5871b39704e694b2194e294aa5/source/dub/compilers/ldc.d#L249), and I'm not sure it's really needed.

Re: Why same pointer type for GC and manual memory?

2019-11-13 Thread Dukc via Digitalmars-d-learn
On Wednesday, 13 November 2019 at 11:07:12 UTC, IGotD- wrote: I'm trying to find the rationale why GC pointers (should be names managed pointers) are using the exact same type as any other pointer. Doesn't this limit the ability to change the default GC type? What does grabage collector type

Re: Should I stop being interested in D language if I don't like to see template instantiation in my code?

2019-11-13 Thread Dukc via Digitalmars-d-learn
On Wednesday, 13 November 2019 at 14:59:57 UTC, Dukc wrote: 4: Templates. Same code size bloat as with options 1 and 3, Meant binary size bloat

Re: Troubleshooting DUB invocations

2019-11-13 Thread Dukc via Digitalmars-d-learn
On Wednesday, 13 November 2019 at 15:41:01 UTC, Sebastiaan Koppe wrote: It has been on the back of my mind since 1.18-beta came out. I am going to reserve a little time tomorrow to work on it. Regarding that, perhaps I can save you a bit trouble if you also try to get 1.19 working: if you get

Re: Troubleshooting DUB invocations

2019-11-19 Thread Dukc via Digitalmars-d-learn
On Monday, 18 November 2019 at 19:35:13 UTC, Sebastiaan Koppe wrote: Kinke made some changes in dub to facilitate separate linking for ldc. I am not aware of all the details but the major benefit is that it allows cross compilation with dub and ldc. Yeah, definitely useful if you want to lin

Re: Troubleshooting DUB invocations

2019-11-19 Thread Dukc via Digitalmars-d-learn
On Tuesday, 19 November 2019 at 13:41:32 UTC, Sebastiaan Koppe wrote: A @disabled function stub would serve better, unless I'm missing something. Either way, as long as there is a clear way to debug why it ended up there. Unlike what we have now where you need to dig endlessly. But the @dis

Re: why local variables cannot be ref?

2019-11-25 Thread Dukc via Digitalmars-d-learn
On Monday, 25 November 2019 at 03:07:08 UTC, Fanda Vacek wrote: Is this preferred design pattern? ``` int main() { int a = 1; //ref int b = a; // Error: variable `tst_ref.main.b` only parameters or `foreach` declarations can be `ref` ref int b() { return a; } b = 2;

How to set up multi-dimensional DUB package configuration?

2020-02-12 Thread Dukc via Digitalmars-d-learn
My application has two copyright holders, so I want to be able to specify in the build command whose copyright marks get compiled to the program. D part of the application is built by DUB. DUB configurations would do the trick, but they are already used to define different editions of the appli

Re: How to set up multi-dimensional DUB package configuration?

2020-02-12 Thread Dukc via Digitalmars-d-learn
Illustration, I want to choose both an edition and marked copyright holder: ``` configuration "inhouse" { targetType "executable" versions "InhouseEdition" } configuration "salesmen" { targetType "executable" versions "SalesmenEdition" } configuration "internet" { targetType

How to get Code.dlang.org to update the package?

2020-02-12 Thread Dukc via Digitalmars-d-learn
I have pushed a new release tag in Github around two weeks ago, and ordered a manual update at DUB, yet DUB has still not aknowledged the new tag. Is there some requirement for the release tag for it to be recognized?

Re: How to get Code.dlang.org to update the package?

2020-02-12 Thread Dukc via Digitalmars-d-learn
On Wednesday, 12 February 2020 at 13:05:00 UTC, Petar Kirov [ZombineDev] wrote: On Wednesday, 12 February 2020 at 12:42:32 UTC, Dukc wrote: I have pushed a new release tag in Github around two weeks ago, and ordered a manual update at DUB, yet DUB has still not aknowledged the new tag. Is there

Is there a way to benchmark/profile portably?

2020-05-07 Thread Dukc via Digitalmars-d-learn
Is there some way to measure the performance of a function so that the results will be same in different computers (all x86, but otherwise different processors)? I'm thinking of making a test suite that could find performance regressions automatically. I figured out Bochs[1] could be used for

Re: variant visit not pure?

2020-05-07 Thread Dukc via Digitalmars-d-learn
On Thursday, 7 May 2020 at 09:22:28 UTC, learner wrote: Good morning, Is there a reason why std.variant.visit is not inferring pure? I think `variant` will not infer any trributes. I'm not sure why. It could be some language limitation (that's the reason why `std.range.enumerate` does not i

Re: Is there a way to benchmark/profile portably?

2020-05-07 Thread Dukc via Digitalmars-d-learn
On Thursday, 7 May 2020 at 11:06:17 UTC, Dennis wrote: You can make a reference program that you use to get a measure for how fast the computer is that you run the benchmark on. Then you can use that to scale your actual benchmark results. When testing regressions there's a fairly obvious ch

Re: Is there a way to benchmark/profile portably?

2020-05-07 Thread Dukc via Digitalmars-d-learn
On Thursday, 7 May 2020 at 10:51:27 UTC, Simen Kjærås wrote: If I understand correctly, you want to measure how many cycles pass, rather than clock time? Something like that. Well, I would also like to eliminate differences based on different memory caches between machines. In addition, if

Re: variant visit not pure?

2020-05-07 Thread Dukc via Digitalmars-d-learn
On Thursday, 7 May 2020 at 13:17:21 UTC, learner wrote: I've find this: https://issues.dlang.org/show_bug.cgi?id=16662 Hmm, that explains why it can't infer attributes. An unlimited variant could contain an object, and using it might or might not be . Of course, it could still infer the att

Re: variant visit not pure?

2020-05-08 Thread Dukc via Digitalmars-d-learn
On Thursday, 7 May 2020 at 10:21:26 UTC, Dukc wrote: that's the reason why `std.range.enumerate` does not infer attributes for example This was wrong. `enumerate` can infer. It's `lockstep` that cannot.

Re: variant visit not pure?

2020-05-08 Thread Dukc via Digitalmars-d-learn
On Thursday, 7 May 2020 at 15:36:36 UTC, Ben Jones wrote: I've been using SumType... What are the main differences between it and TaggedAlgebraic? I have not used the the algebraic type of Taggedalgebraic tbh, but it also has a tagged union type that I have good experiences with. Unlike Phobo

Re: variant visit not pure?

2020-05-08 Thread Dukc via Digitalmars-d-learn
On Thursday, 7 May 2020 at 20:12:03 UTC, learner wrote: Modules of D standard library aren't in a good shape, if everyone suggests alternatives for a basic building block as variant. I don't think Variant as a whole is the problem, when one uses it as the infinite variant it does fairly muc

Re: Why emsi containers have @disabled this(this) ?

2020-05-20 Thread Dukc via Digitalmars-d-learn
On Tuesday, 19 May 2020 at 20:51:01 UTC, Luis wrote: I saw that they have postblit operator... But i don't understand exactly why. In special, when they implement InputRange over the containers, but having disabled postblit, make nearly useless (at least as I see on this old post https://forum

Re: How to use this forum ?

2020-05-20 Thread Dukc via Digitalmars-d-learn
On Wednesday, 20 May 2020 at 20:49:52 UTC, Vinod K Chandran wrote: Hi all, I have some questions about this forum. 1. How to edit a post ? No can do :(. Well, moderators can delete posts so you could try to ask them nicely in some cases but the primary way tends to be the same as with email: se

Re: redirect std out to a string?

2020-05-21 Thread Dukc via Digitalmars-d-learn
On Thursday, 21 May 2020 at 04:29:30 UTC, Kaitlyn Emmons wrote: is there a way to redirect std out to a string or a buffer without using a temp file? If you want to do the redirection at startup, it's possible. Have an another program to start your program by std.process functions and redirec

Re: Distinguish between a null array and an empty array

2020-05-26 Thread Dukc via Digitalmars-d-learn
On Sunday, 24 May 2020 at 12:29:23 UTC, bauss wrote: Dang, that sucks there is no proper way and I would say that's a big flaw of D. Because what I need it for is for some data serialization but if the value is an empty array then it should be present and if it's null then it should not be pr

Re: how to append (ref) int[] to int[][]?

2020-06-08 Thread Dukc via Digitalmars-d-learn
On Monday, 8 June 2020 at 06:13:36 UTC, mw wrote: what I really want in (a) is append `ref arr` and output [[3], [3], [3]], i.e. the real `arr` be appended instead of its copy. I tried to change arrs' decl to: (ref (int[]))[] arrs; // the intended semantics I want 1) I'm wondering how

Re: Why is there no range iteration with index by the language?

2020-06-10 Thread Dukc via Digitalmars-d-learn
On Wednesday, 10 June 2020 at 15:34:57 UTC, Steven Schveighoffer wrote: My biggest problem with enumerate is that you can't bind the tuple to parameters for something like map: arr.enumerate.map!((idx, val) => ...) doesn't work. Instead you have to do: arr.enumerate.map!((tup) => ...) And us

Re: Windows + LDC/DMD installation nightmare when changing VS versions

2020-06-12 Thread Dukc via Digitalmars-d-learn
On Friday, 12 June 2020 at 15:21:12 UTC, Guillaume Piolat wrote: Any idea what could be causing this? Please help. This was a living nightmare. I just want a working setup... I don't know if this is any help, as I don't use Visual Studio myself, but: You're trying to build for a 32-bit arc

Re: unit test that show more than one failure

2020-06-16 Thread Dukc via Digitalmars-d-learn
On Tuesday, 16 June 2020 at 06:19:51 UTC, Joel wrote: I've tired different unit test libraries, but they jump out on errors instead of just adding to failed numbers. I'm thinking like this: ``` @("dummy"); unittset { 0.shouldEqual(0); 1.shouldEqual(2); 2.shouldEqual(3); } ``` Test: dumm

Re: "if not" condition check (for data validation)

2020-06-18 Thread Dukc via Digitalmars-d-learn
On Thursday, 18 June 2020 at 13:57:39 UTC, Dukc wrote: if (not!(abra && cadabra)) ... if (not(abra && cadabra)) ...

Re: "if not" condition check (for data validation)

2020-06-18 Thread Dukc via Digitalmars-d-learn
On Thursday, 18 June 2020 at 12:50:35 UTC, Stanislav Blinov wrote: auto not(alias cond)() { return !cond(); } if (not!(() => abra && cadabra)) ... but that is indeed even less readable. No reason to use templates here ``` pragma(inline, true) auto not(bool cond) { return !cond(); } if (not

Re: Arduino and MCU Support

2020-06-26 Thread Dukc via Digitalmars-d-learn
On Thursday, 25 June 2020 at 03:00:04 UTC, Dylan Graham wrote: I'm currently making an automatic transmission controller with Arduino. C++ just has too many traps that I keep falling into. Since stability is critical (if the code screws up at 100km/h I'm dead), I'd rather use a sane language li

Good way to send/receive UDP packets?

2020-07-18 Thread Dukc via Digitalmars-d-learn
I have a project where I need to take and send UDP packets over the Internet. Only raw UDP - my application uses packets directly, with their starting `[0x5a, packet.length.to!ubyte]` included. And only communication with a single address, no need to communicate with multiple clients concurrent

Re: My RPN calculator code review?

2020-07-18 Thread Dukc via Digitalmars-d-learn
On Friday, 17 July 2020 at 21:37:46 UTC, AB wrote: I'd appreciate your opinions regarding style, mistakes/code smell/bad practice. Thank you. In a project this small, implementability (meaning, ease of writing) is really the main guideline, readability is a non-issue. When your codebase hits

Re: Good way to send/receive UDP packets?

2020-07-19 Thread Dukc via Digitalmars-d-learn
Thank you everybody - Especially for the links to the blogs. This is just the kind of stuff I seek (didn't give a close look yet, though). I think I'm going to try std.socket first, since it's in the standard library. If it feels like it could be easier, I'll consider Libasync.

Re: Good way to send/receive UDP packets?

2020-07-22 Thread Dukc via Digitalmars-d-learn
On Wednesday, 22 July 2020 at 13:17:11 UTC, wjoe wrote: - Choosing a port which isn't in use right now isn't good enough because a few minutes later there may be another program using it, too, and for the same reason. But doesn't the UDP header include the sender IP address? So together with

Re: Accessing non-binary Unicode properties with std.uni

2020-09-29 Thread Dukc via Digitalmars-d-learn
On Monday, 28 September 2020 at 18:23:43 UTC, Chloé Kekoa wrote: The documentation of std.uni [1] says that the unicode struct provides sets for several binary properties. I am looking for a way to query non-binary properties of a character. Is that possible with std.uni or do I need to use a t

Re: Memory management

2020-10-02 Thread Dukc via Digitalmars-d-learn
On Tuesday, 29 September 2020 at 10:57:07 UTC, novice3 wrote: Naive newbie question: Can we have (in theory) in D lang memory management like V lang? I don't know V so can't be sure, but doing it the same way as in the examples sounds possible. The first two calls are easy. D string literals

Vibe.D TLS problem

2020-10-27 Thread Dukc via Digitalmars-d-learn
I have a Vibe.D server binary that, locally at least, works. But only without TLS. I want to add TLS to it and test it locally with a self-signed certificate. I made one with LibreSSL, stored in `cert.crt` and `key.key`. The application main function: ``` shared static this() { import vibe.d

Re: How kill executables started with spawnShell or executeShell when program finish?

2020-10-27 Thread Dukc via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 15:16:33 UTC, Marcone wrote: Becouse my program use plink.exe running with spawnShell or executeShell. But when my program finish with some crash, or killed with windows task manager by user, Plink still running. How can I stop all process initialized with spawnSh

Re: Vibe.D TLS problem

2020-11-05 Thread Dukc via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 17:36:53 UTC, Dukc wrote: ``` HTTP connection handler has thrown: Accepting SSL tunnel: error:1408F09C:SSL routines:ssl3_get_record:http request (336130204) ``` I figured out from the Vibe.D source code that if I enable the debug level of the console logger, I

Re: Simulating computed goto

2020-11-25 Thread Dukc via Digitalmars-d-learn
On Wednesday, 25 November 2020 at 18:44:52 UTC, NonNull wrote: Is there a good way to simulate computed goto in D? I haven't used assembly myself, but it's possible that you can define a mixin that does this, using inline assembly.

Re: Simulating computed goto

2020-11-26 Thread Dukc via Digitalmars-d-learn
On Wednesday, 25 November 2020 at 20:05:28 UTC, NonNull wrote: So to simulate computed goto have to 1. wrap switch(x) in a loop [ while(0) ] 2. inside each case recompute x (instead of jump to computed y) 3. jump back to execute switch again [ continue ] It does look as if a nested switch can co

Re: Automatic update system

2020-11-26 Thread Dukc via Digitalmars-d-learn
On Thursday, 26 November 2020 at 12:13:59 UTC, vnr wrote: Hello, I have a program written in D which is open-source on GitHub. I would appreciate it if, when I release a new version, users would be notified by the program and that it offers an automatic update, i.e. the user doesn't have to r

Re: how to print progress of a long running parallel() loop?

2020-12-07 Thread Dukc via Digitalmars-d-learn
On Monday, 7 December 2020 at 08:16:50 UTC, mw wrote: r = Parallel(n_jobs=2, verbose=10)(delayed(sleep)(.2) for _ in range(10)) to print out the progress. How to do this in D's parallel loop? thanks. Allocate a `shared int` before the foreach loop. In the loop when, let's say `!(i & 0xFFF)

Re: To use or not immutable?

2020-12-09 Thread Dukc via Digitalmars-d-learn
On Wednesday, 9 December 2020 at 16:47:43 UTC, Jack wrote: Do you use it in your code base? are there some design flaws, like there's in C++'s const, which I'm not aware of? There are downsides, Jonathan Davis has written about them: http://www.jmdavisprog.com/articles/why-const-sucks.html B

Re: where is the memory corruption?

2020-12-09 Thread Dukc via Digitalmars-d-learn
On Wednesday, 9 December 2020 at 20:35:21 UTC, Jack wrote: the output is "h" rather "hello". What am I missing? In the sayHello function, you are converting a pointer to utf16 character into utf8 string, not utf16 string to utf8 string. Convert the C wstring to a D `wstring` first (std.strin

Re: Is there a standard function that combines take() and popFrontExactly()

2020-12-14 Thread Dukc via Digitalmars-d-learn
On Friday, 11 December 2020 at 19:07:23 UTC, realhet wrote: I've just made this unicode wordreplacer function working, but It seems not too nice and functional-ish. Are there ways to make it more simple? To answer the title, yes there is: ``` foreach(isWord, len; str.map!fun.group){ auto

Re: Floating point values in structs.

2020-12-22 Thread Dukc via Digitalmars-d-learn
On Friday, 18 December 2020 at 16:18:12 UTC, Dave P. wrote: If the compiler is going to introduce the overhead of initializing all the variables anyway, why set it to nan when integer types get set to the useful default of 0? Consider default value of `int*`. It is `null`, not a pointer to a

  1   2   3   >