Re: template instantiation problems

2020-01-14 Thread Boris Carvajal via Digitalmars-d-learn
On Friday, 10 January 2020 at 18:31:59 UTC, ag0aep6g wrote: import m1 = foo.baz; import m2 = foo; alias p = __traits(parent, m1); pragma(msg, m1.stringof); /* "module baz", ok */ pragma(msg, m2.stringof); /* "module foo", ok */ pragma(msg, p.stringof); /* "package foo", ok */ enum e(alias

Re: range algorithms on container class

2020-01-14 Thread Alex Burton via Digitalmars-d-learn
On Thursday, 9 January 2020 at 10:26:07 UTC, Jonathan M Davis wrote: On Wednesday, January 8, 2020 10:56:20 PM MST rikki cattermole via Digitalmars-d-learn wrote: Slicing via the opSlice operator overload is a convention, not a requirement. It's not a requirement, but it's more than a conventi

Re: Filling an associated array of associated arrays

2020-01-14 Thread Jamie via Digitalmars-d-learn
On Tuesday, 14 January 2020 at 23:59:59 UTC, mipri wrote: On Tuesday, 14 January 2020 at 23:23:51 UTC, Jamie wrote: c.f. https://issues.dlang.org/show_bug.cgi?id=17607 I found that by searching the forums for your error. That has fixed my issue. I had searched the forums for relevant topics,

So, you want to be a programmer? Here is the way to go.

2020-01-14 Thread Murilo via Digitalmars-d-learn
Hi everyone. I've received so many people asking me about how to learn programming, or complaining about how difficult it is, that I wrote a small text teaching the way to go for those who want to learn programming. I tried to write it in a funny and straight forward way. Here it is: https:/

Re: Filling an associated array of associated arrays

2020-01-14 Thread mipri via Digitalmars-d-learn
On Tuesday, 14 January 2020 at 23:23:51 UTC, Jamie wrote: I'm trying to initialise an associated array of associated arrays with values, taking the same approach I would for an associated array: This works: import std.stdio; void main() { string[string][string] table = ([ "in

Filling an associated array of associated arrays

2020-01-14 Thread Jamie via Digitalmars-d-learn
I'm trying to initialise an associated array of associated arrays with values, taking the same approach I would for an associated array: string[string][string] table = [ "info" : [ "equation" : "H2 + I2 <=> 2HI", "type" : "elementary", ], "frc" : [ "A" :

Re: How to create meson.build with external libs?

2020-01-14 Thread p.shkadzko via Digitalmars-d-learn
On Tuesday, 14 January 2020 at 20:14:30 UTC, p.shkadzko wrote: On Tuesday, 14 January 2020 at 15:15:09 UTC, Rasmus Thomsen wrote: On Tuesday, 14 January 2020 at 09:54:18 UTC, p.shkadzko wrote: On Monday, 13 January 2020 at 21:15:51 UTC, p.shkadzko wrote: On Monday, 13 January 2020 at 20:53:43

Re: How to create meson.build with external libs?

2020-01-14 Thread p.shkadzko via Digitalmars-d-learn
On Tuesday, 14 January 2020 at 15:15:09 UTC, Rasmus Thomsen wrote: On Tuesday, 14 January 2020 at 09:54:18 UTC, p.shkadzko wrote: On Monday, 13 January 2020 at 21:15:51 UTC, p.shkadzko wrote: On Monday, 13 January 2020 at 20:53:43 UTC, p.shkadzko wrote: On Monday, 13 January 2020 at 19:56:35 U

Re: How to create meson.build with external libs?

2020-01-14 Thread p.shkadzko via Digitalmars-d-learn
On Tuesday, 14 January 2020 at 11:26:30 UTC, Andre Pany wrote: On Tuesday, 14 January 2020 at 09:54:18 UTC, p.shkadzko wrote: [...] May I ask, whether you have tried to use Dub, or is s.th. blocking you from using Dub? Kind regards André I tested dub and it fetched and compiled mir.ndslic

Re: Reading a file of words line by line

2020-01-14 Thread mipri via Digitalmars-d-learn
On Tuesday, 14 January 2020 at 16:39:16 UTC, mark wrote: I can't help feeling that the foreach loop's block is rather more verbose than it could be? WordSet words; auto rx = ctRegex!(r"^[a-z]+", "i"); auto file = File(filename); foreach (line; file.byLine) { auto matc

Re: Reading a file of words line by line

2020-01-14 Thread mark via Digitalmars-d-learn
Should I have closed the file, i.e.,: auto file = File(filename); scope(exit) file.close(); // Add this?

Reading a file of words line by line

2020-01-14 Thread mark via Digitalmars-d-learn
As part of learning D I want to read a file that contains one word per line (plus optional junk after the word) and creates a set of all the unique words of a particular length (uppercased). D doesn't appear to have a set type so I'm faking using an associative array whose values are always 0.

Re: Invalid memory operation during allocation with `new`

2020-01-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/13/20 6:06 PM, Per Nordlöw wrote: On Monday, 13 January 2020 at 20:30:33 UTC, Adam D. Ruppe wrote: Reading symbols from pain... (gdb) break onInvalidMemoryOperationError Breakpoint 1 at 0x4614f8 (gdb) r Starting program: /home/me/test/pain [Thread debugging using libthread_db enabled] Using

Re: How to create meson.build with external libs?

2020-01-14 Thread Rasmus Thomsen via Digitalmars-d-learn
On Tuesday, 14 January 2020 at 09:54:18 UTC, p.shkadzko wrote: On Monday, 13 January 2020 at 21:15:51 UTC, p.shkadzko wrote: On Monday, 13 January 2020 at 20:53:43 UTC, p.shkadzko wrote: On Monday, 13 January 2020 at 19:56:35 UTC, p.shkadzko wrote: On Monday, 13 January 2020 at 17:14:29 UTC, p

Re: Is it safe in D to cast pointers to structures like this?

2020-01-14 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Tuesday, 14 January 2020 at 12:05:01 UTC, John Burton wrote: After years of C++ I have become paranoid about any casting of pointers being undefined behavior due to aliasing so want to see if :- FWIW, this is safe and portable in C++20: https://en.cppreference.com/w/cpp/numeric/bit_cast

Is it safe in D to cast pointers to structures like this?

2020-01-14 Thread John Burton via Digitalmars-d-learn
After years of C++ I have become paranoid about any casting of pointers being undefined behavior due to aliasing so want to see if :- 1) This is safe to do in D. 2) If not is there anything I can do to make it safe. 3) If not, what is the best approach? I have a void* pointing to a block of al

Re: How to create meson.build with external libs?

2020-01-14 Thread Andre Pany via Digitalmars-d-learn
On Tuesday, 14 January 2020 at 09:54:18 UTC, p.shkadzko wrote: [...] May I ask, whether you have tried to use Dub, or is s.th. blocking you from using Dub? Kind regards André

Blog Post #0098: More HeaderBar Stuff

2020-01-14 Thread Ron Tarrant via Digitalmars-d-learn
Wanna know how to rearrange the contents of your HeaderBar? Or add extra widgets to that same HeaderBar? Then come on over to the GtkD Coding Blog and have a read: https://gtkdcoding.com/2020/01/14/0098-headerbar-more.html

Re: How to create meson.build with external libs?

2020-01-14 Thread p.shkadzko via Digitalmars-d-learn
On Monday, 13 January 2020 at 21:15:51 UTC, p.shkadzko wrote: On Monday, 13 January 2020 at 20:53:43 UTC, p.shkadzko wrote: On Monday, 13 January 2020 at 19:56:35 UTC, p.shkadzko wrote: On Monday, 13 January 2020 at 17:14:29 UTC, p.shkadzko wrote: [...] I had to set PKG_CONFIG_PATH to "/usr/