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

2022-05-12 Thread jmh530 via Digitalmars-d-learn
On Thursday, 12 May 2022 at 15:32:24 UTC, Adam D Ruppe wrote: On Thursday, 12 May 2022 at 15:18:34 UTC, jmh530 wrote: What's the difference between a Type and Type Identifier? The is expression roughly follows variable declaration style. You write int a; to declare a new symbol named `a`

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

2022-05-12 Thread jmh530 via Digitalmars-d-learn
On Thursday, 12 May 2022 at 12:13:32 UTC, Basile B. wrote: [snip] ``` is ( Type : TypeSpecialization , TemplateParameterList ) is ( Type == TypeSpecialization , TemplateParameterList ) is ( Type Identifier : TypeSpecialization , TemplateParameterList ) is ( Type Identifier == TypeSpecialization

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

2022-05-11 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 11 May 2022 at 09:06:52 UTC, bauss wrote: On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote: What are you stuck at? What was the most difficult features to understand? etc. To make it more meaningful, what is your experience with other languages? Ali dip1000

Re: Including C sources in a DUB project

2022-05-10 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 20:50:12 UTC, Alexander Zhirov wrote: On Tuesday, 10 May 2022 at 19:13:21 UTC, Dennis wrote: It has an example directory: https://github.com/dlang/dub/tree/master/examples And if there are two compilers in the system - `dmd` and `ldc`, which compiler chooses

Re: Including C sources in a DUB project

2022-05-10 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 10 May 2022 at 19:13:21 UTC, Dennis wrote: [snip] It has an example directory: https://github.com/dlang/dub/tree/master/examples If your configuration is missing, you could make a Pull Request to add it. So it does. Thanks. We might also link to that on the dub.pm website.

Re: Including C sources in a DUB project

2022-05-10 Thread jmh530 via Digitalmars-d-learn
On Monday, 9 May 2022 at 09:17:06 UTC, Alexander Zhirov wrote: [snip] It would be nice if dub included a directory of example configurations for common issues like this.

Re: Compile delegate with enum into proper function?

2022-05-08 Thread jmh530 via Digitalmars-d-learn
On Sunday, 8 May 2022 at 03:58:06 UTC, Tejas wrote: [snip] If there is only one possible value for the overload, is there an issue with using default arguments? [snip] Default arguments are intended to be resolved at runtime. That is, if you compile a function with two parameters and one

Re: Compile delegate with enum into proper function?

2022-05-07 Thread jmh530 via Digitalmars-d-learn
On Saturday, 7 May 2022 at 23:30:37 UTC, Paul Backus wrote: [snip] Worth noting that you *can* write ```d alias foo = partial!(foo, a); ``` ...which will add the partially-applied version to `foo`'s overload set. You sure about that? Below fails to compile on godbolt with ldc 1.27.1 [1].

Re: Compile delegate with enum into proper function?

2022-05-07 Thread jmh530 via Digitalmars-d-learn
On Saturday, 7 May 2022 at 18:46:03 UTC, Paul Backus wrote: On Saturday, 7 May 2022 at 18:36:40 UTC, jmh530 wrote: In the code below, there is a two parameter function `foo` and an override of it with only one parameter. In the override case, I force the second one to be 1, but ideally there

Compile delegate with enum into proper function?

2022-05-07 Thread jmh530 via Digitalmars-d-learn
In the code below, there is a two parameter function `foo` and an override of it with only one parameter. In the override case, I force the second one to be 1, but ideally there should be a way to specify it at compile-time. It would be kind of nice to be able to do it with an enum and a

Re: DMD failed with exit code -1073741819

2022-05-03 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 3 May 2022 at 19:03:56 UTC, Dennis wrote: On Tuesday, 3 May 2022 at 18:22:49 UTC, jmh530 wrote: Does anyone have any idea what causes these types of errors? Sounds like a stack overflow, maybe your code has a complex/recursive part that makes DMD's call stack very deep. Thanks.

DMD failed with exit code -1073741819

2022-05-03 Thread jmh530 via Digitalmars-d-learn
I made some changes to some code I'm working on and now there are some lines that are giving me funky DMD error codes (I can tell it is some lines because I comment them out and the errors go away). So for instance, one line I have a static assert that gives an error code -1073741819, but if I

Re: Is there a way to not escape slashes when parsing JSON?

2022-02-21 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 22 February 2022 at 00:36:38 UTC, bachmeier wrote: [snip] Yes. std.random is another. I gave up out on the current one. Luckily I already had external libraries for that before I started using D. Have you tried mir.random?

Re: Strange behavior of iota

2022-02-16 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 16 February 2022 at 19:35:00 UTC, jmh530 wrote: [snip] Step 1: In the integral overloads, use allSatisfy!(isSigned, B, E) || allSatisfy!(isUnsigned, T, U) for the current behavior Step 2: When !(allSatisfy!(isSigned, B, E) || allSatisfy!(isUnsigned, T, U)), then convert to

Re: Strange behavior of iota

2022-02-16 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 16 February 2022 at 15:55:55 UTC, bachmeier wrote: On Wednesday, 16 February 2022 at 15:21:11 UTC, jmh530 wrote: On Tuesday, 15 February 2022 at 22:24:53 UTC, bachmeier wrote: [snip] After looking at the documentation and seeing CommonType!(int, uint) is uint, I have to say

Re: Strange behavior of iota

2022-02-16 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 15 February 2022 at 22:24:53 UTC, bachmeier wrote: [snip] After looking at the documentation and seeing CommonType!(int, uint) is uint, I have to say that iota's behavior doesn't make much sense. What do you propose as an alternative? What about the narrowest type that fits

Re: Jupyter notebook with Dlang

2021-11-16 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 16 November 2021 at 14:40:01 UTC, Imperatorn wrote: https://forum.dlang.org/post/pvwbeqzvktovnhoag...@forum.dlang.org On Wednesday, 29 April 2020 at 15:49:05 UTC, Jan Hönig wrote: [snip] I would also like to know this! I would also be interested.

Re: alias this - am I using it wrong?

2021-08-25 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 25 August 2021 at 12:23:06 UTC, Adam D Ruppe wrote: [snip] That's a lot about alias this that I didn't know. Thanks.

Re: How to get element type of a slice?

2021-08-18 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 17 August 2021 at 14:40:20 UTC, Ferhat Kurtulmuş wrote: [snip] Very informative, thanks. My code is lying here[1]. I want my struct to accept 2d static arrays, random access ranges, and "std.container.Array". I could achieve it with its present form, and I will probably slightly

Re: equivalent of std.functional.partial for templates?

2021-08-11 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 14:08:59 UTC, Paul Backus wrote: [snip] Should have read further--this does not work with template functions due to [issue 1807.][1] My mistake. [1]: https://issues.dlang.org/show_bug.cgi?id=1807 Looks like that strengthens the case for moving forward with

Re: Integer programming in D?

2021-07-19 Thread jmh530 via Digitalmars-d-learn
On Monday, 19 July 2021 at 12:39:41 UTC, Arredondo wrote: Is there an integer linear programming/discrete optimization library for D? an equivalent to the JuMP library for Julia for instance. Doesn't have to be too big, I really only need to solve a few smallish binary linear systems, but

Re: assert(false) and GC

2021-07-08 Thread jmh530 via Digitalmars-d-learn
On Thursday, 8 July 2021 at 18:11:50 UTC, DLearner wrote: Hi Please confirm that: ` assert(false, __FUNCTION__ ~ "This is an error message"); ` Will _not_ trigger GC issues, as the text is entirely known at compile time. Best regards Consider below. Only z will generate an error. This

Re: float price; if (price == float.nan) { // initialized } else { // uninitialized } ... valid ?

2021-06-30 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 30 June 2021 at 04:17:19 UTC, someone wrote: On Wednesday, 30 June 2021 at 03:55:05 UTC, Vladimir Panteleev wrote: If you want to give any type a "null" value, you could use [`std.typecons.Nullable`](https://dlang.org/library/std/typecons/nullable.html). At LEAST for some

Re: Financial Library

2021-06-13 Thread jmh530 via Digitalmars-d-learn
On Sunday, 13 June 2021 at 22:32:16 UTC, Bastiaan Veelo wrote: On Sunday, 13 June 2021 at 12:46:29 UTC, Financial Wiz wrote: What are some of the best Financial Libraries for D? I would like to be able to aggregate as much accurate information as possible. Thanks. I am not into financials,

Re: dual-context deprecation

2021-05-17 Thread jmh530 via Digitalmars-d-learn
On Monday, 17 May 2021 at 14:35:51 UTC, Steven Schveighoffer wrote: [snip] The feature is deprecated in its current form. The issue as I understand it (i.e. very little) is that compilers other than DMD could not use this same way to implement dual contexts, and so they could not have the

Re: dual-context deprecation

2021-05-17 Thread jmh530 via Digitalmars-d-learn
On Monday, 17 May 2021 at 13:51:32 UTC, Paul Backus wrote: [snip] See this issue for context: https://issues.dlang.org/show_bug.cgi?id=5710 Thanks. Lots of details there that I don't follow all of. I mentioned in the deprecation PR [1] that it was not listed in the list of deprecated

dual-context deprecation

2021-05-17 Thread jmh530 via Digitalmars-d-learn
The code below (simplified from my actual problem) generates a warning that member function b "requires a dual-context, which is deprecated". However when I look at the list of deprecated features [1], I'm not seeing which one this is referring to. Is it a valid deprecation? I could only

Re: Since dmd 2.096.0: import `x.t` is used as a type

2021-05-03 Thread jmh530 via Digitalmars-d-learn
On Sunday, 2 May 2021 at 18:36:25 UTC, Basile B. wrote: [snip] BTW during the PR review the problem you encounter [was anticipated](https://github.com/dlang/dmd/pull/12178#issuecomment-773886263) si I guess you're stuck with [the author

Re: mir - Help on how to transform multidimentional arrays.

2021-04-29 Thread jmh530 via Digitalmars-d-learn
On Thursday, 29 April 2021 at 15:56:48 UTC, jmh530 wrote: What you're basically asking for the first one is to convert for row major to column major. There doesn't seem to be a specific function for that, but you can piece it together. The second one is just applying allReversed to the

Re: mir - Help on how to transform multidimentional arrays.

2021-04-29 Thread jmh530 via Digitalmars-d-learn
On Thursday, 29 April 2021 at 15:26:15 UTC, Newbie wrote: [snip] Forgot to add the the first array was created using the following code. auto base = iota(2, 5, 3); What you're basically asking for the first one is to convert for row major to column major. There doesn't seem to be a

Re: DIP1000 and immutable

2021-04-27 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 27 April 2021 at 14:44:48 UTC, Adam D. Ruppe wrote: On Tuesday, 27 April 2021 at 14:28:12 UTC, jmh530 wrote: However, should it ever matter if you escape an immutable? Your example is a pretty clear case of use-after-free if gloin actually did escape the reference and kept it

DIP1000 and immutable

2021-04-27 Thread jmh530 via Digitalmars-d-learn
What is the motivation for DIP1000 also applying to immutable? For instance, in the code (compiled with -dip1000), adapted from the spec [1], you get the same errors with immutable function parameters as you would with mutable ones. However, should it ever matter if you escape an immutable?

Re: How to delete dynamic array ?

2021-03-17 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 16:32:28 UTC, Ali Çehreli wrote: On 3/17/21 3:54 AM, jmh530 wrote: On Tuesday, 16 March 2021 at 23:49:00 UTC, H. S. Teoh wrote: double[] data; data = cast(double[]) malloc(n * double.sizeof)[0 .. n]; This is one of those things that is not explained

Re: How to delete dynamic array ?

2021-03-17 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 16:20:06 UTC, Steven Schveighoffer wrote: [snip] I've had online battles about this terminology, and people asked me to change my array article to disavow this distinction, but I'm not going to change it. It's so much easier to understand. -Steve I'll be on

Re: How to delete dynamic array ?

2021-03-17 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 14:30:26 UTC, Guillaume Piolat wrote: On Wednesday, 17 March 2021 at 10:54:10 UTC, jmh530 wrote: This is one of those things that is not explained well enough. Yes. I made this article to clear up that point:

Re: How to delete dynamic array ?

2021-03-17 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 16 March 2021 at 23:49:00 UTC, H. S. Teoh wrote: [snip] Note that T[] is just a slice, not the dynamic array itself. The dynamic array is allocated and managed by the GC when you append stuff to it, or when you create a new array with `new` or an array literal. None of the

Re: Why am I getting a dividing by zero error message

2021-01-28 Thread jmh530 via Digitalmars-d-learn
On Thursday, 28 January 2021 at 18:37:37 UTC, Ruby The Roobster wrote: Here is the output/input of the program: Type in data for an egg: Width: 3 Hight: 2 [...] It might help to separate break this out into smaller functions. May make it easier to follow what is happening.

Re: Why many programmers don't like GC?

2021-01-15 Thread jmh530 via Digitalmars-d-learn
On Friday, 15 January 2021 at 16:22:59 UTC, IGotD- wrote: [snip] Are we talking about the same things here? You mentioned DMD but I was talking about programs compiled with DMD (or GDC, LDC), not the nature of the DMD compiler in particular. Bump the pointer and never return any memory

Re: Why many programmers don't like GC?

2021-01-15 Thread jmh530 via Digitalmars-d-learn
On Friday, 15 January 2021 at 15:36:37 UTC, Ola Fosheim Grøstad wrote: On Friday, 15 January 2021 at 15:20:05 UTC, jmh530 wrote: Hypothetically, would it be possible for users to supply their own garbage collector that uses write barriers? Yes. You could translate Google Chrome's Oilpan to D.

Re: Why many programmers don't like GC?

2021-01-15 Thread jmh530 via Digitalmars-d-learn
On Friday, 15 January 2021 at 14:50:00 UTC, welkam wrote: On Thursday, 14 January 2021 at 18:51:16 UTC, Ola Fosheim Grøstad wrote: One can follow the same kind of reasoning for D. It makes no sense for people who want to stay high level and do batch programming. Which is why this disconnect

Re: C++ or D?

2020-12-30 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 30 December 2020 at 19:51:07 UTC, Ola Fosheim Grøstad wrote: [snip] Sort of, in C++ it would be something like this template class OuterName> void myfunction(OuterName x){ stuff(); } [snip] You mean like this struct Foo(T) { T x; } void foo(T : Foo!V, V)(T x) {

Re: Running unit tests from DUB single file packages

2020-12-22 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 22 December 2020 at 15:06:09 UTC, drug wrote: [snip] But what do you mean exactly by "work with dependency"? As I understand, `dub test` does not run unit tests in dependencies and single file packages work with dependencies in general. Do you mean something else? I'm finishing

Re: Running unit tests from DUB single file packages

2020-12-21 Thread jmh530 via Digitalmars-d-learn
On Monday, 21 December 2020 at 11:31:49 UTC, drug wrote: [snip] Unfortunately I'm very busy. But I check it again and it turns out that the fix does not resolve the problem completely. This PR just remove the single file from testing so currently dub does not run unit tests in the single file

Re: Running unit tests from DUB single file packages

2020-12-20 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 2 December 2020 at 12:51:11 UTC, drug wrote: [snip] Thanks! Let's see if it gets merged or if a slightly more involved solution is needed. Remake it - https://github.com/dlang/dub/pull/2052 This has more chances to be merged Looks like this got merged and will be part of

Re: Running unit tests from DUB single file packages

2020-12-01 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 14:15:22 UTC, Johannes Loher wrote: [snip] The point of using DUB (and the single file package format) is easy access to libraries from the DUB registry. If I didn't want to use a dependency, I would not be using DUB at all. That said, leaving out the

Re: Running unit tests from DUB single file packages

2020-12-01 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 11:40:38 UTC, Johannes Loher wrote: [snip] Any hints on how to execute unit tests from single file DUB packages? Is it even possible at the moment? Thanks in advance for any help! [1] https://adventofcode.com/ Have you tried it without the imports?

Re: Running unit tests from DUB single file packages

2020-12-01 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 1 December 2020 at 13:52:35 UTC, jmh530 wrote: On Tuesday, 1 December 2020 at 11:40:38 UTC, Johannes Loher wrote: [snip] Any hints on how to execute unit tests from single file DUB packages? Is it even possible at the moment? Thanks in advance for any help! [1]

Re: lambdas with types

2020-11-20 Thread jmh530 via Digitalmars-d-learn
On Friday, 20 November 2020 at 14:57:42 UTC, H. S. Teoh wrote: On Fri, Nov 20, 2020 at 02:47:52PM +, Paul Backus via Digitalmars-d-learn wrote: [...] In this specific case, you could also make `foo` a type-safe variadic function [1], which would eliminate the need for `allSatisfy`:

lambdas with types

2020-11-20 Thread jmh530 via Digitalmars-d-learn
Doing something like below fails because I don't seem to be able to make a templated lambda that just takes types. Is the only way to do something similar to create a separate function to handle the condition, or is there some other way to do something with similar flexibility? import

Re: enum and const or immutable ‘variable’ whose value is known at compile time

2020-09-17 Thread jmh530 via Digitalmars-d-learn
On Thursday, 17 September 2020 at 10:53:48 UTC, Mike Parker wrote: [snip] I can attest that in the 17 years I've been hanging around here, the fact that enum is used to indicate a manifest constant has not been a serious source of WTF posts. So I think "pretty much everyone coming to D" have

Re: How to use libmir --> mir-algorithm, numir, mir-random?

2020-09-09 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 9 September 2020 at 15:30:33 UTC, Shaleen Chhabra wrote: [snip] Hi, I updated my dmd version to dmd-2.093.1 Now it throws a conflict error between 1. function mir.ndslice.topology.iota!(long, 1LU).iota at mir/ndslice/topology.d(630) conflicts with function

Re: How does D's templated functions implementation differ from generics in C#/Java?

2020-08-07 Thread jmh530 via Digitalmars-d-learn
On Friday, 7 August 2020 at 21:39:44 UTC, H. S. Teoh wrote: [snip] "Furthermore, it can dispatch to a type-erased implementation ala Java -- at your choice;" This is interesting. Would you just cast to Object?

Re: Template constraint on alias template parameter.

2020-08-06 Thread jmh530 via Digitalmars-d-learn
On Thursday, 6 August 2020 at 18:09:50 UTC, ag0aep6g wrote: [snip] `is(...)` only works on types. You're looking for `__traits(isSame, T, Foo)`. For `is(T!U == Foo!U, U)` to work, the compiler would have to guess U. If the first guess doesn't work, it would have to guess again, and again,

Re: Template constraint on alias template parameter.

2020-08-06 Thread jmh530 via Digitalmars-d-learn
On Thursday, 6 August 2020 at 16:01:35 UTC, jmh530 wrote: [snip] It seems as if the T is properly Foo(T) and can only be instantiated with actual types. Something like below works and might work for me. template test(alias T) if (__traits(isTemplate, T)) { void test(U)(U x)

Template constraint on alias template parameter.

2020-08-06 Thread jmh530 via Digitalmars-d-learn
The code below compiles, but I want to put an additional constraint on the `test` function is only called with a Foo struct. I tried things like is(T == Foo) and is(T : Foo), but those don't work. However, something like is(T!int : Foo!int) works, but is(T!U == Foo!U, U) doesn't. Any idea

Re: 2-D array initialization

2020-08-02 Thread jmh530 via Digitalmars-d-learn
On Sunday, 2 August 2020 at 19:19:51 UTC, Andy Balba wrote: I'm not a gitHub fan, but I like the mir functions; and it looks like I have to download mir before using it. mir has quite a few .d files..Is there a quick way to download it ? dub [1] is now packaged with dmd, which is the

Re: 2-D array initialization

2020-07-31 Thread jmh530 via Digitalmars-d-learn
On Friday, 31 July 2020 at 23:42:45 UTC, Andy Balba wrote: ubyte[3][4] c ; How does one initialize c in D ? none of the statements below works c = cast(ubyte) [ [5, 5, 5], [15, 15,15], [25, 25,25], [35, 35,35] ]; c[0] = ubyte[3] [5, 5, 5] ; c[1] = ubyte[3] [15, 15,15] ; c[2] =

Re: D Mir: standard deviation speed

2020-07-15 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 15 July 2020 at 11:41:35 UTC, 9il wrote: [snip] Ah, no, my bad! You write @fmamath, I have read it as @fastmath. @fmamath is OK here. I've mixed up @fastmath and @fmamath as well. No worries.

Re: D Mir: standard deviation speed

2020-07-15 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 15 July 2020 at 11:26:19 UTC, 9il wrote: [snip] @fmamath private double sd(T)(Slice!(T*, 1) flatMatrix) @fastmath violates all summation algorithms except `"fast"`. The same bug is in the original author's post. I hadn't realized that @fmamath was the problem, rather than

Re: D Mir: standard deviation speed

2020-07-15 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 15 July 2020 at 05:57:56 UTC, tastyminerals wrote: [snip] Here is a (WIP) project as of now. Line 160 in https://github.com/tastyminerals/mir_benchmarks_2/blob/master/source/basic_ops.d std of [60, 60] matrix 0.0389492 (> 0.001727) std of [300, 300] matrix 1.03592 (> 0.043452)

Re: D Mir: standard deviation speed

2020-07-14 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 14 July 2020 at 19:04:45 UTC, tastyminerals wrote: I am trying to implement standard deviation calculation in Mir for benchmark purposes. I have two implementations. One is the straightforward std = sqrt(mean(abs(x - x.mean())**2)) and the other follows Welford's algorithm for

Re: Upcoming refraction module in bolts [was: DUB project type support for Emacs Projectile]

2020-06-15 Thread jmh530 via Digitalmars-d-learn
On Monday, 15 June 2020 at 17:32:26 UTC, Jean-Louis Leroy wrote: [snip] Thanks, cool.

Re: DUB project type support for Emacs Projectile

2020-06-15 Thread jmh530 via Digitalmars-d-learn
On Monday, 15 June 2020 at 13:17:11 UTC, Jean-Louis Leroy wrote: [snip] Nah, I saw it. Well. My take on it has been ready for months but I had to wait for my employer's permission to publish it. They are very open-source friendly, and as a consequence there is a glut of requests for

Re: DUB project type support for Emacs Projectile

2020-06-14 Thread jmh530 via Digitalmars-d-learn
On Sunday, 14 June 2020 at 17:19:05 UTC, Jean-Louis Leroy wrote: [snip] In case you missed it, I thought you would find this interesting https://forum.dlang.org/thread/dytpsnkqnmgzniiwk...@forum.dlang.org

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

2020-06-10 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 10 June 2020 at 00:53:30 UTC, Seb wrote: [snip] Anyhow, I would be highly in favor of DMD doing this. It's one of those many things that I have on my list for D3 or a D fork. Chapel supports zippered iteration [1]. From the discussion here, it sounds very much like the

Re: Mixin and imports

2020-06-08 Thread jmh530 via Digitalmars-d-learn
On Monday, 8 June 2020 at 14:27:26 UTC, data pulverizer wrote: [snip] Out of curiosity what does the "." in front of `foo` mean? I've seen that in some D code on the compiler in GitHub and have no idea what it does. I tried Googling it to no avail. It doesn't have anything to do with UFCS

Re: Mixin and imports

2020-06-08 Thread jmh530 via Digitalmars-d-learn
On Monday, 8 June 2020 at 12:20:46 UTC, Adam D. Ruppe wrote: [snip] Why do you even want foo!"fabs"? Usually when I see people having this problem it is actually a misunderstanding of what is possible with the foo!fabs style - which is better in basically every way and can be used in most

Re: Mixin and imports

2020-06-08 Thread jmh530 via Digitalmars-d-learn
On Monday, 8 June 2020 at 10:28:39 UTC, Paul Backus wrote: [snip] Thanks for that suggestion. That works for me. Unfortunately, it's probably not worth the extra effort though, versus doing foo!fabs in my case.

Re: Mixin and imports

2020-06-08 Thread jmh530 via Digitalmars-d-learn
On Monday, 8 June 2020 at 04:13:08 UTC, Mike Parker wrote: [snip] The problem isn't the mixin. It's the template. Templates take the scope of their declaration, not their instantiation. So the mixin is getting the template's scope. Anyway, this appears to work: `double z =

