Re: Array concatenation & optimisation

2024-07-21 Thread Johan via Digitalmars-d-learn
On Sunday, 21 July 2024 at 05:43:32 UTC, IchorDev wrote: Does this mean that array literals are *always* separately allocated first, or is this usually optimised out? Not always allocated, see your example below. I don't quite know what the heuristic is for allocation or not... For

Re: Using FFI to write a std::string to a buffer passed in from D

2024-07-21 Thread Johan via Digitalmars-d-learn
On Sunday, 21 July 2024 at 13:35:46 UTC, Troy wrote: void create(void* b) { std::string s = "engineer again"; *(std::string*)(b) = s;// Segfault here } You have to construct an empty string object first in location `b` (emplacement new). Then you can assign to it as you do.

Re: std.string.assumeUTF() silently casting mutable to immutable?

2024-02-13 Thread Johan via Digitalmars-d-learn
On Tuesday, 13 February 2024 at 08:10:20 UTC, Jonathan M Davis wrote: So, there's definitely a bug here, but it's a dmd bug. Its checks for whether it can safely change the constness of the return type apparently aren't sophisticated enough to catch this case. This is a pretty severe bug.

Re: LDC Stacktrace with symbols instead of addresses

2024-02-12 Thread Johan via Digitalmars-d-learn
On Monday, 12 February 2024 at 16:14:27 UTC, Per Nordlöw wrote: . Doing the same thing with LDC via ```sh ldc2 -g --d-debug -run app ``` gives ``` ld: error: undefined symbol: _D3etc5linux11memoryerror26registerMemoryErrorHandlerFNbZb referenced by app.d:3

Re: Why is the following failing?

2024-01-25 Thread Johan via Digitalmars-d-learn
On Thursday, 25 January 2024 at 16:07:44 UTC, Stefan Koch wrote: On Thursday, 25 January 2024 at 15:39:08 UTC, ryuukk_ wrote: ```D void main() { char[32] id = 0; id = "hello"; } ``` this works fine, and that is what i expect for the example above.. Raise a bug, I'll fix it. Hmm.

Re: Something similar to "inline"

2023-12-27 Thread Johan via Digitalmars-d-learn
On Wednesday, 27 December 2023 at 16:35:47 UTC, Paul Backus wrote: On Wednesday, 27 December 2023 at 15:57:14 UTC, tososdk wrote: Two things: Could you explain how "inline" works? Is there something similar in Dlang? I don't think the D forums is the best place to ask about how "inline"

Re: Building a wasm library, need to override .object._d_newitemT!T

2023-12-24 Thread Johan via Digitalmars-d-learn
On Saturday, 23 December 2023 at 20:42:37 UTC, Etienne Cimon wrote: I'm having a problem implementing the `new` keyword, so that I can start importing more libraries with minimal change. However, LDC calls .object._d_newitemT!T from the original druntime - which I need for compile-time

Re: macOS Sonoma Linker Issue

2023-12-22 Thread Johan via Digitalmars-d-learn
Some general advice: 1 - use `dub` from LDC's package (this may solve some arm64 vs x86 issues when on Apple Silicon CPU) 2 - when you use a new or different compiler, you have to rebuild _all_ packages. So clear your dub cache. I think point 2 is causing your issues. -Johan

Re: macOS Sonoma Linker Issue

2023-12-17 Thread Johan via Digitalmars-d-learn
On Wednesday, 13 December 2023 at 18:32:50 UTC, Renato wrote: On Wednesday, 4 October 2023 at 11:01:08 UTC, Johan wrote: On Tuesday, 3 October 2023 at 23:55:05 UTC, confuzzled wrote: Any known workaround for this most recent issue on macOS Sonoma? The file I'm compiling contains a blank main()

Re: Why can't we use strings in C++ methods?

2023-11-04 Thread Johan via Digitalmars-d-learn
On Saturday, 4 November 2023 at 12:01:11 UTC, Emmanuel Danso Nyarko wrote: On Saturday, 4 November 2023 at 11:18:02 UTC, Dadoum wrote: ```d extern (C) void hello(string arg) { import std.stdio; writeln(arg); } ``` Compiles fine with dmd, ldc2 and gdc. ```d extern (C++) void

Re: macOS Sonoma Linker Issue

2023-10-04 Thread Johan via Digitalmars-d-learn
On Tuesday, 3 October 2023 at 23:55:05 UTC, confuzzled wrote: Any known workaround for this most recent issue on macOS Sonoma? The file I'm compiling contains a blank main() without any imports but this error shows up on everything I've attempted to compile since upgrading to Sonoma.

Re: change object class

2023-09-17 Thread Johan via Digitalmars-d-learn
On Sunday, 17 September 2023 at 17:10:16 UTC, evilrat wrote: On Sunday, 17 September 2023 at 15:05:59 UTC, Vitaliy Fadeev wrote: It works! But I want to ask how to make this 100% the best of the best? What should I consider before changing ```__vptr``` ? If that works for you with that

Re: how to make pragma(lib)'s path relative to the package's path?

2023-07-31 Thread Johan via Digitalmars-d-learn
On Monday, 31 July 2023 at 00:32:07 UTC, ryuukk_ wrote: I reworked the PR, here is the new link: https://github.com/dlang/dmd/pull/15479 It basically add support for ``pragma(lib, "local:bin/lib.a");`` Makes things easier, and doesn't change any old behavior Before continuing with the PR,

Re: Which D compiler is the most maintained and future-proof? [DMD GDC and LDC]

2023-07-24 Thread Johan via Digitalmars-d-learn
On Monday, 24 July 2023 at 13:51:06 UTC, Steven Schveighoffer wrote: DMD is the point of all D feature introductions, and so anything that works with LDC should work with DMD. It's the other way around that might cause trouble, since there may be DMD features which haven't yet made it into

Re: Garbage Collectors

2023-07-19 Thread Johan via Digitalmars-d-learn
On Wednesday, 19 July 2023 at 11:27:14 UTC, Richard (Rikki) Andrew Cattermole wrote: [...] you would have to do a new build of druntime/phobos special which isn't the easiest thing to do. Side remark: LDC ships with the ldc-build-runtime tool which should help the user a lot in building

Re: Virtual method call from constructor

2023-04-05 Thread Johan via Digitalmars-d-learn
On Tuesday, 4 April 2023 at 07:08:52 UTC, Chris Katko wrote: dscanner reports this as a warning: ```D struct foo{ this() { /* some initial setup */ refresh(); } void refresh() { /* setup some more stuff */} // [warn] a virtual call inside a constructor may lead to unexpected results in

Re: Some questions with D and webassembly

2023-03-03 Thread Johan via Digitalmars-d-learn
On Friday, 3 March 2023 at 18:34:24 UTC, TheZipCreator wrote: On Friday, 3 March 2023 at 13:42:55 UTC, ryuukk_ wrote: On Friday, 3 March 2023 at 03:32:37 UTC, TheZipCreator wrote: [...] https://discourse.llvm.org/t/rfc-webassembly-reference-types-in-clang/66939 It looks like this needs

Re: MacOS Weirdness

2023-01-16 Thread Johan via Digitalmars-d-learn
On Tuesday, 17 January 2023 at 03:48:03 UTC, Ruby The Roobster wrote: I just fixed a bug in my personal D hobby project. After pushing everything to github, I noticed that it fails to link with the latest LDC on MacOS. The error I'm getting is thus: ``` ld: warning: alignment (1) of atom

Re: Pure D frontend as library.

2022-12-27 Thread Johan via Digitalmars-d-learn
On Monday, 26 December 2022 at 19:13:01 UTC, Alexandru Ermicioi wrote: Hi team, I'd like to ask a lazy question: How easy is to use D compiler frontend without backend? How complicated would be to write a transpiler, and from which files should you start modifications? I'm wondering if

Re: how to install the new dmd on Mac M1?

2022-08-27 Thread Johan via Digitalmars-d-learn
On Thursday, 25 August 2022 at 14:44:22 UTC, MichaelBi wrote: -iMac ~ % curl -fsS https://dlang.org/install.sh | bash -s dmd Unsupported Arch arm64 I've fixed this quite some time ago: https://github.com/dlang/installer/pull/491 Apparently it was never released? -Johan

Re: Cast converts AA to rvalue?

2022-08-10 Thread Johan via Digitalmars-d-learn
On Wednesday, 10 August 2022 at 09:52:10 UTC, ag0aep6g wrote: On 10.08.22 10:20, Johan wrote: ``` shared immutable int[int] aa; void main () {     // (cast()aa)[1] = 1; // works without immutable     (*cast(int[int]*)())[1] = 1; } ``` We have shared static constructors for that: shared

Re: Cast converts AA to rvalue?

2022-08-10 Thread Johan via Digitalmars-d-learn
On Wednesday, 10 August 2022 at 00:28:53 UTC, Steven Schveighoffer wrote: On 8/9/22 7:02 PM, Johan wrote: Testcase: ``` shared int[int] aa; void main () {     cast()aa[1] = 1; } ``` If you use `cast()(aa[1]) = 1`, it has a range error even on older versions. That it ever worked is

Cast converts AA to rvalue?

2022-08-09 Thread Johan via Digitalmars-d-learn
Testcase: ``` shared int[int] aa; void main () { cast()aa[1] = 1; } ``` Up to dlang 2.097, this program runs and works fine. Since dlang 2.098, the program errors with: `core.exception.RangeError@/app/example.d(3): Range violation` I think the 2.098+ behavior is correct, but I cannot find

Re: CMake and D

2022-08-04 Thread Johan via Digitalmars-d-learn
On Thursday, 4 August 2022 at 20:29:30 UTC, Jan Allersma wrote: So something goes wrong with linking, but I dont know what. Execute `dmd -v` on some test program. It will output the linker line at the end of the output, the line starting with `cc yourcode.o -o yourcode ...`. On that linker

Re: Using LDC2 with --march=amdgcn

2022-07-24 Thread Johan via Digitalmars-d-learn
On Sunday, 24 July 2022 at 18:44:42 UTC, realhet wrote: Hello, I noticed that the LDC2 compiler has an architecture target called "AMD GCN". Is there an example code which is in D and generates a working binary of a hello world kernel. I tried it, and just failed at the very beginning:

Re: How to map machine instctions in memory and execute them? (Aka, how to create a loader)

2022-06-06 Thread Johan via Digitalmars-d-learn
On Monday, 6 June 2022 at 15:13:45 UTC, rempas wrote: ``` // mov rdx, *cast(char*)(code + 14) = 0x48; *cast(char*)(code + 15) = 0xC7; *cast(char*)(code + 16) = 0xC2; *cast(char*)(code + 17) = 12; *cast(char*)(code + 18) = 0x00; *cast(char*)(code + 19) = 0x00; *cast(char*)(code +

Re: gdc 12.1: undefined references when linking separately compiled files

2022-05-30 Thread Johan via Digitalmars-d-learn
On Saturday, 28 May 2022 at 22:23:34 UTC, kdevel wrote: On Saturday, 28 May 2022 at 15:10:25 UTC, Steven Schveighoffer wrote: [...] Is this specific to gdc, or does it happen for other compilers as well? The former. Please check the dlang versions of all compilers. The template emission

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

2022-05-21 Thread Johan via Digitalmars-d-learn
On Tuesday, 17 May 2022 at 06:28:10 UTC, cc wrote: On Monday, 16 May 2022 at 15:08:15 UTC, H. S. Teoh wrote: For anything performance-related, I don't even look at dmd, I use LDC all the way. DMD is only useful for fast compile-run-debug cycle, I don't even look at performance numbers for

Re: Why are structs and classes so different?

2022-05-17 Thread Johan via Digitalmars-d-learn
On Monday, 16 May 2022 at 21:20:43 UTC, Ali Çehreli wrote: On 5/16/22 10:35, Johan wrote: > What is very problematic is that you cannot see the difference in > syntax. In my opinion it would have been much better if the language > required using a `*` for class types: for example `Foo* a`, and

Re: Why are structs and classes so different?

2022-05-16 Thread Johan via Digitalmars-d-learn
On Sunday, 15 May 2022 at 16:36:05 UTC, Ali Çehreli wrote: On 5/15/22 08:26, Kevin Bailey wrote: > structs and classes are so different. I think a more fundamental question is why structs and classes both exist at all. If they could be the same, one kind would be sufficient. And the answer

Re: Back to Basics at DConf?

2022-05-13 Thread Johan via Digitalmars-d-learn
On Thursday, 12 May 2022 at 21:58:33 UTC, Ali Çehreli wrote: I am considering proposing a presentation for DConf 2022. Would a "Back to Basics" style presentation be interesting? If, so what exact topic would you like to see? Hey Ali, When I read "Back to basics" on a program language

Re: While loop on global variable optimised away?

2022-05-11 Thread Johan via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 09:34:20 UTC, ichneumwn wrote: Hi Forum, I have a snippet of code as follows: ``` extern(C) extern __gshared uint g_count; // inside a class member function: while(g_count) <= count) {} ``` This is from a first draft of the code without proper thread

Re: gdc or ldc for faster programs?

2022-01-26 Thread Johan via Digitalmars-d-learn
On Wednesday, 26 January 2022 at 11:25:47 UTC, Iain Buclaw wrote: On Wednesday, 26 January 2022 at 04:28:25 UTC, Ali Çehreli wrote: On 1/25/22 16:15, Johan wrote: > On Tuesday, 25 January 2022 at 19:52:17 UTC, Ali Çehreli wrote: >> >> I am using compilers installed by Manjaro Linux's package

Re: gdc or ldc for faster programs?

2022-01-25 Thread Johan via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 19:52:17 UTC, Ali Çehreli wrote: I am using compilers installed by Manjaro Linux's package system: ldc: LDC - the LLVM D compiler (1.28.0): based on DMD v2.098.0 and LLVM 13.0.0 gdc: dc (GCC) 11.1.0 dmd: DMD64 D Compiler v2.098.1 What phobos version is

Re: gdc or ldc for faster programs?

2022-01-25 Thread Johan via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 19:52:17 UTC, Ali Çehreli wrote: I am not experienced with dub but I used --build=release-nobounds and verified that -O3 is used for both compilers. (I also tried building manually with GNU 'make' with e.g. -O5 and the results were similar.) `-O5` does not do

Re: Module without object file?

2022-01-07 Thread Johan via Digitalmars-d-learn
On Tuesday, 4 January 2022 at 22:17:38 UTC, kdevel wrote: Is there any chance to rephrase fsobjects.d such that it becomes a "header only"/"compile only" file of which no object file must be presented to the linker? https://wiki.dlang.org/LDC-specific_language_changes#LDC_no_moduleinfo

Re: FreeBSD 13 : wrong kernel version and size of kevent_t

2021-12-21 Thread Johan via Digitalmars-d-learn
On Tuesday, 21 December 2021 at 21:09:14 UTC, eugene wrote: On Tuesday, 21 December 2021 at 21:02:21 UTC, rempas wrote: On Tuesday, 21 December 2021 at 19:55:13 UTC, eugene wrote: core/sys/freebsd/config.d and core/sys/freebsd/sys/event.d are the same as in fresh dmd, so there is not much

Re: FreeBSD 13 : wrong kernel version and size of kevent_t

2021-12-21 Thread Johan via Digitalmars-d-learn
On Tuesday, 21 December 2021 at 10:28:15 UTC, eugene wrote: On Monday, 20 December 2021 at 21:19:43 UTC, rempas wrote: I would recommend you to file an [issue](https://issues.dlang.org/) just so the developers themself can notice it. filed an issue, see

Re: Is there a place I can learn LLD inline assembly with GCC syntax?

2021-12-15 Thread Johan via Digitalmars-d-learn
On Wednesday, 15 December 2021 at 09:26:28 UTC, rempas wrote: I want to learn how to use inline assembly for LDC with GCC syntax specifically so I can support all the targets (as [here](https://wiki.dlang.org/Compilers) it is said that DMD intel-like syntax only supports the "i386" and "amd64"

Re: Rather Bizarre slow downs using Complex!float with avx (ldc).

2021-09-30 Thread Johan via Digitalmars-d-learn
On Thursday, 30 September 2021 at 16:40:03 UTC, james.p.leblanc wrote: D-Ers, I have been getting counterintuitive results on avx/no-avx timing experiments. This could be an template instantiation culling problem. If the compiler is able to determine that `Complex!float` is already

Re: Can we rely on LDC respecting "align" (for avx) ??

2021-09-08 Thread Johan via Digitalmars-d-learn
On Wednesday, 8 September 2021 at 04:32:50 UTC, james.p.leblanc wrote: 1) Can we truly rely on LDC's alignment for AVX ? Yes. If you find wrong alignment, it's a bug. -Johan

Re: Phobos Unittest

2021-09-04 Thread Johan via Digitalmars-d-learn
On Saturday, 4 September 2021 at 03:18:01 UTC, Paul Backus wrote: On Saturday, 4 September 2021 at 00:09:37 UTC, H. S. Teoh wrote: This is related to the bogonity of the current behaviour of -unittest, which compiles *all* unittests of *all* imported modules, even when you're compiling user

Re: Anyway to achieve the following

2021-08-17 Thread Johan via Digitalmars-d-learn
On Monday, 16 August 2021 at 19:30:19 UTC, JG wrote: On Sunday, 15 August 2021 at 21:53:14 UTC, Carl Sturtivant wrote: On Sunday, 15 August 2021 at 07:10:17 UTC, JG wrote: [...] What you are asking for are reference variables. C++ has them: the example here illustrates the behavior you

Re: Anyway to achieve the following

2021-08-15 Thread Johan via Digitalmars-d-learn
On Sunday, 15 August 2021 at 16:49:22 UTC, Paul Backus wrote: On Sunday, 15 August 2021 at 07:10:17 UTC, JG wrote: Hi, This is exactly the behaviour I was trying to obtain. It however comes with a fair amount of overhead, as can be seen in the following llvm ir: [...] I'm not really

Re: semi-final switch?

2021-06-18 Thread Johan via Digitalmars-d-learn
On Thursday, 17 June 2021 at 21:41:28 UTC, Steven Schveighoffer wrote: However, sometimes the data I'm switching on is coming from elsewhere (i.e. a user), and while I want to enforce that the data is valid (it's one of the enum values), I don't want to crash the program if the incoming

Re: How to profile compile times of a source code?

2021-01-31 Thread Johan via Digitalmars-d-learn
On Sunday, 31 January 2021 at 16:39:12 UTC, Boris Carvajal wrote: On Sunday, 31 January 2021 at 16:13:24 UTC, Anonymouse wrote: Does ldc produce traces in a format that Tracy supports? I can't seem to open the generated *.time-trace files with it. (tracy 0.7.5-1 installed from Arch Linux AUR.)

Re: Is there a way to force emitting of stack frame for a specific function?

2020-10-09 Thread Johan via Digitalmars-d-learn
On Friday, 9 October 2020 at 02:01:30 UTC, Andrey Zherikov wrote: The question: is it possible to tell compiler to always generate stack frame for my stackFrame function? "pragma(inline, false)" doesn't help here - the result is completely the same. (Do you mean a stack frame, or a frame

Re: It is possible to substract 5 from 3 unsigned integer

2020-10-06 Thread Johan via Digitalmars-d-learn
On Tuesday, 6 October 2020 at 18:24:14 UTC, Alaindevos wrote: There are two subtractions possible. A machine-one which can be architecture dependent, does not have the same results on all computers, and behaves like a modulus in mathematics. A logical one. For the last one higher classes

Re: Building LDC runtime for a microcontroller

2020-09-19 Thread Johan via Digitalmars-d-learn
On Friday, 18 September 2020 at 23:00:33 UTC, Adam D. Ruppe wrote: The error says something about constness being different, well, why the eff would an init symbol ever be mutable? See https://forum.dlang.org/post/edngcvtlkjpykxvxy...@forum.dlang.org for why TypeInfo is mutable. (In this

Re: __vector(ubyte[32]) misalignment

2020-08-09 Thread Johan via Digitalmars-d-learn
On Sunday, 9 August 2020 at 01:03:51 UTC, Bruce Carneal wrote: The .alignof attribute of __vector(ubyte[32]) is 32 but initializing an array of such vectors via an assignment to .length has given me 16 byte alignment (and subsequent seg faults which I suspect are related). Is sub .alignof

Re: problem using std.format on Arm

2020-08-08 Thread Johan via Digitalmars-d-learn
On Saturday, 8 August 2020 at 17:00:17 UTC, Jeremiah Glover wrote: I've been wanting to put together a programming to teach D. The raspberry pi seemed like a good computer to use so everyone could be guaranteed to have a computer to practice on. I've had some trouble, however, getting a test

Re: D on lm32-CPU: string argument on stack instead of register

2020-07-31 Thread Johan via Digitalmars-d-learn
On Friday, 31 July 2020 at 10:22:20 UTC, Michael Reese wrote: My question: Is there a way I can tell the D compiler to use registers instead of stack for string arguments, or any other trick to reduce code size while maintaining an ideomatic D codestyle? A D string is a "slice", which is a

Re: miscellaneous array questions...

2020-07-21 Thread Johan via Digitalmars-d-learn
On Monday, 20 July 2020 at 22:05:35 UTC, WhatMeWorry wrote: 1) The D Language Reference says: "There are four kinds of arrays..." with the first example being "type* Pointers to data" and "int* p; etc. At the risk of sounding overly nitpicky, isn't a pointer to an integer simply a

Re: What would be the advantage of using D to port some games?

2020-07-21 Thread Johan via Digitalmars-d-learn
On Wednesday, 24 June 2020 at 18:53:34 UTC, matheus wrote: Hi, I currently use D for small CLI/Batch apps, before that I used to program in C. Despite of using D I usually program like C but with the advantage of: GC, AA, CTFE and a few classes here and there. As we can see there are a lot

Re: Why infinite loops are faster than finite loops?

2020-06-21 Thread Johan via Digitalmars-d-learn
On Saturday, 20 June 2020 at 21:11:57 UTC, tastyminerals wrote: I am not sure that this is a question about D or a more general one. I have watched this nice presentation "Speed Is Found In The Minds of People" by Andrei: https://www.youtube.com/watch?v=FJJTYQYB1JQ=youtu.be?t=2596 and on 43:20

Re: What is the equivalent of -version=Flag for conditional compilation in the ldc2 compiler?

2020-06-05 Thread Johan via Digitalmars-d-learn
On Friday, 5 June 2020 at 22:36:23 UTC, data pulverizer wrote: Hi, I was switching from dmd to ldc2 and would like to know the equivalent command line for conditional compilation -version=Flag I was using in dmd. I checked the ldc2 --help but didn't see anything relevant. Version there

Re: Detecting performance pitfall in array access

2020-05-17 Thread Johan via Digitalmars-d-learn
On Sunday, 17 May 2020 at 03:30:57 UTC, Adnan wrote: Hello, I am trying to examine what causes my similar D solution to lag behind performance. In the link, they don't have ldc or gdc but according to my machine, the dmd generated code isn't really far behind ldc generated code.

Re: Compililng C++ and D together without going mad

2020-04-29 Thread Johan via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 13:02:36 UTC, Jan Hönig wrote: On Wednesday, 29 April 2020 at 11:38:16 UTC, Johan wrote: LDC is a (somewhat complex) project with D and C++ code (and external C++ libraries). I think it will help you if your main() is in D (such that druntime is automatically

Re: Compililng C++ and D together without going mad

2020-04-29 Thread Johan via Digitalmars-d-learn
On Wednesday, 29 April 2020 at 10:25:31 UTC, Jan Hönig wrote: In my pet project, I am using some C++ libraries. The main file/function is also C++. All of it successfully compiles with cmake. Now I want to add some functionality by calling my own D functions (which use some other

Re: How do I disable the multithreaded GC?

2020-04-09 Thread Johan via Digitalmars-d-learn
On Thursday, 9 April 2020 at 20:42:18 UTC, Stefan Koch wrote: Simple question, how do I keep the GC from spawning threads? Cheers, Stefan https://dlang.org/changelog/2.087.0.html#gc_parallel

Re: Cross-compile for ARM

2020-04-08 Thread Johan via Digitalmars-d-learn
On Wednesday, 8 April 2020 at 15:52:59 UTC, Severin Teona wrote: Hello, I am working with a NUCLEO_f429zi board, architecure ARMv7e-m and cortex-m4 CPU. I want to cross-compile D code for it from Ubuntu 18.04 LTS Server. My current GCC version is 9. How can I do that? What is the best

Re: CT BitArray

2020-04-05 Thread Johan via Digitalmars-d-learn
On Wednesday, 31 October 2018 at 23:14:08 UTC, Bastiaan Veelo wrote: Currently, BitArray is not usable at compile time, so you cannot do ``` enum e = BitArray([1, 1, 1, 0]); ``` This gives /dlang/dmd/linux/bin64/../../src/phobos/std/bitmanip.d(1190): Error: `bts` cannot be interpreted at

Re: CT BitArray

2020-04-04 Thread Johan via Digitalmars-d-learn
On Friday, 3 April 2020 at 20:06:50 UTC, Steven Schveighoffer wrote: On 4/3/20 3:13 PM, Johan wrote: On Thursday, 2 April 2020 at 12:41:28 UTC, Steven Schveighoffer wrote: Hm... I thought there was precedent for providing fallback implementations for intrinsics. That is, you define the

Re: CT BitArray

2020-04-03 Thread Johan via Digitalmars-d-learn
On Thursday, 2 April 2020 at 12:41:28 UTC, Steven Schveighoffer wrote: On 4/2/20 8:26 AM, Bastiaan Veelo wrote: On Thursday, 1 November 2018 at 08:50:38 UTC, Bastiaan Veelo wrote: On Thursday, 1 November 2018 at 00:01:04 UTC, Stefan Koch wrote: On Wednesday, 31 October 2018 at 23:14:08 UTC,

Re: DMD 2.090.1: SIGILL, Illegal instruction on (ahem) intel Pentium III

2020-03-11 Thread Johan via Digitalmars-d-learn
On Wednesday, 11 March 2020 at 22:18:04 UTC, kdevel wrote: On Thursday, 27 February 2020 at 19:24:39 UTC, Johan wrote: LDC will work fine if told what processor you have: https://d.godbolt.org/z/5hrzgm -m32 -mcpu=pentium3 (-mcpu=native should also work). When I "cross compile" on an AMD 64

Re: How to use sets in D?

2020-03-08 Thread Johan via Digitalmars-d-learn
On Sunday, 8 March 2020 at 08:43:10 UTC, mark wrote: Here are some timings ... [...] #!/usr/bin/env rdmd Please remember that performance testing is not trivial. At the very least, you should be testing optimized code (-O) and preferably with LDC or GDC because they have a much stronger

Re: DMD 2.090.1: SIGILL, Illegal instruction on (ahem) intel Pentium III

2020-02-27 Thread Johan via Digitalmars-d-learn
On Thursday, 27 February 2020 at 18:07:40 UTC, Rainer Schuetze wrote: On 27/02/2020 11:30, kdevel wrote: On Thursday, 27 February 2020 at 07:44:57 UTC, Seb wrote: On Thursday, 27 February 2020 at 00:36:49 UTC, kdevel wrote: [...] Program received signal SIGILL, Illegal instruction.

Re: Strange counter-performance in an alternative `decimalLength9` function

2020-02-26 Thread Johan via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 00:50:35 UTC, Basile B. wrote: So after reading the translation of RYU I was interested too see if the decimalLength() function can be written to be faster, as it cascades up to 8 CMP. ... Then bad surprise. Even with ldmd (so ldc2 basically) feeded with

Re: Easiest way to use FMA instruction

2020-01-09 Thread Johan via Digitalmars-d-learn
On Friday, 10 January 2020 at 00:02:52 UTC, Johan wrote: For LDC: ``` double fma(double a, double b, double c) { import ldc.llvmasm; return __irEx!( `declare double @llvm.fma.f64(double %a, double %b, double %c)`, `%r = call double @llvm.fma.f64(double %0,

Re: Easiest way to use FMA instruction

2020-01-09 Thread Johan via Digitalmars-d-learn
On Thursday, 9 January 2020 at 22:50:37 UTC, Ben Jones wrote: On Thursday, 9 January 2020 at 20:57:10 UTC, Ben Jones wrote: What's the easiest way to use the FMA instruction (fused multiply add that has nice rounding properties)? The FMA function in Phobos just does a*b +c which will round

Re: undefined symbol: _D3std7variant...

2019-10-23 Thread Johan via Digitalmars-d-learn
On Wednesday, 23 October 2019 at 20:45:55 UTC, baz wrote: On Tuesday, 22 October 2019 at 13:07:54 UTC, Andrey wrote: On Tuesday, 22 October 2019 at 12:57:45 UTC, Daniel Kozak wrote: Have you try to clean all caches? Try to remove .dub folder I removed .dub folder but this error appears

CTFE static array error: cannot modify read-only constant

2017-09-22 Thread Johan via Digitalmars-d-learn
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 read-only constant [0, 1, 2] 8:called from here:

Re: Express "Class argument may not be null" ?

2017-08-09 Thread Johan via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 12:47:49 UTC, Steven Schveighoffer wrote: On 8/8/17 3:59 PM, Johan Engelen wrote: In C++, it is clear that the _caller_ is doing the dereferencing, and the dereference is also explicit. In fact it's not doing any dereferencing. It's just under the hood

map on char[] converts to dchar?

2017-07-24 Thread Johan via Digitalmars-d-learn
Hi all, What am I doing wrong here? ``` import std.algorithm; int foo(char c) { return 123; } auto mapFoo(char[] chars) { return chars.map!(a => a.foo); } ``` errors with: main.d(14): Error: function main.foo (char c) is not callable using argument types (dchar)