Re: CTFE and RTFE results differ (aliasing)

2025-06-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 5 May 2025 at 17:15:57 UTC, kdevel wrote: ```d // // bs3.d // 2025-05-05 stvo // // $ dmd -g -checkaction=context -unittest -main -run bs3.d // bs3.d(25): [unittest] [4, 3, 3, 4] != [4, 3, 2, 1] // 1/1 modules FAILED unittests // [...] Filed as https://github.com/dlang/dmd/issues/21

Re: String Interpolation support in VS Code

2025-02-23 Thread Jordan Wilson via Digitalmars-d-learn
On Sunday, 23 February 2025 at 14:10:09 UTC, Arredondo wrote: Coming back to D after a few years of inactivity, and I'm pleasantly surprised that we now have string interpolation (sort of) in the language. The issue I'm having is with Visual Studio Code. I'm getting a red squiggle under the e

Re: Vibe.d Password Verification

2025-02-05 Thread Adam Wilson via Digitalmars-d-learn
On Wednesday, 5 February 2025 at 15:16:10 UTC, seany wrote: Is there any built in passowrd verification for Vibe.d? Such as bcrypt.verifypassword(password , hash)? I looked at this library: https://code.dlang.org/packages/passwd This is causing linking error ( ld: error: unable to find library

Re: Open a folder with explorer.exe

2024-12-28 Thread Jordan Wilson via Digitalmars-d-learn
On Saturday, 28 December 2024 at 18:55:08 UTC, bauss wrote: I cannot figure out how to get spawnProcess working with explorer.exe on Windows. Been trying to call it like: ``` spawnProcess(["explorer.exe", path]); ``` But it only opens explorer.exe in the documents path and not the path given

Re: Recommendations on porting Python to D

2024-12-19 Thread Jordan Wilson via Digitalmars-d-learn
On Friday, 20 December 2024 at 00:53:30 UTC, Chris Piker wrote: Though I probably shouldn't give in, this response does break my cool a little bit, so one time only... rant / / rant Definitely seen worse Xmas rants here ;-) Jordan

D-Scanner errors

2024-11-25 Thread Jordan Wilson via Digitalmars-d-learn
I have some `iq{}` blocks, that D-Scanner shows up as errors. I believe this is because `libdparse` doesn't support interpolated strings yet. So, I attempted to suppress these errors in D-Scanner, but I find that you can't disable sections of code, only disable the warnings in their entirety.

Re: Do not able to install DMD Compiler with curl

2024-10-31 Thread Jordan Wilson via Digitalmars-d-learn
On Thursday, 31 October 2024 at 08:00:25 UTC, Salih Dincer wrote: The following there is error "No public key"! ``` md@SDB MSYS ~ $ curl -fsS https://dlang.org/install.sh | bash -s dmd Downloading https://dlang.org/d-keyring.gpg ###

Re: Would appreciate some help porting Q3VM to D (mainly C macros and type conversions)

2024-10-18 Thread Jordan Wilson via Digitalmars-d-learn
On Friday, 18 October 2024 at 14:41:15 UTC, Mark Bauermeister wrote: On Thursday, 17 October 2024 at 02:47:03 UTC, Mai Lapyst wrote: [...] Yea. I forgot about the sizeof division being wrong. I replaced all calls to ARRAY_LEN with \.length. [...] Is the `switch` correct? I would expect to

Re: Find homography in D?

2024-04-30 Thread Jordan Wilson via Digitalmars-d-learn
On Sunday, 21 April 2024 at 14:57:33 UTC, Paolo Invernizzi wrote: Hi, Someone can point me to a D implementation of the classical OpenCV find homography matrix? Thank you, Paolo Something I wrote awhile ago... ``` import kaleidic.lubeck : svd; import gfm.math; import mir.ndslice : sliced;

profiling vibe

2024-02-02 Thread Jordan Wilson via Digitalmars-d-learn
I can't seem to be able to use `--profile` with vibe: ```shell dub init -t vibe.d dub build --build=profile ../../.dub/packages/vibe-core/2.7.3/vibe-core/source/vibe/internal/async.d-mixin-119(142,3): Warning: statement is not reachable ../../.dub/packages/vibe-core/2.7.3/vibe-core/source/vibe/

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

2024-01-19 Thread Jordan Wilson via Digitalmars-d-learn
On Friday, 19 January 2024 at 08:57:40 UTC, Renato wrote: Do you know why the whole thread seems to have disappeared?? There's a lot of good stuff in the thread, it would be a huge shame to lose all that! I agree! Thanks for posting your benchmarks, I thought your whole benching setup was pre

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