Mixin and imports

2020-06-07 Thread jmh530 via Digitalmars-d-learn
In the code below, foo!fabs compiles without issue, but foo!"fabs" does not because the import is not available in the string mixin. If I move the import to the top of the module, then it works. However, then if I move foo to another module, then it will no longer compile since it is in

Re: Mir Slice Column or Row Major

2020-05-27 Thread jmh530 via Digitalmars-d-learn
On Thursday, 28 May 2020 at 00:51:50 UTC, 9il wrote: snip Actually it is a question of notation. For example, mir-lapack uses ndslice as column-major Fortran arrays. This may cause some headaches because the data needs to be transposed in mind. We can think about ndslice as about column-major

Re: Mir Slice Column or Row Major

2020-05-27 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 27 May 2020 at 16:07:58 UTC, welkam wrote: On Wednesday, 27 May 2020 at 01:31:23 UTC, data pulverizer wrote: column major Cute puppies die when people access their arrays in column major. Not always true...many languages support column-major order (Fortran, most obviously).

Re: [GTK-D] dub run leads to lld-link: error: could not open libcmt.lib: no such file or directory

2020-05-26 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 15:18:42 UTC, jmh530 wrote: On Tuesday, 26 May 2020 at 15:16:25 UTC, jmh530 wrote: [snip] Another short-term fix might be to try compiling with the -m32 dflag (need to put in your dub.sdl/json). Sorry, easier is dub test --arch=x86 You may also have to make

