Re: What is the difference between enum and shared immutable?

2020-10-28 Thread matheus via Digitalmars-d-learn
On Thursday, 29 October 2020 at 01:26:38 UTC, Mike Parker wrote: enum int[] arr = [1,2,3]; someFunc(arr); This is identical to someFunc([1,2,3]); Manifest constants have no address. They are effectively aliases for their values. Hi Mike, I really didn't know about this. Thanks for the

Re: What is the difference between enum and shared immutable?

2020-10-28 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 29 October 2020 at 00:55:29 UTC, matheus wrote: On Wednesday, 28 October 2020 at 22:07:06 UTC, H. S. Teoh wrote: ... (This is why it's a bad idea to use enum with an array literal, because every time it's referenced you get a new copy of the array.) ... Could you please give an

Re: What is the difference between enum and shared immutable?

2020-10-28 Thread matheus via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 22:07:06 UTC, H. S. Teoh wrote: ... (This is why it's a bad idea to use enum with an array literal, because every time it's referenced you get a new copy of the array.) ... Could you please give an example (Snippet) about this? Matheus.

Re: nested module problem

2020-10-28 Thread mw via Digitalmars-d-learn
IMO, 3rd party libraries should always be in their own package namespace. Leave the top-level for user code! Why should a local module 'util' conflict with any dependency? It should be the library author's job to make sure his code doesn't conflict with the user's! logged:

Re: nested module problem

2020-10-28 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 28, 2020 at 10:52:33PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Wednesday, 28 October 2020 at 22:43:12 UTC, mw wrote: > > I wonder what's the best way to resolve this conflict, i.e my local > > file name with 3rd party library dir name. > > Don't write any module with

Re: nested module problem

2020-10-28 Thread mw via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 22:52:33 UTC, Adam D. Ruppe wrote: On Wednesday, 28 October 2020 at 22:43:12 UTC, mw wrote: I wonder what's the best way to resolve this conflict, i.e my local file name with 3rd party library dir name. Don't write any module with a single name unless you are

Re: nested module problem

2020-10-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 22:43:12 UTC, mw wrote: I wonder what's the best way to resolve this conflict, i.e my local file name with 3rd party library dir name. Don't write any module with a single name unless you are guaranteed to never import it. pyd should have called it like

Re: nested module problem

2020-10-28 Thread mw via Digitalmars-d-learn
I run into a similar issue today: -- I try to use a library `pyd`, and -- my local project has a file called "source/util.d" the dub build error out: /.dub/packages/pyd-0.13.1/pyd/infrastructure/util/typelist.d(1,1): Error: package name 'util' conflicts with usage as a module name in file

Re: What is the difference between enum and shared immutable?

2020-10-28 Thread IGotD- via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 21:54:19 UTC, Jan Hönig wrote: shared immutable x = 1; Is there a point to add shared to an immutable? Aren't immutable implicitly also shared?

Re: What is the difference between enum and shared immutable?

2020-10-28 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 28, 2020 at 09:54:19PM +, Jan Hönig via Digitalmars-d-learn wrote: > Maybe this is a silly question, but I don't understand completely the > difference between an `enum` and a `shared immutable`. > > I could have: > > enum x = 1; > > or > > shared immutable x = 1; > > What is

Re: dub fetching dependencies for wrong configuration(s)

2020-10-28 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 19:34:43 UTC, ikod wrote: To make this transition as painless as possible I'll create new package with major version "2" if you confirm that everything works as expected. I tried cloning requests from git and added it as a dub package, and it seems to work.

What is the difference between enum and shared immutable?

2020-10-28 Thread Jan Hönig via Digitalmars-d-learn
Maybe this is a silly question, but I don't understand completely the difference between an `enum` and a `shared immutable`. I could have: enum x = 1; or shared immutable x = 1; What is the exact difference between those too? My best guess is, that shared immutable gets initialized during

Re: Print int[string] sorted by Value

2020-10-28 Thread Ali Çehreli via Digitalmars-d-learn
On 10/28/20 9:30 AM, Paul wrote: > On Wednesday, 28 October 2020 at 15:40:23 UTC, aberba wrote: >> Have you tries .values() function? dictionary.values.sort() > > Thanks aberba. Yes, that was my first attempt! > > If my terminology is correct that gives me a "range" of sorted VALUES. No, both

