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

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]

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

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,

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)() {

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 = !((a, b) => a.splitter(b).array);

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

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

Re: Indenting standards religions K, 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

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

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

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

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; }

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

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

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-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: 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

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

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: 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

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

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,

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.

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

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

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

Re: print ubyte[] as (ascii) string

2022-01-07 Thread Dukc via Digitalmars-d-learn
On Thursday, 30 December 2021 at 09:34:27 UTC, eugene wrote: ```d char[] s = cast(char[])ioCtx.buf[0 .. strlen(cast(char*)ioCtx.buf.ptr) - 1]; // -1 is to eliminate terminating '\n' writefln("got '%s' from '%s:%d'", s, client.addr, client.port); ``` Is there some more concise/elegant way to

Re: Why do we have Dmain?

2021-10-22 Thread Dukc via Digitalmars-d-learn
On Friday, 22 October 2021 at 07:00:25 UTC, Mike Parker wrote: The entry point for your program is a function `_start`. That's implemented in the C runtime, which all D programs depend on. It in turn calls `main`, as it does for C and C++ programs. It is possible, in both C and D, to write

Re: better c fibers

2021-09-27 Thread Dukc via Digitalmars-d-learn
On Tuesday, 21 September 2021 at 09:37:30 UTC, Abby wrote: Hi there, I'm new in dlang I specially like betterC. I was hoping that d fibers would be implemented in without using classes, but there are not. Is there another way how to use async/await in dlang better c? Thank you for your help

Re: Array permutations