Re: [GTK-D] dub run leads to lld-link: error: could not open libcmt.lib: no such file or directory

2020-05-26 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 13 May 2020 at 15:26:48 UTC, BoQsc wrote: [snip] Linking... lld-link: error: could not open libcmt.lib: no such file or directory lld-link: error: could not open OLDNAMES.lib: no such file or directory Error: linker exited with status 1 C:\D\dmd2\windows\bin\dmd.exe failed with

Re: [GTK-D] dub run leads to lld-link: error: could not open libcmt.lib: no such file or directory

2020-05-26 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 26 May 2020 at 15:16:25 UTC, jmh530 wrote: [snip] Another short-term fix might be to try compiling with the -m32 dflag (need to put in your dub.sdl/json). Sorry, easier is dub test --arch=x86

Re: Static assert triggered in struct constructor that shouldn't be called

2020-05-24 Thread jmh530 via Digitalmars-d-learn
On Sunday, 24 May 2020 at 21:43:34 UTC, H. S. Teoh wrote: On Sun, May 24, 2020 at 09:34:53PM +, jmh530 via Digitalmars-d-learn wrote: The following code results in the static assert in the constructor being triggered, even though I would have thought no constructor would have been called

Static assert triggered in struct constructor that shouldn't be called

2020-05-24 Thread jmh530 via Digitalmars-d-learn
The following code results in the static assert in the constructor being triggered, even though I would have thought no constructor would have been called. I know that there is an easy fix for this (move the static if outside the constructor), but it still seems like it doesn't make sense.