2024-01-14 Thread Jordan Wilson via Digitalmars-d-learn
On Saturday, 13 January 2024 at 11:03:42 UTC, Renato wrote: I like to use a phone encoding problem to determine the strenghtness and weaknesses of programming languages because this problem is easy enough I can write solutions in any language in a few hours, but complex enough to exercise lots

Desiring bool any_key_pressed()

2023-03-02 Thread Daren Scot Wilson via Digitalmars-d-learn
Here is a very simple version of the program I'm working on. Is there a way to write is_any_key_pressed() that doesn't block, doesn't require the Enter key, and doesn't require dragging in any complex libraries or dealing with low-level stuff like ioctl()? Is there nothing in Phobos that provi

Re: stdin.readln line editing and recall with up arrow

2023-02-28 Thread Daren Scot Wilson via Digitalmars-d-learn
On Saturday, 25 February 2023 at 08:47:42 UTC, Richard (Rikki) Andrew Cattermole wrote: On 25/02/2023 9:45 PM, Daren Scot Wilson wrote: I went with readline.  Left/right arrows work, but up arrow still does not recall earlier commands. Maybe I need also a separate input history thing? https:/

Re: stdin.readln line editing and recall with up arrow

2023-02-25 Thread Daren Scot Wilson via Digitalmars-d-learn
On Saturday, 25 February 2023 at 05:41:48 UTC, Richard (Rikki) Andrew Cattermole wrote: On 25/02/2023 6:36 PM, Daren Scot Wilson wrote: stdin.readln() works fine until I, out of habit, use the up arrow to recall an earlier input and the left/right to move around and change a character.   How do

stdin.readln line editing and recall with up arrow

2023-02-24 Thread Daren Scot Wilson via Digitalmars-d-learn
stdin.readln() works fine until I, out of habit, use the up arrow to recall an earlier input and the left/right to move around and change a character. How do I get that to work?

Re: Which TOML package, or SDLang?

2023-01-30 Thread Daren Scot Wilson via Digitalmars-d-learn
On Monday, 30 January 2023 at 17:54:15 UTC, H. S. Teoh wrote: XML is evil. Agreed! I'm going with TOML, community package. It's working, so far.

Which TOML package, or SDLang?

2023-01-29 Thread Daren Scot Wilson via Digitalmars-d-learn
So, which package do I use for TOML? I find these three: * toml-foolery (Andrej Petrović) * toml-d, or toml.d (oglu on github) at ver 0.3.0 * toml, (dlang community on github) at ver 2.0.1 I'm guessing from version numbers that the third one, toml, is officially good for real world use. But I

Re: Handling CheckBox state changes in DLangUI

2022-12-30 Thread Daren Scot Wilson via Digitalmars-d-learn
On Saturday, 31 December 2022 at 03:05:45 UTC, brianush1 wrote: On Saturday, 31 December 2022 at 02:40:49 UTC, Daren Scot Wilson wrote: The compiler errors I get are, for no '&' and with '&': Error: function `app.checkbox_b_clicked(Widget source, bool checked)` is not callable using argument t

Handling CheckBox state changes in DLangUI

2022-12-30 Thread Daren Scot Wilson via Digitalmars-d-learn
I'm writing a GUI program using dlangui. It has some checkboxes. I'm trying to figure out how to invoke a callback function when the user clicks the box. What are the valid ways of doing that? I can copy from dlangide's source, where a delegate is defined in-line and assigned. That seems to wo

Re: Passing D reimplementation of C++ template as argument to a C++ function

2022-09-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 24 September 2022 at 07:04:34 UTC, Gregor Mückl wrote: Hi! I have a D template struct that reimplements a C++ class template with identical memory layout for a set of types that matter to me. Now, I want to use some C++ functions and classes that use these template instances, fro

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

2022-08-25 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 26 August 2022 at 00:34:30 UTC, MichaelBi wrote: when using ldc2, has this error "ld: library not found for -lssl" after dub build --compiler=ldc2 So where is your ssl library located and how (if at all) are you telling the compiler/linker where to find it?

Re: Using LDC2 with --march=amdgcn

2022-07-26 Thread Nicholas Wilson 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: How

Re: Python <==> d call both ways example (with PyD and autowrap)?

2022-06-22 Thread Jordan Wilson via Digitalmars-d-learn
On Wednesday, 22 June 2022 at 16:02:00 UTC, mw wrote: Hi, I know with PyD, D can call Python, and with autowrap, Python can call a D .dll, I'm just wondering if someone can show an example that Python <==> d can call both ways? esp. show passing D objects to Python and then call its member fu

Re: How to do same as 'nmap' command from within a D program?