2021-09-11 Thread Dukc via Digitalmars-d-learn
On Saturday, 11 September 2021 at 19:37:42 UTC, Vino wrote: Request your help on the below to print the below array as "Required output", Was able to get these values "[1,2],[2,3],[3,4],[4,5]" by using list.slide(2), need your help to get values "1,3],[1,4],[1,5],[2,4],[2,5],[3,5]" ```d

Re: Ali's Book - Programming in D

2021-09-11 Thread Dukc via Digitalmars-d-learn
On Friday, 10 September 2021 at 22:26:34 UTC, Ali Çehreli wrote: https://bitbucket.org/acehreli/ddili/commits/ Ah it's there - gotta remember that place if I want to make corrections. Good book - It's the one that got me up to speed with D before I was commited enough to pay for anything.

Re: How to Fix Weird Build Failure with "-release" but OK with "-debug"?

2021-07-21 Thread Dukc via Digitalmars-d-learn
On Wednesday, 21 July 2021 at 14:15:51 UTC, Steven Schveighoffer wrote: 2. It's hard for me to see where the null dereference would be in that function (the `bool` implementation is pretty simple). -Steve DMD complains about dereferences in three different lines. I suspect it's `this`

Re: Can static variables in methods be local for each object?

2021-07-20 Thread Dukc via Digitalmars-d-learn
On Tuesday, 20 July 2021 at 09:24:07 UTC, Mark Lagodych wrote: Is there a way to make myvar local to each instance of `X` without making it a variable of `X`? Just curious. Yes. ```d import std.stdio; class X { int x(int param) { static int[typeof(this)] myvar; if (param

Re: Why can't we transpile C++ to D?

2021-06-10 Thread Dukc via Digitalmars-d-learn
On Thursday, 10 June 2021 at 15:09:02 UTC, Tejas wrote: Sorry, I'm rather ignorant when it comes to this, but why can't we use [pegged](https://github.com/PhilippeSigaud/Pegged) to transpile C++ code to D? Then we won't need a nogc compatible std library and so many other things could get

Re: coreutils with D trials, wc, binary vs well formed utf

2021-05-24 Thread Dukc via Digitalmars-d-learn
Is there a(n easy-ish) way to fix up that wc.d source in the blog to fallback to byte stream mode when a utf-8 reader fails an encoding? Rewrite `toLine`: ``` Line toLine(char[] l) pure { import std.array : array; import std.algorithm : filter; import std.utf : byDchar, replacementDchar;

Re: dlang opengl / gl / glu /glut library.

2021-04-21 Thread Dukc via Digitalmars-d-learn
On Sunday, 18 April 2021 at 23:36:58 UTC, Alain De Vos wrote: When doing graphics the number of functions explodes. So one needs always a list, compare to a header file in c. If there are "modern" alternatives to opengl feel free. More modern from which perspective? Simpler to use

Re: Dlang equivalent of #define/#ifdef : not... version

2021-04-21 Thread Dukc via Digitalmars-d-learn
On Tuesday, 20 April 2021 at 23:58:46 UTC, Steven Schveighoffer wrote: static if(i_am_a_feature) { ... } This would be correct if `i_am_a_feature` would be always defined, just set to `false` if not existent. But I think the idea was to not define the symbol at all if feature does not

Re: How to get Laptop battery level

2021-02-22 Thread Dukc via Digitalmars-d-learn
On Monday, 22 February 2021 at 21:14:48 UTC, Dukc wrote: Note that DGame seems to be currently unmaintained - it might have some bits that do not compile anymore. SDL2 is a commonly used library though - you should be able to find more examples about it if you need to. Plus, the example I

Re: How to get Laptop battery level

2021-02-22 Thread Dukc via Digitalmars-d-learn
On Monday, 22 February 2021 at 20:59:01 UTC, Greatsam4sure wrote: Dlang is a system programming language. How do I access the battery level of my system using code in dlang? As a systems language, D could access the hardware interface directly, if you knew it and loaded your program as a

Re: Profiling

2021-02-09 Thread Dukc via Digitalmars-d-learn
On Tuesday, 9 February 2021 at 16:39:25 UTC, Dukc wrote: You may have or may not have done it wrong, but in any case this is a bug. If you do something wrong, the program should tell you what you did wrong, instead of telling you that character '-' does not belong to middle of a long int. Oh

Re: Profiling

2021-02-09 Thread Dukc via Digitalmars-d-learn
On Tuesday, 9 February 2021 at 07:45:13 UTC, JG wrote: Is d-profile-viewer no longer working? Or did I do something wrong? You may have or may not have done it wrong, but in any case this is a bug. If you do something wrong, the program should tell you what you did wrong, instead of telling

Re: Open question: what code pattern you use usually for null safety problem

2021-01-15 Thread Dukc via Digitalmars-d-learn
On Thursday, 14 January 2021 at 18:24:44 UTC, ddcovery wrote: This is only an open question to know what code patterns you usually use to solve this situation in D: if(person.father.father.name == "Peter") doSomething(); if(person.father.age > 80 ) doSomething(); knowing that *person*, or

Re: Why many programmers don't like GC?

2021-01-14 Thread Dukc via Digitalmars-d-learn
On Thursday, 14 January 2021 at 14:28:43 UTC, Виталий Фадеев wrote: On Wednesday, 13 January 2021 at 18:58:56 UTC, Marcone wrote: I've always heard programmers complain about Garbage Collector GC. But I never understood why they complain. What's bad about GC? How write quickly without GC ?

Re: DConf talk : Exceptions will disappear in the future?

2021-01-06 Thread Dukc via Digitalmars-d-learn
On Monday, 4 January 2021 at 15:39:50 UTC, ludo456 wrote: Listening to the first visioconf of the Dconf 2020, titled Destroy All Memory Corruption, (https://www.youtube.com/watch?v=XQHAIglE9CU) Walter talks about not using exceptions any more in the future. He says something like "this is

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

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: 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

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

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 &

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

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

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: 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,

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

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

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

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

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: 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: 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

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

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

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

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: 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:

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

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

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: 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

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

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:

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

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

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

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-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

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,

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

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

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: 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

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 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 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

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;

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

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

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: 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: 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: 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: 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

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: 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

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-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

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

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

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

  1   2   3   >