Re: Mir Slice.shape is not consistent with the actual array shape

2020-05-24 Thread jmh530 via Digitalmars-d-learn
On Sunday, 24 May 2020 at 14:21:26 UTC, Pavel Shkadzko wrote: [snip] Sorry for the typo. It should be "auto arrSlice = a.sliced;" Try using fuse /+dub.sdl: dependency "mir-algorithm" version="*" +/ import std.stdio; import std.conv; import std.array: array; import std.range: chunks; import

Re: CTFE and Static If Question

2020-05-07 Thread jmh530 via Digitalmars-d-learn
On Thursday, 7 May 2020 at 17:59:30 UTC, Paul Backus wrote: On Thursday, 7 May 2020 at 15:00:18 UTC, jmh530 wrote: Does foo!y0(rt) generate the same code as foo(rt, y0)? How is the code generated by foo(rt, x0) different from foo(rt,y0)? You can look at the generated code using the Compiler

Re: CTFE and Static If Question

2020-05-07 Thread jmh530 via Digitalmars-d-learn
On Thursday, 7 May 2020 at 15:34:21 UTC, ag0aep6g wrote: [snip] The `static if` is guaranteed to be evaluated during compilation. That means, `foo!y0` effectively becomes this: auto foo(int rt) { return rt + 1; } There is no such guarantee for `foo(rt, y0)`. It doesn't matter that y0