2022-01-24 Thread Daren Scot Wilson via Digitalmars-d-learn
On Sunday, 23 January 2022 at 06:30:11 UTC, frame wrote: On Saturday, 22 January 2022 at 20:55:38 UTC, Daren Scot Wilson wrote: I don't see any D std.* libraries that do this. Are there a Dub packages I should look at? If you really want to this in D without any external app or OS API you c

How to do same as 'nmap' command from within a D program?

2022-01-22 Thread Daren Scot Wilson via Digitalmars-d-learn
I'm writing a command line program to control certain hardware devices. I can hardcode or have in a config file the IP addresses for the devices, if I know that info. If I don't? Then I run an 'nmap' command and look for the devices. But why should I, a human, have to do any work like that? B

Re: writeln the struct from the alis this Example from the home page

2021-11-18 Thread Jordan Wilson via Digitalmars-d-learn
On Thursday, 18 November 2021 at 16:08:22 UTC, Paul Backus wrote: On Thursday, 18 November 2021 at 13:51:42 UTC, Martin Tschierschke wrote: [...] You can define a `toString` method, like this: ```d string toString() { import std.conv; return p.to!string; } ``` You can find more infor

Re: Obtain pointer from static array literal

2021-10-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 8 October 2021 at 05:31:21 UTC, codic wrote: On Friday, 8 October 2021 at 05:01:00 UTC, Nicholas Wilson wrote: note that if the pointer is not escaped from the function (i.e. thing is void thing(scope int* abc)note the addition of scope) LDC will perform promotion of GC allocation to

Re: Obtain pointer from static array literal

2021-10-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 8 October 2021 at 02:49:17 UTC, codic wrote: I am working with a C API (XCB) which uses `void*` a lot to obtain parameter packs; these are very small and throwaway so I want them to be allocated to the stack. CUDA has something similar that I have to deal with for dcompute[1]. The

Re: How can we view source code that has been generated (say via "static foreach") ?

2021-09-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 16 September 2021 at 04:54:21 UTC, james.p.leblanc wrote: Thank you for your kind response. Wow, at first the large output file from a small test program was a bit surprising .., but actually it is manageable to dig through to find the interesting bits. So, this is quite useful!

Re: yet another segfault - array out of bound is not caught by try catch

