Re: Need Advice: Union or Variant?

2022-11-17 Thread Petar via Digitalmars-d-learn
On Thursday, 17 November 2022 at 20:54:46 UTC, jwatson-CO-edu wrote: I have an implementation of the "[Little Scheme](https://mitpress.mit.edu/9780262560993/the-little-schemer/)" educational programming language written in D, [here](https://github.com/jwatson-CO-edu/SPARROW)". It has many

Re: T... args!

2021-12-09 Thread Petar via Digitalmars-d-learn
On Thursday, 9 December 2021 at 00:36:29 UTC, Salih Dincer wrote: On Wednesday, 8 December 2021 at 23:47:07 UTC, Adam Ruppe wrote: On Wednesday, 8 December 2021 at 23:43:48 UTC, Salih Dincer wrote: I think you meant to say void foo(string[] args...) {} Not exactly... ```d alias str =

Re: Any workaround for "closures are not yet supported in CTFE"?

2021-12-08 Thread Petar via Digitalmars-d-learn
On Wednesday, 8 December 2021 at 17:05:49 UTC, Timon Gehr wrote: On 12/8/21 9:07 AM, Petar Kirov [ZombineDev] wrote: [...] Nice, so the error message is lying. Closure support deserves way more love in the compiler. I'm quite surprised that that hack worked, given that various very similar

Re: Any workaround for "closures are not yet supported in CTFE"?

2021-12-08 Thread Petar via Digitalmars-d-learn
On Wednesday, 8 December 2021 at 12:17:42 UTC, Stanislav Blinov wrote: On Wednesday, 8 December 2021 at 08:07:59 UTC, Petar Kirov [ZombineDev] wrote: ```d interface ICallable { void opCall() const; } alias Action = void delegate(); struct A { Action[] dg; } ``` At this point why

Re: Any workaround for "closures are not yet supported in CTFE"?

2021-12-08 Thread Petar via Digitalmars-d-learn
On Wednesday, 8 December 2021 at 07:55:55 UTC, Timon Gehr wrote: On 08.12.21 03:05, Andrey Zherikov wrote: On Tuesday, 7 December 2021 at 18:50:04 UTC, Ali Çehreli wrote: I don't know whether the workaround works with your program but that delegate is the equivalent of the following struct

Re: Was this supposed to be allowed?

2021-09-15 Thread Petar via Digitalmars-d-learn
On Wednesday, 15 September 2021 at 13:52:40 UTC, z wrote: ```D float[2] somevalue = somefloat3value[] + cast(Unqual!float[2]) [somesharedfloatarray1[i],somesharedfloatarray2[ii]]; ``` Older LDC/DMD releases never complained but now that i upgraded DMD, DMD-compiled builds suffer from runtime

Re: github copilot and dlang

2021-07-05 Thread Petar via Digitalmars-d-learn
On Monday, 5 July 2021 at 15:56:38 UTC, Antonio wrote: Has someone tried github copilot (https://copilot.github.com/) with dlang? Access to the preview could be requested and, I think, main dlang team members could bypass the waitlist easily. I suspect that the "low" volume of dlang code

Re: Checking for manifest constants

2021-03-05 Thread Petar via Digitalmars-d-learn
On Friday, 5 March 2021 at 08:23:09 UTC, Bogdan wrote: I was using a trick with dmd to check for manifest constants which worked until dmd v2.094. Yesterday I tried it on the latest compiler and it failed with: source/introspection/manifestConstant.d(37,28): Error: need this for name of

Re: GC.addRange in pure function

2021-02-12 Thread Petar via Digitalmars-d-learn
On Friday, 12 February 2021 at 12:17:13 UTC, Per Nordlöw wrote: On Tuesday, 9 February 2021 at 03:05:10 UTC, frame wrote: On Sunday, 7 February 2021 at 14:13:18 UTC, vitamin wrote: Why using 'new' is allowed in pure functions but calling GC.addRange or GC.removeRange isn't allowed? Would

Re: GC.addRange in pure function

2021-02-12 Thread Petar via Digitalmars-d-learn
On Friday, 12 February 2021 at 19:48:01 UTC, vitamin wrote: On Wednesday, 10 February 2021 at 16:25:44 UTC, Petar Kirov [ZombineDev] wrote: On Wednesday, 10 February 2021 at 13:44:53 UTC, vit wrote: [...] TL;DR Yes, you can, but it depends on what "without problem" means for you :P [...]

Re: GC.addRange in pure function

2021-02-10 Thread Petar via Digitalmars-d-learn
On Wednesday, 10 February 2021 at 16:25:44 UTC, Petar Kirov [ZombineDev] wrote: [..] A few practical examples: Here it is deemed that the only observable side-effect of `malloc` and friends is the setting of `errno` in case of failure, so these wrappers ensure that this is not observed.

Re: GC.addRange in pure function

2021-02-10 Thread Petar via Digitalmars-d-learn
On Wednesday, 10 February 2021 at 13:44:53 UTC, vit wrote: On Wednesday, 10 February 2021 at 12:17:43 UTC, rm wrote: On 09/02/2021 5:05, frame wrote: On Sunday, 7 February 2021 at 14:13:18 UTC, vitamin wrote: Why using 'new' is allowed in pure functions but calling GC.addRange or

Re: Dimensions in compile time

2021-02-08 Thread Petar via Digitalmars-d-learn
On Monday, 8 February 2021 at 13:09:53 UTC, Rumbu wrote: On Monday, 8 February 2021 at 12:19:26 UTC, Basile B. wrote: On Monday, 8 February 2021 at 11:42:45 UTC, Vindex wrote: size_t ndim(A)(A arr) { return std.algorithm.count(typeid(A).to!string, '['); } Is there a way to find out the

Re: std.expreimantal.allocator deallocate

2021-01-24 Thread Petar via Digitalmars-d-learn
On Sunday, 24 January 2021 at 14:56:25 UTC, Paul Backus wrote: On Sunday, 24 January 2021 at 11:00:17 UTC, vitamin wrote: It is Ok when I call deallocate with smaller slice or I need track exact lengtht? It depends on the specific allocator, but in general, it is only guaranteed to work

Re: std.expreimantal.allocator deallocate

2021-01-24 Thread Petar via Digitalmars-d-learn
On Sunday, 24 January 2021 at 16:16:12 UTC, vitamin wrote: On Sunday, 24 January 2021 at 14:56:25 UTC, Paul Backus wrote: On Sunday, 24 January 2021 at 11:00:17 UTC, vitamin wrote: It is Ok when I call deallocate with smaller slice or I need track exact lengtht? It depends on the specific

Re: Value of type enum members

2021-01-19 Thread Petar via Digitalmars-d-learn
On Tuesday, 19 January 2021 at 20:27:30 UTC, Andrey Zherikov wrote: Could someone please explain why there is a difference in values between compile-time and run-time? struct T { int i; this(int a) {i=a;} } enum TENUM : T { foo = T(2), bar = T(3), } void main() {

Re: Git-repo-root relative path

2020-11-18 Thread Petar via Digitalmars-d-learn
On Monday, 16 November 2020 at 10:21:27 UTC, Per Nordlöw wrote: I need a function that gets the relative path of a file in a Git-repo and preferrably also its status. I'm not sure I understand the question. I have written two programs, hopefully one of them does what you want :D Either via

Re: Why is time_t defined as a 32-bit type on Windows?

2020-08-07 Thread Petar via Digitalmars-d-learn
On Friday, 7 August 2020 at 05:37:32 UTC, Andrej Mitrovic wrote: On Wednesday, 5 August 2020 at 16:13:19 UTC, Andrej Mitrovic wrote: ``` C:\dev> rdmd -m64 --eval="import core.stdc.time; writeln(time_t.sizeof);" 4 ``` According to MSDN this should not be the case:

Re: core.thread vs std.concurrency - which of them to use?

2020-08-06 Thread Petar via Digitalmars-d-learn
On Thursday, 6 August 2020 at 01:13:28 UTC, Victor L Porton wrote: When to use core.thread and when std.concurrency for multithreading in applications? Is one of them a preferred way? Druntime's core.thread sets the foundation for D's multi-threading (or at least the non-betterC foundation).

Re: Strong typing and physical units

2020-07-28 Thread Petar via Digitalmars-d-learn
On Tuesday, 28 July 2020 at 04:40:33 UTC, Cecil Ward wrote: [snip] By the way, I found 2 implementations of unit of measurement in D: https://code.dlang.org/packages/units-d https://code.dlang.org/packages/quantities

Re: String switch is odd using betterC

2020-02-26 Thread Petar via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 08:32:50 UTC, Abby wrote: On Wednesday, 26 February 2020 at 08:25:00 UTC, Abby wrote: Any idea why? Ok so this is enough to produce the same result, it seems that there is a problem in string switch when there is more the 6 cases. extern(C) void main() {

Re: What's opIndexAssign supposed to return ?

2020-02-25 Thread Petar via Digitalmars-d-learn
On Tuesday, 25 February 2020 at 11:02:40 UTC, wjoe wrote: Lets say I've got 3 overloads of opIndexAssign: auto opIndexAssign(T t); auto opIndexAssign(T t, size_t i); and auto opIndexAssign(T t, size_t[2] i); I would assume to return what I would return with opIndex but I'd rather not act upon

Re: Two problems with json and lcd

2020-02-19 Thread Petar via Digitalmars-d-learn
On Wednesday, 19 February 2020 at 08:14:34 UTC, AlphaPurned wrote: The first is std.json. It is broke. Doesn't work with tuples. The change above fixes it by treating tuple as an array(same code). It works fine. Can you post a minimal, but complete program that shows the problems with

Re: State of MIPS

2020-02-19 Thread Petar via Digitalmars-d-learn
On Wednesday, 19 February 2020 at 07:09:02 UTC, April wrote: What's the current state of MIPS compiling for bare metal? Especially the R4300i processor. I see MIPS on both GDC and LDC "partial support/bare metal" lists but them being somewhat vague about it I'm not quite sure which it means

Re: Two problems with json and lcd

2020-02-18 Thread Petar via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 18:05:43 UTC, AlphaPurned wrote: json has two issues, it doesn't work with tuple: (isArray!T) goes to (isArray!T || (T.stringof.length > 4 && T.stringof[0..5] == "Tuple")) and right below else { static assert(false, text(`unable

Re: How to declare a virtual member (not a function) in a class

2020-02-18 Thread Petar via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 12:37:45 UTC, Adnan wrote: I have a base class that has a couple of constant member variables. These variables are abstract, they will only get defined when the derived class gets constructed. class Person { const string name; const int id; } class

Re: Alternative to friend functions?

2020-02-18 Thread Petar via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 12:43:22 UTC, Adnan wrote: What is the alternative to C++'s friend functions in D? module stable_matching; alias FemaleID = int; alias MaleID = int; class Person { string name; int id; } class Male : Person { this(string name = "Unnamed Male") {

Re: DPP: Linker issue with functions implemented in C header files

2020-02-18 Thread Petar via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 09:20:08 UTC, Andre Pany wrote: Hi Petar, Hi Andre, I'm happy to help :) thank you very much for the explanation and the code sample. Filling the az_span anonymous member was the tricky part, I thought it would be not possible to do so, but you showed me the

Re: DPP: Linker issue with functions implemented in C header files

2020-02-18 Thread Petar via Digitalmars-d-learn
On Tuesday, 18 February 2020 at 05:41:38 UTC, Andre Pany wrote: Hi, I try to get wrap the "Azure SDK for C" using DPP and have following issue. Functions, which are actually implemented in C header files will cause linker errors:

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

2020-02-12 Thread Petar via Digitalmars-d-learn
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 some requirement for the release tag for it to be recognized? Hi Dukc, I'm

Re: Building for multiple platforms

2020-02-12 Thread Petar via Digitalmars-d-learn
On Wednesday, 12 February 2020 at 12:46:23 UTC, Petar Kirov [ZombineDev] wrote: On Wednesday, 12 February 2020 at 08:41:25 UTC, Neils wrote: [...] Since your project is already on GitHub, I think the easiest solution would be to use GitHub Actions [1] + setup-dlang action [2] +

Re: Building for multiple platforms

2020-02-12 Thread Petar via Digitalmars-d-learn
On Wednesday, 12 February 2020 at 08:41:25 UTC, Neils wrote: I maintain an open-source project written in D and I use DUB for building and my compiler backend is DMD. My dub.json file is rather simple: https://github.com/neilsf/XC-BASIC/blob/master/dub.json I offer pre-built binaries for

Re: How do I fix my failed PRs?

2020-02-03 Thread Petar via Digitalmars-d-learn
On Sunday, 2 February 2020 at 08:54:02 UTC, mark wrote: I've done quite a few small corrections/improvements to the D-tour's English. Almost all have been accepted. However, four have not been accepted, apparently for technical reasons. But I don't understand what's wrong or what I need to

Re: lambda alias import

2020-01-17 Thread Petar via Digitalmars-d-learn
On Friday, 17 January 2020 at 23:04:57 UTC, Petar Kirov [ZombineDev] wrote: [..] *If* you compile both modules .. [..]

Re: lambda alias import

2020-01-17 Thread Petar via Digitalmars-d-learn
On Friday, 17 January 2020 at 21:40:05 UTC, JN wrote: stuff.d: alias doStuff = () {}; main.d: import stuff; void main() { doStuff(); } DMD throws compile error: Error 42: Symbol Undefined __D5stuff9__lambda3FNaNbNiNfZv Is this expected behavior? It tripped me while trying to use

Re: Information about the 'magic' field in object.Object class

2020-01-16 Thread Petar via Digitalmars-d-learn
On Thursday, 16 January 2020 at 14:32:24 UTC, Adam D. Ruppe wrote: On Thursday, 16 January 2020 at 14:30:04 UTC, realhet wrote: Is there a documentation about that 'magic' field? I'm pretty sure the only fields in there are pointer to vtable and pointer to monitor object... I have a really

Re: Mapping float to ulong in CTFE

2019-12-12 Thread Petar via Digitalmars-d-learn
On Thursday, 12 December 2019 at 19:21:22 UTC, berni44 wrote: Is it possible to get to the bits of a float in CTFE? I tried the following, but this doesn't work: ``` import std.stdio; union FloatBits { float floatValue; ulong ulongValue; } ulong test(float f) { FloatBits fb;

Re: std.format range with compound format specifiers?

2019-11-19 Thread Petar via Digitalmars-d-learn
On Tuesday, 19 November 2019 at 21:50:08 UTC, Steven Schveighoffer wrote: I know I can format a range with a format string that contains %(%s, %). And this results in a nice comma separated list for each item. But what about an item that has a not-so-cookie-cutter format? Like for instance a

Re: CI: Why Travis & Circle

2019-11-16 Thread Petar via Digitalmars-d-learn
On Thursday, 14 November 2019 at 17:32:27 UTC, jmh530 wrote: On Thursday, 14 November 2019 at 17:06:36 UTC, Andre Pany wrote: [snip] With the public availability of Github Actions I highly recommend it if you have open source project on Github. If is free and works well with D and Dub.

Re: Meson build system user new to D.

2019-05-07 Thread Petar via Digitalmars-d-learn
On Monday, 6 May 2019 at 19:52:23 UTC, Mike Brockus wrote: Hello everyone I am a Meson build system user and I am new to the D language, just wondering if there are compiler flags that I should add, unit testing frameworks, any good practices I can follow and or anything like that also some

Re: Design by Introspection - Looking for examples

2019-01-14 Thread Petar via Digitalmars-d-learn
On Tuesday, 15 January 2019 at 00:42:37 UTC, Tony A wrote: Hi, I just watched the Andrei's talk about Design by Introspection and for what I see this is used in D. Could anyone point out some good Github examples that I can see this in action and the benefits? Thanks. Basically, look for

Re: Dub and it's build directory

2018-08-21 Thread Petar via Digitalmars-d-learn
On Monday, 20 August 2018 at 18:59:23 UTC, Russel Winder wrote: Hi, [...] Hi Russel, So the questions are: 1. How does Dub find the compiler version number, in this case 2.081, given that neither DMD or LDC seem to have a way of delivering only the version number. The __VERSION__ [1]

Re: is this a betterC bug ?

2018-08-15 Thread Petar via Digitalmars-d-learn
On Wednesday, 15 August 2018 at 08:14:53 UTC, Petar Kirov [ZombineDev] wrote: https://run.dlang.io/is/iD9ydu I made a typo in one of the comments. Here's the fixed version: https://run.dlang.io/is/HRqYcZ

Re: is this a betterC bug ?

2018-08-15 Thread Petar via Digitalmars-d-learn
On Tuesday, 14 August 2018 at 17:49:32 UTC, Mike Franklin wrote: On Tuesday, 14 August 2018 at 17:22:42 UTC, Seb wrote: FYI: staticArray will be part of 2.082, it already works with dmd-nightly: That just seems wrong. Isn't the fact that `staticArray` is needed a bug in the compiler? I

Re: dtoh

2018-08-12 Thread Petar via Digitalmars-d-learn
On Tuesday, 7 August 2018 at 12:46:31 UTC, Steven Schveighoffer wrote: On 8/7/18 6:08 AM, bauss wrote: On Monday, 6 August 2018 at 13:28:05 UTC, Laeeth Isharc wrote: Hi Walter. Can dtoh be open-sourced now that dmd is? https://github.com/adamdruppe/dtoh I might be confused, but it seems

Re: Storing Formatted Array Value

2017-11-28 Thread Petar via Digitalmars-d-learn
On Wednesday, 29 November 2017 at 07:08:12 UTC, Vino wrote: Hi All, Request your help, with the below code I am able to print the value of the array without brackects , but can some on help me on hot to store this output to a variable Program: import std.stdio; import std.container; void

Re: dmd/ldc failed with exit code -11

2017-11-22 Thread Petar via Digitalmars-d-learn
On Wednesday, 22 November 2017 at 15:33:46 UTC, Anonymouse wrote: On Tuesday, 21 November 2017 at 19:22:47 UTC, Anonymouse wrote: Compiling a debug dmd and running the build command in gdb, it seems to be a stack overflow at ddmd/dtemplate.d:6241, TemplateInstance::needsCodegen(). After a

Re: dmd/ldc failed with exit code -11

2017-11-21 Thread Petar via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 10:10:59 UTC, Petar Kirov [ZombineDev] wrote: On Tuesday, 21 November 2017 at 00:15:04 UTC, Anonymouse wrote: I have a large named enum (currently 645 members) of IRC event types. It's big by neccessity[1]. I'm using dub, and both dmd and ldc successfully build

Re: dmd/ldc failed with exit code -11

2017-11-21 Thread Petar via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 00:15:04 UTC, Anonymouse wrote: I have a large named enum (currently 645 members) of IRC event types. It's big by neccessity[1]. I'm using dub, and both dmd and ldc successfully build it in test and debug modes, but choke and die on plain and release. I

Re: DMD test suite assertion failure in test_cdvecfill.d

2017-11-21 Thread Petar via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 07:02:20 UTC, Michael V. Franklin wrote: I'm getting this error when I try to run the DMD test suite. cd dmd make -C test -f Makefile [...] I don't think you're doing anything wrong, though you shouldn't be getting that error. File a bug report and try

Re: Turn a float into a value between 0 and 1 (inclusive)?

2017-11-21 Thread Petar via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 09:53:33 UTC, Petar Kirov [ZombineDev] wrote: On Tuesday, 21 November 2017 at 09:21:29 UTC, Chirs Forest wrote: I'm interpolating some values and I need to make an (elapsed_time/duration) value a float between 0 and 1 (inclusive of 0 and 1). The elapsed_time

Re: Turn a float into a value between 0 and 1 (inclusive)?

2017-11-21 Thread Petar via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 09:21:29 UTC, Chirs Forest wrote: I'm interpolating some values and I need to make an (elapsed_time/duration) value a float between 0 and 1 (inclusive of 0 and 1). The elapsed_time might be more than the duration, and in some cases might be 0 or less. What's the

Re: Inference of GC allocation scope

2017-11-16 Thread Petar via Digitalmars-d-learn
On Thursday, 16 November 2017 at 17:29:56 UTC, Nordlöw wrote: Are there any plans on a compiler pass that finds scoped GC-allocations and makes their destructors deterministic similar to D's struct scope behaviour?

Re: How you guys go about -BetterC Multithreading?

2017-11-10 Thread Petar via Digitalmars-d-learn
On Thursday, 9 November 2017 at 19:42:55 UTC, Jacob Carlborg wrote: On 2017-11-09 17:52, Petar Kirov [ZombineDev] wrote: Thanks for reminding me, I keep forgetting that it should just work (minus initialization?). What do you mean "initialization"? static constructors

Re: How you guys go about -BetterC Multithreading?

2017-11-10 Thread Petar via Digitalmars-d-learn
On Friday, 10 November 2017 at 11:55:57 UTC, Guillaume Piolat wrote: On Thursday, 9 November 2017 at 16:00:36 UTC, Petar Kirov [ZombineDev] wrote: In short, the cost / benefit of going all the way version(D_BetterC) is incredibly poor for regular applications, as you end up a bit more

Re: How you guys go about -BetterC Multithreading?

2017-11-09 Thread Petar via Digitalmars-d-learn
On Thursday, 9 November 2017 at 16:08:20 UTC, Jacob Carlborg wrote: On 2017-11-09 13:19, Petar Kirov [ZombineDev] wrote: Though you need to be extra careful not to use thread-local storage I think TLS should work, it's the OS that handles TLS, not druntime. Thanks for reminding me, I keep

Re: How you guys go about -BetterC Multithreading?

2017-11-09 Thread Petar via Digitalmars-d-learn
On Thursday, 9 November 2017 at 13:00:15 UTC, ParticlePeter wrote: On Thursday, 9 November 2017 at 12:19:00 UTC, Petar Kirov [ZombineDev] wrote: On Thursday, 9 November 2017 at 11:08:21 UTC, ParticlePeter wrote: Any experience reports or general suggestions? I've used only D threads so far.

Re: How you guys go about -BetterC Multithreading?

2017-11-09 Thread Petar via Digitalmars-d-learn
On Thursday, 9 November 2017 at 12:30:49 UTC, rikki cattermole wrote: On 09/11/2017 12:19 PM, Petar Kirov [ZombineDev] wrote: On Thursday, 9 November 2017 at 11:08:21 UTC, ParticlePeter wrote: Any experience reports or general suggestions? I've used only D threads so far. It would be far

Re: How you guys go about -BetterC Multithreading?

2017-11-09 Thread Petar via Digitalmars-d-learn
On Thursday, 9 November 2017 at 11:08:21 UTC, ParticlePeter wrote: Any experience reports or general suggestions? I've used only D threads so far. It would be far easier if you use druntime + @nogc and/or de-register latency-sensitive threads from druntime [1], so they're not interrupted

Re: Request Assistance Calling D from C++: weird visibility issue inside struct and namespace

2017-11-08 Thread Petar via Digitalmars-d-learn
On Wednesday, 8 November 2017 at 07:55:02 UTC, Andrew Edwards wrote: On Wednesday, 8 November 2017 at 07:30:34 UTC, evilrat wrote: On Wednesday, 8 November 2017 at 06:34:27 UTC, Andrew Edwards just using fully qualified name didn't make it? void call_cpp() { ::foo("do great things"); //

Re: CTFE static array error: cannot modify read-only constant

2017-09-23 Thread Petar via Digitalmars-d-learn
On Friday, 22 September 2017 at 14:43:28 UTC, Johan wrote: Hi all, ``` auto foo(const int[3] x) { int[3] y = x; y[0] = 1; // line 4 return y; } immutable int[3] a = [0,1,2]; immutable int[3] b = foo(a); // line 8 ``` compiles with an error: ``` 4: Error: cannot modify