Re: CTFE and Static If Question

2020-05-07 Thread jmh530 via Digitalmars-d-learn
On Thursday, 7 May 2020 at 15:29:01 UTC, H. S. Teoh wrote: [snip] You explained things very well, thanks.

CTFE and Static If Question

2020-05-07 Thread jmh530 via Digitalmars-d-learn
I am curious how ctfe and static ifs interact. In particular, if an enum bool passed as a template parameter or run-time one will turn an if statement into something like a static if statement (perhaps after the compiler optimizes other code away). In the code below, I am a function that takes

Re: Python eval() equivalent in Dlang working in Runtime?

2020-05-01 Thread jmh530 via Digitalmars-d-learn
On Friday, 1 May 2020 at 15:42:54 UTC, Baby Beaker wrote: There is a Python eval() equivalent in Dlang working in Runtime? You might find arsd's script.d interesting [1], but it's more like a blend between D and javascript.

Re: Implicit Function Template Instantiation (IFTI) Question

2020-04-27 Thread jmh530 via Digitalmars-d-learn
On Monday, 27 April 2020 at 17:40:06 UTC, Steven Schveighoffer wrote: [snip] Thanks for that. Very detailed. In terms of a use case, we just added a center function to mir [1]. It can take an alias to a function. I wanted to add a check that the arity of the function was 1, but it turned