Re: dub fetching dependencies for wrong configuration(s)

2020-10-28 Thread ikod via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 22:15:34 UTC, Anonymouse wrote: On Tuesday, 27 October 2020 at 21:15:35 UTC, ikod wrote: On Tuesday, 27 October 2020 at 17:01:23 UTC, Anonymouse wrote: On Sunday, 4 October 2020 at 21:00:49 UTC, ikod wrote: Thanks, Andre! I'll split requests as you suggested

Re: Associative array using std.container.array

2020-10-28 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 28, 2020 at 06:54:01PM +, Vino via Digitalmars-d-learn wrote: > Hi All, > >Is it possible to create an associative array using > std.container.array, if possible can you please provide me an example > nor send me some link which has this information.

Associative array using std.container.array

2020-10-28 Thread Vino via Digitalmars-d-learn
Hi All, Is it possible to create an associative array using std.container.array, if possible can you please provide me an example nor send me some link which has this information. From, Vino.B

Re: synthesising instantiated template parameters and arguments

2020-10-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 05:51:14 UTC, Nicholas Wilson wrote: class A(T,int,args...) {} alias C = A!(int, 0, float); I need `ScopeClass!C` to be template ScopeClass(C) { class Anon(T,int,args...) // name doesn't matter { // implement members with compile time

Re: How can I use class and wasm?

2020-10-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 26 October 2020 at 21:38:39 UTC, Jack wrote: I did consider do something like this but the class would only live in the function's lifetime, right? that wouldn't work if I need to pass the class around Right, you'd have to manage the memory somehow. One possibility is to malloc it

Re: Print int[string] sorted by Value

2020-10-28 Thread Paul via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 15:27:04 UTC, H. S. Teoh wrote: foreach (key; aa.keys.sort!((a,b) => aa[a] < aa[b])) { writeln(key); This solution worked perfectly without modifying any of my other code. I don't fully understand it but can study up

Re: Print int[string] sorted by Value

2020-10-28 Thread Paul via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 15:40:23 UTC, aberba wrote: Have you tries .values() function? dictionary.values.sort() Thanks aberba. Yes, that was my first attempt! If my terminology is correct that gives me a "range" of sorted VALUES. I think I can't "iterate"(foreach) through an array

Re: Print int[string] sorted by Value

2020-10-28 Thread Paul via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 15:25:26 UTC, Paul Backus wrote: auto sorted = dictionary.byPair.array.sort!((a, b) => a.value < b.value) It seems this method produces a ?sorted array of tuples? [..Tuple!(string, "key", uint, "value")("Program", 74), Tuple!(string, "key", uint,

Re: Print int[string] sorted by Value

2020-10-28 Thread aberba via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 15:15:40 UTC, Paul wrote: per the D sample wc2.d size_t[string] dictionary; <-is printed by... . foreach (word1; dictionary.keys.sort) writef etc I want to print the dictionary sorted by value not key. I can write an algorithm but is there a

Re: Print int[string] sorted by Value

2020-10-28 Thread Paul via Digitalmars-d-learn
Thanks Teoh

Re: Print int[string] sorted by Value

2020-10-28 Thread Paul via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 15:25:26 UTC, Paul Backus wrote: On Wednesday, 28 October 2020 at 15:15:40 UTC, Paul wrote: per the D sample wc2.d size_t[string] dictionary; <-is printed by... . foreach (word1; dictionary.keys.sort) writef etc I want to print the dictionary

Re: Print int[string] sorted by Value

2020-10-28 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 15:15:40 UTC, Paul wrote: per the D sample wc2.d size_t[string] dictionary; <-is printed by... . foreach (word1; dictionary.keys.sort) writef etc I want to print the dictionary sorted by value not key. I can write an algorithm but is there a

Re: Print int[string] sorted by Value

2020-10-28 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Oct 28, 2020 at 03:15:40PM +, Paul via Digitalmars-d-learn wrote: > per the D sample wc2.d > size_t[string] dictionary; <-is printed by... > . > foreach (word1; dictionary.keys.sort) writef etc > > I want to print the dictionary sorted by value not key. I can write > an

Print int[string] sorted by Value

2020-10-28 Thread Paul via Digitalmars-d-learn
per the D sample wc2.d size_t[string] dictionary; <-is printed by... . foreach (word1; dictionary.keys.sort) writef etc I want to print the dictionary sorted by value not key. I can write an algorithm but is there a library method(s) I can use to iterate through the array sorted

Re: Getting Qte5 to work

2020-10-28 Thread Marcone via Digitalmars-d-learn
Look this video https://www.youtube.com/watch?v=Es9Qs9_1ipk

Re: How is this an "Access Violation"

2020-10-28 Thread Ruby The Roobster via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 12:33:18 UTC, Ruby The Roobster wrote: On Wednesday, 28 October 2020 at 00:48:36 UTC, Ruby The Roobster wrote: On Tuesday, 27 October 2020 at 02:05:37 UTC, Ruby The Roobster wrote: Following function when called throws an access violation. I think it has to do

Re: How is this an "Access Violation"

2020-10-28 Thread Ruby The Roobster via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 00:48:36 UTC, Ruby The Roobster wrote: On Tuesday, 27 October 2020 at 02:05:37 UTC, Ruby The Roobster wrote: Following function when called throws an access violation. I think it has to do with the assert statements, but I don't know why. [...] Okay. I

Re: Getting Qte5 to work

2020-10-28 Thread Patrick Schluter via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 06:52:35 UTC, evilrat wrote: Just an advice, Qte5 isn't well maintained, the other alternatives such as 'dlangui' also seems abandoned, so basically the only maintained UI library here is gtk-d, but there was recently a nice tutorial series written about it.

Re: Getting Qte5 to work

2020-10-28 Thread Josh Dredge via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 07:56:35 UTC, Mike Parker wrote: On Wednesday, 28 October 2020 at 07:50:27 UTC, Josh Dredge wrote: developers would love to be working with! I will give Gtk a go too - I've never programmed with it, but I used Ubuntu alot back in the day and never really

Re: Getting Qte5 to work

2020-10-28 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 07:50:27 UTC, Josh Dredge wrote: developers would love to be working with! I will give Gtk a go too - I've never programmed with it, but I used Ubuntu alot back in the day and never really liked applications that used it, but maybe its more responsive on

Re: Getting Qte5 to work

2020-10-28 Thread Josh Dredge via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 06:52:35 UTC, evilrat wrote: On Tuesday, 27 October 2020 at 11:46:02 UTC, Josh Dredge wrote: [...] Welcome! If by web development you also have back-end programming then you should be like 50% know how desktop programming works. [...] Fantastic, thank

asdf: filter value and print the next value

2020-10-28 Thread Vino via Digitalmars-d-learn
Hi All, Request your help in the below code, the logic is that fetch the json data(Pool) from apidata1 and use that and search for "pool" in sapidata2 and print the matched(pool) type from apidata2. Code: import datacollector.GetLamaAssignment; import std.stdio: writeln; import asdf:

Re: Foreach output into a multi dimensional associative array.

2020-10-28 Thread Vino via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 08:00:55 UTC, Imperatorn wrote: On Monday, 26 October 2020 at 19:05:04 UTC, Vino wrote: [...] Some comments: 1. You're missing a comma (,) after the first item in your apidata 2. You're creating a string[int][string] instead of string[][string] (your

Re: mir.ndslice : multi dimensional associative array - Example/Docs

2020-10-28 Thread Vino via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 02:50:55 UTC, 9il wrote: On Monday, 26 October 2020 at 14:31:00 UTC, Vino wrote: [...] No. ndslice provides rectangular arrays. An associative array (as it defined in D) can't be really 2D, instead, it is an AA of AAs like in your example. A real 2D analog

Re: Getting Qte5 to work

2020-10-28 Thread evilrat via Digitalmars-d-learn
On Tuesday, 27 October 2020 at 11:46:02 UTC, Josh Dredge wrote: Hi all, I'm completely new to D and while I'm not new to programming in general, I mostly do web development, Welcome! If by web development you also have back-end programming then you should be like 50% know how desktop