2021-09-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 17 September 2021 at 11:10:33 UTC, seany wrote: I have now this function, as a private member in a Class : } catch (RangeError er) { I can't remember if you can catch an index OOB error but try `catch (Throwable er)` will work if it is catchable at all and you can figur

Re: is it possible to sort a float range ?

2021-06-23 Thread Jordan Wilson via Digitalmars-d-learn
On Wednesday, 23 June 2021 at 22:46:28 UTC, Steven Schveighoffer wrote: On 6/23/21 6:30 PM, Jordan Wilson wrote: On Wednesday, 23 June 2021 at 19:53:24 UTC, someone wrote: [...] ```sort``` returns a ```SortedRange```, and I believe you wish to return a float. So you can do either ```return

Re: is it possible to sort a float range ?

2021-06-23 Thread Jordan Wilson via Digitalmars-d-learn
On Wednesday, 23 June 2021 at 19:53:24 UTC, someone wrote: Please, look for the line marked +++ This is a structure with a public property returning a (still unsorted) range built on-the-fly from already-set properties, a basic range from a to z with n step where some specific values can be a

Re: Now can build and run d on RISC-V arch?

2021-06-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 6 June 2021 at 04:14:20 UTC, lili wrote: I want learn RISC-V and write a simple kernel on it using d. but can not find any support about RISC-V. LDC can compile for riscv 32 and 64 bit. https://github.com/ldc-developers/ldc/releases/tag/v1.26.0 use `-mtriple=riscv32` or `-mtriple=r

Re: DUB doesn't seem to respect my config, am I doing something wrong?

2021-05-22 Thread Jordan Wilson via Digitalmars-d-learn
On Saturday, 22 May 2021 at 20:28:56 UTC, rempas wrote: I've read the documentation about DUB's config (I'm using the SDL format) and it seems that DUB completely ignores my config. My config file is: ``` name "test" description "Testing dub" authors "rempas" copyright "Copyright © 2021, rempa

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Jordan Wilson via Digitalmars-d-learn
On Sunday, 16 May 2021 at 09:55:31 UTC, Chris Piker wrote: On Sunday, 16 May 2021 at 09:17:47 UTC, Jordan Wilson wrote: Another example: ```d auto r = [iota(1,10).map!(a => a.to!int),iota(1,10).map!(a => a.to!int)]; # compile error ``` Hi Jordan Nice succinct example. Thanks for looking at

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Jordan Wilson via Digitalmars-d-learn
On Sunday, 16 May 2021 at 07:20:52 UTC, Chris Piker wrote: On Saturday, 15 May 2021 at 14:05:34 UTC, Paul Backus wrote: If you post your code (or at least a self-contained subset of it) someone can probably help you figure out where you're running into trouble. The error messages by themselves

Re: Local library with dub

2021-04-21 Thread Jordan Wilson via Digitalmars-d-learn
On Wednesday, 21 April 2021 at 15:07:25 UTC, JG wrote: On Wednesday, 21 April 2021 at 00:39:41 UTC, Mike Parker wrote: On Tuesday, 20 April 2021 at 18:43:28 UTC, JG wrote: This still leaves open the question of how to include a version of such a library in another project via dub. Execute

Re: Contributing CDF bindings to Deimos

2021-03-25 Thread Jordan Wilson via Digitalmars-d-learn
On Thursday, 25 March 2021 at 04:00:33 UTC, Chris Piker wrote: On Tuesday, 23 March 2021 at 05:54:13 UTC, mw wrote: [...] Okay, that's done. The repo https://github.com/das-developers/deimos.cdf and package https://code.dlang.org/packages/cdf have been drafted and tested on Linux, I'm about

Re: Strange error

2021-03-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 22 March 2021 at 07:52:14 UTC, MichaelJames wrote: Tell me, did you manage to solve this problem? https://github.com/dlang/dmd/pull/12300

Re: Simple BeamUI project won't link

2020-12-18 Thread Daren Scot Wilson via Digitalmars-d-learn
On Wednesday, 16 December 2020 at 07:45:50 UTC, Ferhat Kurtulmuş wrote: On Wednesday, 16 December 2020 at 07:40:45 UTC, Ferhat Kurtulmuş wrote: This may be not your issue, but I could manage it to work by adding this line: subPackage "examples/myproject" to the dub.sdl of the beamui. I simp

Re: Simple BeamUI project won't link

2020-12-18 Thread Daren Scot Wilson via Digitalmars-d-learn
On Wednesday, 16 December 2020 at 07:40:45 UTC, Ferhat Kurtulmuş wrote: On Wednesday, 16 December 2020 at 07:02:11 UTC, Daren Scot Wilson wrote: Trying out the beamui GUI package, obtained by git clone from github. The "basic" example builds and runs. I'm working on an Arch Linux machine with

Simple BeamUI project won't link

2020-12-15 Thread Daren Scot Wilson via Digitalmars-d-learn
Trying out the beamui GUI package, obtained by git clone from github. The "basic" example builds and runs. So I create a new project from scratch, with "dub init beamy beamui" (ircc) in a directory outside beamui's, sibling to it in fact. This builds and runs, but does not make use of beamui

synthesising instantiated template parameters and arguments

2020-10-27 Thread Nicholas Wilson via Digitalmars-d-learn
Given template ScopeClass(C) { //... } where C is a, possibly templated, class I want the eponymous member of ScopeClass!(C) to have the same templatedness (both parameters and arguments)as C. For a non-template C this is a simple as: template ScopeClass(C) { class ScopeClass {

Re: Two ways of receiving arrays on the C ABI

2020-10-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 20 October 2020 at 00:16:48 UTC, Ali Çehreli wrote: On the D side, both of the following extern(C) functions take the same arguments. https://github.com/dlang/dmd/pull/8120 there are issues with structs. Not sure about length/ptr.

Re: Asserting that a base constructor is always called

2020-05-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 24 May 2020 at 06:38:46 UTC, Tim wrote: Oh right. I mean it makes sense but I got confused when super() is valid syntax. Why would you need to call the super constructor when it's called automatically? A base class with a constructor that has no args will automatically get called a

Re: Thread to watch keyboard during main's infinite loop

2020-05-06 Thread Daren Scot Wilson via Digitalmars-d-learn
On Thursday, 7 May 2020 at 01:02:57 UTC, ag0aep6g wrote: Thank you, this is 110% helpful. Actually, I'd like to return the excess 10%. My dmd compiler does not like: import core.thread: sleep; so I put the code back the way I had, just to get on with work. Use `shared` so that all thr

Thread to watch keyboard during main's infinite loop

2020-05-06 Thread Daren Scot Wilson via Digitalmars-d-learn
I'm writing a simple command line tool to send data by UDP once per second forever, to test some software on another machine. Not actually forever, of course, but until ^C or I hit 'Q'. I want to tap keys to make other things happen, like change the data or rate of sending. Not sure of the b

Re: determine ldc version in static if or version?

2020-04-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 1 April 2020 at 21:19:54 UTC, Adam D. Ruppe wrote: I want to do like static if(__LDC_VERSION == 1.19) { // declaration } All the tricks I know that I have tried so far give the dmd numbers. Perhaps I could use that to identify a particular version as a hack, but I specificall

Re: Best way to learn 2d games with D?

2020-03-15 Thread Jordan Wilson via Digitalmars-d-learn
On Sunday, 15 March 2020 at 17:58:58 UTC, Steven Schveighoffer wrote: I want to try and learn how to write 2d games. I'd prefer to do it with D. I've found a ton of tutorials on learning 2d gaming with other languages. Is there a place to look that uses D for learning? Should I just start wit

Re: SQLite 3 support?

2020-02-26 Thread Jordan Wilson via Digitalmars-d-learn
On Wednesday, 26 February 2020 at 20:06:20 UTC, mark wrote: There seems to be some support for SQLite 3 in std. lib. etc when looking at the stable docs: https://dlang.org/phobos/etc_c_sqlite3.html But this isn't visible when looking at stable (ddox). Is this the best SQLite 3 library to use o

Re: Finding position of a value in an array

2019-12-31 Thread Daren Scot Wilson via Digitalmars-d-learn
On Tuesday, 31 December 2019 at 06:01:36 UTC, Paul Backus wrote: countUntil operates on ranges, and static arrays aren't ranges. To get a range from a static array, you have to slice it with the `[]` operator: int i = info.doos[].countUntil(important_d); (Why can't static arrays be range

Re: Finding position of a value in an array

2019-12-30 Thread Daren Scot Wilson via Digitalmars-d-learn
On Monday, 30 December 2019 at 23:15:48 UTC, JN wrote: On Sunday, 29 December 2019 at 08:31:13 UTC, mipri wrote: int i = a.countUntil!(v => v == 55); assert(i == 2); I also had to ask because I couldn't find it. In other languages it's named "index()", "indexOf()" or "find()". D is the only

Finding position of a value in an array

2019-12-29 Thread Daren Scot Wilson via Digitalmars-d-learn
Reading documentation... Array, Algorithms, ... maybe I've been up too late... how does one obtain the index of, say, 55 in an array like this int[] a = [77,66,55,44]; I want to do something like: int i = a.find_value_returning_its_index(55); assert(i==2) I'm sure it's obvious bu

Re: No UFCS with nested functions?

2019-11-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 4 November 2019 at 19:51:26 UTC, Tobias Pankrath wrote: Why does the following not work? It works, if I move the 'prop' out of 'foo'. --- struct S { ubyte[12] bar; } bool foo (ref S s) { static bool prop(const(ubyte)[] f) { return f.length > 1; } return s

Re: exceptions and optimization

2019-10-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 21 October 2019 at 21:09:32 UTC, Peter Jacobs wrote: On Monday, 21 October 2019 at 20:37:32 UTC, Nicholas Wilson wrote: What kind of conditions are you wanting to throw exception on? infinities, NaNs, ill conditioning, something else? As always the best way to check is to mark the

Re: contains method on immutable sorted array

2019-10-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 21 October 2019 at 10:14:54 UTC, Andrey wrote: Hello, I have got a global constant immutable array: immutable globalvalues = sort(cast(wstring[])["й", "ц", "ук", "н"]); Somewhere in program I want to check an existance: globalvalues.contains("ук"w).writeln; But get an error: Erro

Re: exceptions and optimization

2019-10-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 21 October 2019 at 20:12:19 UTC, Peter Jacobs wrote: Toward the end of Walter's recent talk, D at 20, he says something to the effect that optimizations are disabled when exceptions can be thrown. We have a compressible flow solver in which it is very convenient to be able to throw

Re: Is there a way to do the same thing in entry and return of a bunch of functions?

2019-09-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 17 September 2019 at 17:11:09 UTC, Stefanos Baziotis wrote: I think it's better to give a concrete example rather than explaining this vaguely. -- The question -- Can we do better ? For one, I believe that because D does not have a preprocessor, we have to do an actual declaration

Re: LDC asm for int128

2019-09-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 10 September 2019 at 06:18:05 UTC, Newbie2019 wrote: I want to translate this c code into d (build with ldc), so I can use -flto and inline with other code. uint64_t _wymum(uint64_t A, uint64_t B){ __uint128_t r = A ; r *= B; return (r>>64)^r; } Do i need A

Re: Undefined reference - built from source DMD

2019-09-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 10 September 2019 at 11:12:30 UTC, Stefanos Baziotis wrote: I don't if this the right group to post this. DMD built from source fails to link / find `main`. The error is: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start': (.text+0x20): undefined

Re: Why is sformat and formattedWrite (appender) allocating GC mem here?

2019-08-31 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 31 August 2019 at 21:12:32 UTC, ag0aep6g wrote: I've made a pull request to get rid of those allocations: https://github.com/dlang/phobos/pull/7163 Merged.

Re: Is removing elements of AA in foreach loop safe?

2019-08-30 Thread Jordan Wilson via Digitalmars-d-learn
On Thursday, 29 August 2019 at 10:11:58 UTC, berni wrote: Iterating of some structure and removing elements thereby is always errorprone and should be avoided. But: In case of AA, I've got the feeling, that it might be safe: foreach (k,v;ways) if (v.empty) ways.remove(k); Do you

Re: Shadertoy in Dcompute?

2019-08-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 22 August 2019 at 00:57:26 UTC, Bert wrote: How hard would it be to do something like Shadertoy in Dcompute and would it be any faster? I don't like the basics of Shadertoy, lots of nonsense to do basic stuff. E.g., to work with complex numbers one must essentially do everything

Re: Function called twice

2019-08-02 Thread Jordan Wilson via Digitalmars-d-learn
On Friday, 2 August 2019 at 22:35:53 UTC, Adam D. Ruppe wrote: On Friday, 2 August 2019 at 21:44:28 UTC, Jordan Wilson wrote: // outputs 1 2 2 3 z.map!(a => tuple!("number","iseven")(a, a.isEven)) .filter!(a => a.iseven) .array; I *think* what's happening here

Function called twice

2019-08-02 Thread Jordan Wilson via Digitalmars-d-learn
Hello, I don't quite understand why isEven is called twice in the 2nd example? auto isEven(int n) { n.writeln; return (n % 2) == 0; } void main() { auto z = [1,2,3]; // outputs 1 2 3 z.map!(a => tuple!("number")(a)) .filter!(a => a.nu

Re: Wrong vtable for COM interfaces that don't inherit IUnknown

2019-07-15 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 15 July 2019 at 22:01:25 UTC, KytoDragon wrote: I am currently trying to write a XAudio2 backend and have come across the problem, that some of the interfaces for XAudio2's COM objects seem to be missing the first entry in their vtable. After reading the iterface article in the spec

Re: Finding Max Value of Column in Multi-Dimesional Array

2019-07-04 Thread Jordan Wilson via Digitalmars-d-learn
On Friday, 5 July 2019 at 00:54:15 UTC, Samir wrote: Is there a cleaner way of finding the maximum value of say the third column in a multi-dimensional array than this? int[][] p = [[1,2,3,4], [9,0,5,4], [0,6,2,1]]; writeln([p[0][2], p[1][2], p[2][2]].max); I've tried the following writeln([0,

Re: D on ARM laptops?

2019-07-03 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 3 July 2019 at 20:49:20 UTC, JN wrote: Does anyone know if and how well D works on ARM laptops (such as Chromebooks and similar)? For example this one https://www.pine64.org/pinebook/ . Can it compile D? Obviously DMD is out because it doesn't have ARM builds. Not sure about GDC

Re: Illegal Filename after basic install and trying Hello World

2019-06-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 26 June 2019 at 13:57:22 UTC, Gilbert Fernandes wrote: I am using VS 2019 into which I have C# and C++ active. Installed the following : DMD 2.086.1 then Visual D 0.50.0 DMD has been installed at the base of C:\ at C:\D Created a D project, which contains a default Hello world pro

Re: DIP 1016 and const ref parameters

2019-06-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 19 June 2019 at 19:25:59 UTC, Jonathan M Davis wrote: Aside from looking through the newsgroup/forum for discussions on DIPs, that's pretty much all you're going to find on that. Andrei's talk is the most up-to-date information that we have about this particular DIP. The prel

Re: is there a way to embed python 3.7 code in D program?

2019-05-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 12 May 2019 at 20:06:34 UTC, torea wrote: Hi, I'd like to use D for the "brain" of a small robot (Anki vector) whose API is coded in Python 3.6+. I had a look at Pyd but it's limited to python 2.7... It isn't. You may needs to set a dub version, or it may pick up the 2.7 as the d

Re: Compiler/Phobos/Types problem — panic level due to timing.

2019-05-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 5 May 2019 at 19:18:47 UTC, lithium iodate wrote: On Sunday, 5 May 2019 at 18:53:08 UTC, Russel Winder wrote: Hi, I had merrily asumed I could implement nth Fibonacci number with: takeOne(drop(recurrence!((a, n) => a[n-1] + a[n-2])(zero, one), n)).front where zero and one a

Re: I had a bad time with slice-in-struct array operation forwarding/mimicing. What's the best way to do it?

2019-05-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 4 May 2019 at 15:18:58 UTC, Random D user wrote: I wanted to make a 2D array like structure and support D slice like operations, but I had surprisingly bad experience. I quickly copy pasted the example from the docs: https://dlang.org/spec/operatoroverloading.html#array-ops It's

Call delegate from C++

2019-04-24 Thread Nicholas Wilson via Digitalmars-d-learn
How do you pass a delegate to a c++ function to be called by it? The function to pass the delegate to is: extern (C++) int fakeEntrypoint( extern(C++) void function(void* /*delegate's context*/) func, void* /*delegate's context*/ arg); What I want is: int entrypoint(scope void delegat

Re: Error: template instance `Reflect!(type)` cannot use local `type` as parameter to non-global template `Reflect(Ts...)()`

2019-04-06 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 7 April 2019 at 05:24:38 UTC, Alex wrote: Error: template instance `Reflect!(type)` cannot use local `type` as parameter to non-global template `Reflect(Ts...)()` mixin(`import `~moduleName!(T)~`;`); mixin(`alias X = T.`~name~`;`); super.Reflect!(X); I realize X

Re: Problems instantiating template class

2019-04-06 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 6 April 2019 at 17:30:45 UTC, Mek101 wrote: I'm rewriting from C# a small library of mine to practice with D. I have a class: class WeightedRandom(T, W = float) if(isNumeric!W) { // Fields private W[T] _pairs; // The total sum of all the weights;

Re: template with enum parameter doesn't compile

2019-04-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 5 April 2019 at 14:47:42 UTC, Sjoerd Nijboer wrote: So the following code doesn't compile for some reason, and I can't figure out why. enum MyEnum { A, B, C } class MyClass(MyEnum myEnum) { /*...*/ } int main() { MyClass!MyEnum.A a; } The error: Error: template instan

Re: Request some GtkD Assistance

2019-03-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 27 March 2019 at 06:55:53 UTC, Andrew Edwards wrote: Good day all, I've installed Gtk+ and GtkD on my MacBookPro which is running macOS Mojave but am having some issues linking to and using it. Any assistance to resolve this is appreciated. Steps taken: 1. Install Gtk+

Re: Why a template with Nullable does not compile?

2019-03-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 12 March 2019 at 05:14:21 UTC, Victor Porton wrote: Why does this not compile? import std.typecons; template FieldInfo(T, Nullable!T default_) { } /usr/lib/ldc/x86_64-linux-gnu/include/d/std/typecons.d(2570,17): Error: `alias T = T;` cannot alias itself, use a qualified name to cr

Re: Phobos in BetterC

2019-03-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 9 March 2019 at 12:42:34 UTC, Sebastiaan Koppe wrote: There might also be the option to use @nogc exceptions (dip 1008), but I am not sure. That won't work as the implementation on DIP1008 cheats the type system but doesn't actually work, i.e. the exceptions are still CG allocate

Re: Phobos in BetterC

2019-03-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 8 March 2019 at 09:24:25 UTC, Vasyl Teliman wrote: I've tried to use Mallocator in BetterC but it seems it's not available there: https://run.dlang.io/is/pp3HDq This produces a linker error. I'm wondering why Mallocator is not available in this mode (it would be intuitive to assum

Re: dcompute - Error: unrecognized `pragma(LDC_intrinsic)

2019-02-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 28 February 2019 at 09:58:35 UTC, Michelle Long wrote: I've included it in Visual D as di and it seems not to add it to the include line... Is it in any way possible that it being an di file would allow that? Seems that it is an LDC issue though but LDC has some usage of it I bel

Re: how to pass a malloc'd C string over to be managed by the GC

2019-02-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 28 February 2019 at 03:33:25 UTC, Sam Johnson wrote: ``` string snappyCompress(const string plaintext) { import deimos.snappy.snappy : snappy_compress, snappy_max_compressed_length, SNAPPY_OK; import core.stdc.stdlib : malloc, free; import std.string : fromStringz,

Re: dcompute - Error: unrecognized `pragma(LDC_intrinsic)

2019-02-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 27 February 2019 at 22:56:14 UTC, Michelle Long wrote: Trying to get dcompute to work... after a bunch of issues dealing with all the crap this is what I can't get past: Error: unrecognized `pragma(LDC_intrinsic) This is actually from the ldc.intrinsics file, which I had to rena

Re: Template recursion exceeded

2019-02-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 27 February 2019 at 05:45:19 UTC, Michelle Long wrote: Basically void foo(int k = 20)() { static if (k <= 0 || k >= 100) return; foo!(k-1)(); } Error Error: template instance `foo!-280` recursive expansion Yep, that return is a dynamic return, not a stat

Re: How to break from parallel foreach?

2019-02-26 Thread Jordan Wilson via Digitalmars-d-learn
On Tuesday, 26 February 2019 at 19:58:24 UTC, Andrey wrote: Hello, How to break from parallel foreach? More general question - how to control such loop? A basic way would be to use a flag: shared stopWork=false; foreach (wordBag; wordBags.parallel) { if (!stopWork) { // do work

Re: DMD2 vs LDC2 inliner

2019-02-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 25 February 2019 at 04:08:38 UTC, Jonathan M Davis wrote: One issue that's commonly brought up about dmd's inliner is that it's in the front-end, which apparently is a poor way to do inlining. One side effect of that though would be that unless the ldc folks go to extra effort to dis

Re: DMD2 vs LDC2 inliner

2019-02-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 25 February 2019 at 02:49:36 UTC, James Blachly wrote: Any ideas why DMD2 cannot inline this, but LDC2 has no problem doing so -- or suggestions for what I can do to make DMD2 inline it? Alternatively, I could version(DigitalMars) and version(LDC), but AFAICT this requires me to du

Re: Compile Time Fun Time

2019-02-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 25 February 2019 at 06:51:20 UTC, Yevano wrote: I am writing a domain specific language of sorts in D for the lambda calculus. One of my requirements is that I should be able to generate expressions like this: new Abstraction(v1, M) like this: L!(x => M) It is common to want to w

Re: How can I walk the list in a RegexMatch backwards?

2019-02-03 Thread Jordan Wilson via Digitalmars-d-learn
On Sunday, 3 February 2019 at 18:07:13 UTC, Chris Bare wrote: auto matches = matchAll(str, searchRegex); foreach (m; matches) // this walks the list forward I tried: foreach_reverse (m; matches) foreach (m; reverse (matches)) foreach (m; retro (matches)) and they all failed to compile. I also

Re: Can LDC compile to supported legacy LLVM versions?

2019-01-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 28 January 2019 at 11:37:56 UTC, Dukc wrote: I have recenty updated my LDC to the most recent version (1.14). The problem is that it compiles to LLVM code version 7.0.1, but I need it to compile to LLVM 6.x.x or LLVM 5.x.x. The last release note said that LLVM versions from 3.someth

Re: How to use core.atomic.cas with (function) pointers?

2019-01-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 22 January 2019 at 14:13:23 UTC, Johan Engelen wrote: The following code compiles: ``` alias T = shared(int)*; shared T a; shared T b; shared T c; void foo() { import core.atomic: cas; cas(&a, b, c); } ``` The type of T has to be a pointer to a shared int (you get a templa

Re: Deprecation: foreach: loop index implicitly converted from size_t to int

2019-01-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 18 January 2019 at 12:27:17 UTC, Michael wrote: Hello all, I am getting this deprecation warning when compiling using DMD64 D Compiler v2.084.0 on Linux. I'm a little unsure what the problem is, however, because the code producing these warnings tends to be of the form: foreach

Re: Understanding SIGSEGV issues

2019-01-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 9 January 2019 at 16:48:47 UTC, Russel Winder wrote: It really is totally weird. My new Rust binding to libdvbv5 and associated version of the same application works fine. So libdvbv5 itself is not the cuprit. This has to mean it is something about the D compilers that has changed

Re: Understanding SIGSEGV issues

2019-01-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 8 January 2019 at 10:23:30 UTC, Russel Winder wrote: Actually that is not a worry since the TransmitterData instance is only needed to call the scan function which creates a ChannelsData instance that holds no references to the TransmitterData instance. It turns out that whilst th

Re: Co-developing application and library

2019-01-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 5 January 2019 at 13:01:24 UTC, Russel Winder wrote: Dub seems to have the inbuilt assumption that libraries are dependencies that do not change except via a formal release when you developing an application. Clearly there is the workflow where you want to amend the library but not

Re: Understanding SIGSEGV issues

2019-01-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 5 January 2019 at 12:14:15 UTC, Russel Winder wrote: Indeed. I should do that to see if I can reproduce the problem to submit a proper bug report. File_Ptr is wrapping a dvb_file * from libdvbv5 to try and make things a bit for D and to ensure RAII. libdvbv5 is a C API with class

Re: Understanding SIGSEGV issues

2019-01-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 5 January 2019 at 10:52:48 UTC, Russel Winder wrote: I found the problem and then two minutes later read your email and bingo we have found the problem. Well done. Previously I had used File_Ptr* and on this occasion I was using File_Ptr and there was no copy constructor because

Re: Understanding SIGSEGV issues

2019-01-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 5 January 2019 at 07:34:17 UTC, Russel Winder wrote: TransmitterData has a destructor defined but with no code in it. This used to work fine – but I cannot be certain which version of LDC that was. The problem does seem to be in the construction of the TransmitterData object beca

  1   2   3   4   5   6   7   8   >