Implicit Function Template Instantiation (IFTI) Question

2020-04-27 Thread jmh530 via Digitalmars-d-learn
When using a template with multiple functions within it, is it possible to access the underlying functions directly? Not sure I am missing anything, but what works when the functions are named differently from the headline template doesn't work when the functions are named the same. import

Attribute inference within template functions

2020-04-22 Thread jmh530 via Digitalmars-d-learn
I was trying to write a function has different behavior depending on whether it is called from @nogc code or not. However, I am noticing that this does not seem possible because of the timing of attribute inference. If I call getFunctionAttributes within foo below, then it is system but then

Re: Multiplying transposed matrices in mir

2020-04-20 Thread jmh530 via Digitalmars-d-learn
On Monday, 20 April 2020 at 19:06:53 UTC, p.shkadzko wrote: [snip] It is. I was trying to calculate the covariance matrix of some dataset X which would be XX^T. Incorrect. The covariance matrix is calculated with matrix multiplication, not element-wise multiplication. For instance, I often

Re: mir: How to change iterator?

2020-04-20 Thread jmh530 via Digitalmars-d-learn
On Monday, 20 April 2020 at 00:27:40 UTC, 9il wrote: [snip] Using two arguments Iterator1, Iterator2 works without allocation /+dub.sdl: dependency "mir-algorithm" version="~>3.7.28" +/ import mir.ndslice; void foo(Iterator1, Iterator2, SliceKind kind) (Slice!(Iterator1, 1, kind) x,

Re: mir: How to change iterator?

2020-04-19 Thread jmh530 via Digitalmars-d-learn
On Thursday, 16 April 2020 at 20:59:36 UTC, jmh530 wrote: [snip] /+dub.sdl: dependency "mir-algorithm" version="~>3.7.28" +/ import mir.ndslice; void foo(Iterator, SliceKind kind)(Slice!(Iterator, 1, kind) x, Slice!(Iterator, 1, kind) y) { import std.stdio : writeln;

Re: Multiplying transposed matrices in mir

2020-04-19 Thread jmh530 via Digitalmars-d-learn
On Sunday, 19 April 2020 at 20:29:54 UTC, p.shkadzko wrote: [snip] Thanks. I somehow missed the whole point of "a * a.transposed" not working because "a.transposed" is not allocated. a.transposed is just a view of the original matrix. Even when I tried to do a raw for loop I ran into issues

Re: Multiplying transposed matrices in mir

2020-04-19 Thread jmh530 via Digitalmars-d-learn
On Sunday, 19 April 2020 at 19:20:28 UTC, p.shkadzko wrote: [snip] well no, "assumeContiguous" reverts the results of the "transposed" and it's "a * a". I would expect it to stay transposed as NumPy does "assert np.all(np.ascontiguous(a.T) == a.T)". Ah, you're right. I use it in other places

Re: Multiplying transposed matrices in mir

2020-04-19 Thread jmh530 via Digitalmars-d-learn
On Sunday, 19 April 2020 at 17:55:06 UTC, p.shkadzko wrote: snip So, lubeck mtimes is equivalent to NumPy "a.dot(a.transpose())". There are elementwise operation on two matrices of the same size and then there is matrix multiplication. Two different things. You had initially said using an

Re: Multiplying transposed matrices in mir

2020-04-19 Thread jmh530 via Digitalmars-d-learn
On Sunday, 19 April 2020 at 17:07:36 UTC, p.shkadzko wrote: I'd like to calculate XX^T where X is some [m x n] matrix. // create a 3 x 3 matrix Slice!(double*, 2LU) a = [2.1, 1.0, 3.2, 4.5, 2.4, 3.3, 1.5, 0, 2.1].sliced(3, 3); auto b = a * a.transposed; // error Looks like it is not possible

Re: mir: How to change iterator?

2020-04-16 Thread jmh530 via Digitalmars-d-learn
On Thursday, 16 April 2020 at 19:59:57 UTC, Basile B. wrote: [snip] And remove the extra assert() BTW... I don't know why this is accepted. Thanks, I hadn't realized about approxEqual. I think that resolves my near-term issue, I would need to play around with things a little more to be

mir: How to change iterator?

2020-04-14 Thread jmh530 via Digitalmars-d-learn
In the code below, I multiply some slice by 5 and then check whether it equals another slice. This fails for mir's approxEqual because the two are not the same types (yes, I know that isClose in std.math works). I was trying to convert the y variable below to have the same double* iterator as

Re: @safe function with __gshared as default parameter value

2020-04-08 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 8 April 2020 at 19:29:17 UTC, Anonymouse wrote: [snip] It works with `ref int` too. ``` __gshared int gshared = 42; void foo(ref int i = gshared) @safe { ++i; } void main() { assert(gshared == 42); foo(); assert(gshared == 43); } ``` Well that definitely

Re: @safe function with __gshared as default parameter value

2020-04-08 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 8 April 2020 at 18:50:16 UTC, data pulverizer wrote: On Wednesday, 8 April 2020 at 16:53:05 UTC, Anonymouse wrote: ``` import std.stdio; @safe: __gshared int gshared = 42; void foo(int i = gshared) { writeln(i); } void main() { foo(); } ``` This currently works; `foo`

Re: Blog post about multidimensional arrays in D

2020-03-27 Thread jmh530 via Digitalmars-d-learn
On Friday, 27 March 2020 at 10:57:10 UTC, p.shkadzko wrote: I decided to write a small blog post about multidimensional arrays in D on what I learnt so far. It should serve as a brief introduction to Mir slices and how to do basic manipulations with them. It started with a small file with

Re: dub libs from home directory on windows

2020-03-18 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 18 March 2020 at 15:10:52 UTC, Виталий Фадеев wrote: On Wednesday, 18 March 2020 at 13:52:20 UTC, Abby wrote: I cannot build my app, so I was wondering if there is some clever way to solve this without hardcoded path to my profile name. Thank you very much for your help. I

Re: How to sort 2D Slice along 0 axis in mir.ndslice ?

2020-03-11 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 11 March 2020 at 06:12:55 UTC, 9il wrote: [snip] Almost the same, just fixed import for `each` and a bit polished /+dub.sdl: dependency "mir-algorithm" version="~>3.7.18" +/ import mir.ndslice; import mir.ndslice.sorting; import mir.algorithm.iteration: each; void main() {

  1   2   3   4   5   >