Paper comparing languages with egs?

2020-12-15 Thread mark via Digitalmars-d-learn
I _think_ I remember seeing somewhere on the D site a reference to a paper on a comparison of programming languages that used a few small programs written in each compared language. I can't recall if D was one of the languages in the paper or whether someone had done D versions separately. Can

Re: Is garbage detection a thing?

2020-11-29 Thread Mark via Digitalmars-d-learn
Recovering from memory errors at run time is unreliable. I should add that I have more like a romantic view of software release cycles where testing is done until the software is in a very, very sophisticated and stable state. More than usual. Not that I want to solely rely on such an

Re: Is garbage detection a thing?

2020-11-29 Thread Mark via Digitalmars-d-learn
Elimination of memory problems is much more valuable than detection. Recovering from memory errors at run time is unreliable. I'm not sure but I have a gut feeling that I am just in a position that is not good to defend. I want small software that fails hard on weak causes, and the industry

Re: Is garbage detection a thing?

2020-11-29 Thread Mark via Digitalmars-d-learn
The reason this distinction is important, and the reason I bring up graph theory, is that liveness is impossible to prove. Seriously: it's impossible, in the general case, for the GC to prove that an object is still alive. Whereas it's trivial to prove reachability. My motivation was

Re: Is garbage detection a thing?

2020-11-29 Thread Mark via Digitalmars-d-learn
Looking at Ada now. I found: Ada is not good for me. It has no augmented assignment. It's just that I want DRY because I use very verbose variable names, and in the past I had a real world case (game in Lua) where I became frustrated when I had to repeat the names. I understand that NASA or

Re: Is garbage detection a thing?

2020-11-29 Thread Mark via Digitalmars-d-learn
I could use AddressSanitizer indirectly by using Go. But their Oh wait, it was ThreadSanitizer that Go uses, right? I failed at talking. I would probably use ASAN under Linux, because that is the right thing to do? Looking at Ada now.

Re: Is garbage detection a thing?

2020-11-29 Thread Mark via Digitalmars-d-learn
On Sunday, 29 November 2020 at 16:21:59 UTC, Daniel N wrote: On Sunday, 29 November 2020 at 16:05:04 UTC, Mark wrote: Thanks a lot for reading, and sorry for a lot of text that is off-topic and is not related to D. Sounds like what you want is ASAN? You can use it with plain C or D(LDC).

Is garbage detection a thing?

2020-11-29 Thread Mark via Digitalmars-d-learn
Hi, can I ask you something in general? I don't know anyone whom I could ask. I'm a hobbyist with no science degree or job in computing, and also know no other programmers. I have no good understanding why "garbage collection" is a big thing and why "garbage detection" is no thing (I think

C++ or D?

2020-11-09 Thread Mark via Digitalmars-d-learn
Hi all, my question would be about using D or not using D. Is the newest C++ iteration any good compared to D? The reason I haven't used C++ anymore for years is that I was too naive sometimes. I tried to use new features in Visual C++, found myself being like a beta-tester for some things.

Re: GtkD - how to list 0..100K strings

2020-04-29 Thread mark via Digitalmars-d-learn
Continuing this in the GtkD mailing list: https://forum.gtkd.org/groups/GtkD/thread/1370/

Re: GtkD - how to list 0..100K strings

2020-04-28 Thread mark via Digitalmars-d-learn
On Tuesday, 28 April 2020 at 18:46:18 UTC, Kagamin wrote: Try this: void populate(NameAndDescription[] namesAndDescriptions) { if(namesAndDescriptions.length>100)namesAndDescriptions=namesAndDescriptions[0..100]; innerView.viewData.populate(namesAndDescriptions); } I

Re: It won't run in gdb...

2020-04-27 Thread mark via Digitalmars-d-learn
On Monday, 27 April 2020 at 12:26:23 UTC, Adam D. Ruppe wrote: On Mon, Apr 27, 2020 at 10:56:09AM +, mark via Digitalmars-d-learn wrote: Thread 1 "DebFind" received signal SIGUSR1, User defined signal 1. The GC sends that signal to pause other threads when it is about to collec

Re: GtkD crash: 'BadAlloc (insufficient resources for operation)'

2020-04-27 Thread mark via Digitalmars-d-learn
I took Adam's advice about .gdbinit and now it runs in gdb. When I ran the program I did Find 'memoize' which worked. Then 'memoize python' which also worked. Then said to find 'any word' (which produces 1000s of rows) at which point it crashed. Below is the bt. Does it look like my bug or a

GtkD crash: 'BadAlloc (insufficient resources for operation)'

2020-04-27 Thread mark via Digitalmars-d-learn
I'm getting a crash when I add 1000s of rows to a tree (up to 100s seems to work ok). The source code is here: https://github.com/mark-summerfield/debfind Note that this will only build and run on a Debian or Debian-derived system (e.g., Ubuntu). I am pretty well reaching the point of

It won't run in gdb...

2020-04-27 Thread mark via Digitalmars-d-learn
: dub build Performing "debug" build using /home/mark/opt/ldc2-1.21.0-linux-x86_64/bin/ldc2 for x86_64. aaset 0.2.5: target for configuration "library" is up to date. gtk-d:gtkd 3.9.0: target for configuration "library" is up to date. debfind ~master: target for configuration "application" is

Re: GtkD - how to list 0..100K strings: new problem

2020-04-27 Thread mark via Digitalmars-d-learn
With the new code if I have 1000s of rows I get this error: (DebFind:8087): Gdk-ERROR **: 11:50:46.787: The program 'DebFind' received an X Window System error. This probably reflects a bug in the program. The error was 'BadAlloc (insufficient resources for operation)'. (Details: serial 8810

Re: GtkD - how to list 0..100K strings [solved]

2020-04-27 Thread mark via Digitalmars-d-learn
I renamed the class shown in my previous post from View to InnerView, then created a new View class: class View : ScrolledWindow { import qtrac.debfind.modelutil: NameAndDescription; InnerView innerView; this() { super(); innerView = new InnerView;

Re: GtkD - how to list 0..100K strings

2020-04-27 Thread mark via Digitalmars-d-learn
I've now got it to work but it is unusable! It can show small numbers of rows with no problem. However, if it has to show 100s of rows it expands the tree vertically way beyond the bottom of the screen and is impossible to navigate. However, if it has to show 1000s of rows it goes into an

GtkD - how to list 0..100K strings

2020-04-26 Thread mark via Digitalmars-d-learn
I'm trying to develop an application in GtkD. I need a widget to display a list of strings: there could be anything from 0 to 100K strings, but typically a few hundred or thousand. Using the DemoCustomList as a model I have created this code: // Note: DebNames is an AAset!string (AAset is a

Re: can a unittest read main()'s args?

2020-03-22 Thread mark via Digitalmars-d-learn
On Sunday, 22 March 2020 at 07:59:01 UTC, rikki cattermole wrote: On 22/03/2020 8:57 PM, mark wrote: I have a module with a unittest { ... } block. However, when I run dub test sometimes I want to output some extra data when the test runs. At the moment I control this by using an environment

can a unittest read main()'s args?

2020-03-22 Thread mark via Digitalmars-d-learn
I have a module with a unittest { ... } block. However, when I run dub test sometimes I want to output some extra data when the test runs. At the moment I control this by using an environment variable, but I wondered if it was possible to pass a command line argument 'dub test myarg' and if so

Re: A set type implemented as an AA wrapper

2020-03-12 Thread mark via Digitalmars-d-learn
On Thursday, 12 March 2020 at 16:02:14 UTC, H. S. Teoh wrote: On Thu, Mar 12, 2020 at 08:51:24AM +, mark via Digitalmars-d-learn wrote: [...] YYY: The range() method is clearly not good D style but I don't know how to support foreach (item; aaset) ... The usual idiom is to overload

Re: A set type implemented as an AA wrapper

2020-03-12 Thread mark via Digitalmars-d-learn
Just in case anyone would like to use it, I've put it on github and also added it as a dub package. https://code.dlang.org/packages/aaset

Re: A set type implemented as an AA wrapper

2020-03-12 Thread mark via Digitalmars-d-learn
On Thursday, 12 March 2020 at 11:33:25 UTC, Simen Kjærås wrote: [snip] I'd suggest simply testing if an AA with that key type is valid: struct AAset(T) if (is(int[T])) That's very subtle, but it works. As Ferhat points out, you could use opApply for this. There's also the option of

A set type implemented as an AA wrapper

2020-03-12 Thread mark via Digitalmars-d-learn
I use sets a lot and since I believe that D's rbtree is O(lg n) for add/remove/in and that D's AA is O(1) for these, I want to implement a set in terms of an AA. Below is the code I've got so far. It allows for add and remove. However, it has three problems (that I know of): XXX: I need to

Re: Aliases to mutable thread-local data not allowed [testable source code]

2020-03-11 Thread mark via Digitalmars-d-learn
On Wednesday, 11 March 2020 at 14:01:13 UTC, Simen Kjærås wrote: [snip] Yeah, I forgot we cast to immutable to be able to send, so receive has to receive immutable(Deb)*, after which you can call deb.dup to get a mutable copy: receive( (immutable(Deb)* deb) { debForName[deb.name]

Re: Aliases to mutable thread-local data not allowed [testable source code]

2020-03-11 Thread mark via Digitalmars-d-learn
On Wednesday, 11 March 2020 at 12:22:21 UTC, Simen Kjærås wrote: On Wednesday, 11 March 2020 at 09:29:54 UTC, mark wrote: [snip] Fascinating. It works just fine when compiling for 32-bit targets with DMD on Windows, but not for 64-bit targets, nor when compiling with LDC. Apparently, this

Re: Aliases to mutable thread-local data not allowed [solved-ish]

2020-03-11 Thread mark via Digitalmars-d-learn
I finally got a threaded version that works, and a lot more cleanly than using send/receive. (But performance is dismal, see the end.) Here's the heart of the solution: void readPackages() { import std.algorithm: max; import std.array: array; import

Re: Aliases to mutable thread-local data not allowed [testable source code]

2020-03-11 Thread mark via Digitalmars-d-learn
Hi Simen, I think you must have done something else but didn't mention to get it to compile. I did the exact changes you said and it wouldn't compile. Here's what I get with changes mentioned below (with new full source):

Re: Aliases to mutable thread-local data not allowed [testable source code]

2020-03-10 Thread mark via Digitalmars-d-learn
I've managed to make a cut-down version that's < 170 LOC. It needs to be run on Debian or a Debian-based Linux (e.g., Ubuntu). Below is the full source followed by the error output. // app.d import std.typecons: Tuple; void main() { import std.stdio: writeln, writefln; auto model =

Re: Aliases to mutable thread-local data not allowed

2020-03-10 Thread mark via Digitalmars-d-learn
On Tuesday, 10 March 2020 at 15:27:04 UTC, Steven Schveighoffer wrote: On 3/10/20 7:09 AM, mark wrote: [snip] Still, the correct thing here is to handle immutable(Deb). However, I'd strongly caution you against casting away immutable, that can lead to undefined behavior in D. Better to just

Re: Aliases to mutable thread-local data not allowed

2020-03-10 Thread mark via Digitalmars-d-learn
I just tried: auto jobs = tids.length; while (jobs) { receive( (Deb deb) { debForName[deb.name] = cast(Deb)deb; }, (DoneMessage m) { jobs--; } ); } to cast away the immutable from the

Re: Aliases to mutable thread-local data not allowed

2020-03-10 Thread mark via Digitalmars-d-learn
On Tuesday, 10 March 2020 at 10:02:16 UTC, Simen Kjærås wrote: [snip] As the error message hints at, the problem is Deb may hold references to data that is shared with other objects on the thread from which it originates. Since you know this is not the case, even if the compiler can't prove

Aliases to mutable thread-local data not allowed

2020-03-10 Thread mark via Digitalmars-d-learn
I have this struct: struct Deb { string name; ... Unit[string] tags; // set of tags Deb dup() const { Deb deb; deb.name = name; ... foreach (key; tags.byKey) deb.tags[key] = unit; return deb; } } And I want to populate an

Re: An struct copy constructor that can cope with an AA?

2020-03-09 Thread mark via Digitalmars-d-learn
On Monday, 9 March 2020 at 14:45:15 UTC, Steven Schveighoffer wrote: On 3/9/20 9:23 AM, mark wrote: I have this struct: [snip] I would name it dup instead of copy for consistency with D. A copy constructor is pretty heavy for a struct to do a complete duplication of the AA. You should have

An struct copy constructor that can cope with an AA?

2020-03-09 Thread mark via Digitalmars-d-learn
I have this struct: struct Deb { string name; ... Unit[string] tags; // set of tags Deb copy() const { Deb deb; ... foreach (key, value; tags) // XXX deb.tags[key] = value; return deb; } void clear() { name = "";

Re: How to use sets in D?

2020-03-09 Thread mark via Digitalmars-d-learn
On Sunday, 8 March 2020 at 17:58:16 UTC, Jesse Phillips wrote: On Friday, 7 February 2020 at 19:37:08 UTC, mark wrote: [snip] I think I've usually used the associative arrays, but I also think I tend to avoid using this approach but couldn't quite remember what I do instead. I believe I

Re: How to use sets in D?

2020-03-08 Thread mark via Digitalmars-d-learn
I use sets a lot and am now working on a program that will need to hold sets of 65,000+ items, so I thought I do some timings for the different approaches. Here are some timings (uset uses the AA Unit approach, tset uses an rbtree, and aset uses an AA with bool values): $ ./sets.d size

Re: use of struct vs class

2020-03-07 Thread mark via Digitalmars-d-learn
Steve, thank you once again. Now it compiles & runs! I now create my tree like this: auto debs = new RedBlackTree!(Deb, (a, b) => a.name < b.name); (I feel that the rbtree docs are inadequate regarding creating new empty trees, so have submitted a bug report:

Re: use of struct vs class

2020-03-07 Thread mark via Digitalmars-d-learn
I've now gone back to using structs direct without pointers but I'm still doing something wrong. struct Deb { string name; ... RedBlackTree!string tags; bool valid() { return !(name.empty || description.empty); } void clear() { name = ""; ...; tags.clear; } }

Re: use of struct vs class

2020-03-07 Thread mark via Digitalmars-d-learn
change #1: if (line.empty) { if (deb != null && deb.valid) debs.insert(deb); else // report incomplete deb = null; continue; } if (deb == null)

Re: use of struct vs class

2020-03-07 Thread mark via Digitalmars-d-learn
Instead of deb.clear I'm now doing deb = null;

Re: use of struct vs class

2020-03-07 Thread mark via Digitalmars-d-learn
On Saturday, 7 March 2020 at 10:30:06 UTC, drug wrote: 07.03.2020 13:20, mark пишет: I have this struct (with details omitted [ snip ] Should Deb be a class rather than a struct? Do you consider using pointers in AA: ``` Deb*[string] debForName; ``` I've done some changes including using

use of struct vs class

2020-03-07 Thread mark via Digitalmars-d-learn
I have this struct (with details omitted ... for brevity): struct Deb { string name; ... RedBlackTree!string tags; void clear() { name = ""; ...; tags.clear; } bool valid() { return !(name.empty || description.empty); } } I plan to store >65K of these (with potential for

Re: converting to/from char[]/string

2020-03-05 Thread mark via Digitalmars-d-learn
On Thursday, 5 March 2020 at 13:31:14 UTC, Adam D. Ruppe wrote: On Thursday, 5 March 2020 at 11:03:30 UTC, mark wrote: I want to use the Porter stemming algorithm. There's a D implementation here: https://tartarus.org/martin/PorterStemmer/d.txt I think I (or ketmar and I stole it from him)

Re: converting to/from char[]/string

2020-03-05 Thread mark via Digitalmars-d-learn
I suspect the problem is using .length rather than some other size property.

Re: converting to/from char[]/string

2020-03-05 Thread mark via Digitalmars-d-learn
I changed int to size_t and used const(char[]) etc. as suggested. It ran but crashed. Each crash was a range violation, so for each one I put in a guard so instead of if ( ... m_b[m_k]) I used if (m_k < m_b.length && ... m_b[m_k) I did this kind of fix in three places. The result is that

Re: converting to/from char[]/string

2020-03-05 Thread mark via Digitalmars-d-learn
On Thursday, 5 March 2020 at 11:12:24 UTC, drug wrote: On 3/5/20 2:03 PM, mark wrote: [snip] Your code and errors seem to be not related. OK, it is probably that the D stemmer is 19 years old! I've now got Martin Porter's own Java version, so I'll have a go at porting that to D myself.

converting to/from char[]/string

2020-03-05 Thread mark via Digitalmars-d-learn
I want to use the Porter stemming algorithm. There's a D implementation here: https://tartarus.org/martin/PorterStemmer/d.txt The main public function's signature is: char[] stem(char[] p, int i, int j) But I work entirely in terms of strings (containing individual words), so I want to add

Re: What does assigning void mean?

2020-03-05 Thread mark via Digitalmars-d-learn
On Thursday, 5 March 2020 at 08:35:52 UTC, drug wrote: On 3/5/20 10:47 AM, mark wrote: In Adam Ruppe's D Cookbook there're these lines in a ref counting example: RefCountedObject o = void; // What does this mean/do? o.data = new Implementation(); o.data.refcount = 1; I don't understand the

What does assigning void mean?

2020-03-04 Thread mark via Digitalmars-d-learn
In Adam Ruppe's D Cookbook there're these lines in a ref counting example: RefCountedObject o = void; // What does this mean/do? o.data = new Implementation(); o.data.refcount = 1; I don't understand the first line; could someone explain please?

Where are the GSOC 2020 ideas?

2020-02-27 Thread mark via Digitalmars-d-learn
On https://wiki.dlang.org I can find GSOC ideas 2011-2019, but not 2020. I know the 2020 one's haven't been accepted, but I'd like to know what they are in case I feel like having a go at one as part of learning D.

SQLite 3 support?

2020-02-26 Thread mark via Digitalmars-d-learn
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 or is a third-party library best? For example

A small D/GtkD example game

2020-02-24 Thread mark via Digitalmars-d-learn
I've just completed a small D/GtkD game. It might be useful for others trying to learn GtkD since it is only just over 1000 lines, yet shows how to create a dialog-style app with a modal dialog and a modeless dialog, and a custom drawn widget, as well as keyboard and mouse handling. The

Re: dscanner and ref parameters

2020-02-23 Thread mark via Digitalmars-d-learn
On Sunday, 23 February 2020 at 09:35:30 UTC, Jacob Carlborg wrote: On 2020-02-23 10:03, mark wrote: Then this would not only help dscanner, but also make it clear to programmers that the argument could be modified. It's not necessary for dscanner. It should look at the signature of

dscanner and ref parameters

2020-02-23 Thread mark via Digitalmars-d-learn
I use dscanner to lint my code and find it helpful. However, in GtkD there are several functions which take ref args, and these confuse dscanner. For example: uint kv; event.getKeyval(kv); // ref arg is updated here dscanner incorrectly (but understandably) reports:

Re: GtkD crash

2020-02-21 Thread mark via Digitalmars-d-learn
Thanks for your question, it led me to focus on the Label and now I've solved the problem. I thought that onChangeState was never called before the Label was constructed, but it turns out it is called before. So now I use: if (statusLabel !is null)

GtkD crash

2020-02-21 Thread mark via Digitalmars-d-learn
I'm porting a simple game to GtkD to learn the library and more about D. Unfortunately, I've hit a show-stopping crash. I have a subclass of ApplicationWindow which has this method: private void onChangeState(int score, Board.State state) { import std.format: format;

Re: Dscanner: is it possible to switch off style checks case-by-case?

2020-02-15 Thread mark via Digitalmars-d-learn
On Saturday, 15 February 2020 at 07:23:02 UTC, Basile B. wrote: On Thursday, 13 February 2020 at 17:15:50 UTC, mark wrote: I'm starting out with GtkD and have this function: [snip] Otherwise here is an example of how you can tune the different checks:

Dscanner: is it possible to switch off style checks case-by-case?

2020-02-13 Thread mark via Digitalmars-d-learn
I'm starting out with GtkD and have this function: void main(string[] args) { Main.init(args); auto game = new GameWindow(); Main.run(); } and this method: void quit(Widget widget) { Main.quit(); } When I run dscanner --styleCheck it reports:

Re: Some impressions/notes from a new D programmer

2020-02-12 Thread mark via Digitalmars-d-learn
On Wednesday, 12 February 2020 at 18:20:47 UTC, Adam D. Ruppe wrote: On Wednesday, 12 February 2020 at 15:52:35 UTC, mark wrote: Yours rolls the two examples into one and doesn't show the Standards or Usage sections. Weird, that's a legit bug in there. I'll fix them. I also think you split

Re: Some impressions/notes from a new D programmer

2020-02-12 Thread mark via Digitalmars-d-learn
On Wednesday, 12 February 2020 at 14:15:40 UTC, Adam D. Ruppe wrote: On Wednesday, 12 February 2020 at 10:39:06 UTC, mark wrote: Library Reference Documentation Have you seen my fork? http://dpldocs.info/experimental-docs/std.zip.ZipArchive.html Yours is *much* clearer. However, if you

Re: Some impressions/notes from a new D programmer

2020-02-12 Thread mark via Digitalmars-d-learn
On Wednesday, 12 February 2020 at 11:46:02 UTC, Dennis wrote: Thanks for your perspective. Just a few things are unclear to me: On Wednesday, 12 February 2020 at 10:39:06 UTC, mark wrote: I don't find the presentation of the member properties and methods very easy to read Can you elaborate

Some impressions/notes from a new D programmer

2020-02-12 Thread mark via Digitalmars-d-learn
I've been learning D for a few weeks now. I'm an experienced programmer in other languages (esp. Python, but also Rust and C++). Here're some *early* impressions and notes. D Tour I found the D Tour, esp. "D's Basics" to be very helpful. Each part is short and in most cases understandable.

A D implementation of the Python difflib module's sequence matcher.

2020-02-12 Thread mark via Digitalmars-d-learn
I've just completed my first D package: http://code.dlang.org/packages/ddiff It is a straight port, so it isn't at all functional-style. I'd be happy and interested if anyone could show me how to replace some/all of the for[each] loops (without reducing performance), or for any other code

Re: Is there a std.zip.ZipArchive isDir or isFile method?

2020-02-11 Thread mark via Digitalmars-d-learn
On Wednesday, 12 February 2020 at 05:59:53 UTC, cc wrote: On Monday, 3 February 2020 at 13:26:38 UTC, mark wrote: I'm using std.zip.ZipArchive to read zip files, e.g.: [snip] I couldn't find one either, I had to do this: version(Windows) { enum uint FILE_ATTRIBUTE_DIRECTORY = 0x10; }

Re: GtkD on Windows: notes + question

2020-02-11 Thread mark via Digitalmars-d-learn
On Tuesday, 11 February 2020 at 20:49:40 UTC, Ron Tarrant wrote: On Sunday, 9 February 2020 at 13:28:59 UTC, mark wrote: I found a much easier way to get GtkD working on windows than that described in https://gtkdcoding.com/2019/01/11/-introduction-to-gtkDcoding.html Just FYI... I don't

Re: GtkD on Windows: notes + question

2020-02-10 Thread mark via Digitalmars-d-learn
On Sunday, 9 February 2020 at 14:08:02 UTC, Daniel Kozak wrote: "lflags-windows": ["/SUBSYSTEM:WINDOWS", "/ENTRY:mainCRTStartup"], [snip] Is there a way to avoid the console Window, at least for release builds? Thank you! Your solution I guess is for dub.json. For those using dub.sdl the

Re: GtkD on Windows: notes + question

2020-02-10 Thread mark via Digitalmars-d-learn
On Sunday, 9 February 2020 at 14:08:02 UTC, Daniel Kozak wrote: "lflags-windows": ["/SUBSYSTEM:WINDOWS", "/ENTRY:mainCRTStartup"], [snip] Is there a way to avoid the console Window, at least for release builds? Thank you! Your solution I guess is for dub.json. For those using dub.sdl the

GtkD on Windows: notes + question

2020-02-09 Thread mark via Digitalmars-d-learn
I found a much easier way to get GtkD working on windows than that described in https://gtkdcoding.com/2019/01/11/-introduction-to-gtkDcoding.html 1. I downloaded and installed the Gtk3 runtime (the link is on https://gtkdcoding.com/2019/01/11/-introduction-to-gtkDcoding.html) 2. I

Re: How to compile with GtkD [solved]

2020-02-09 Thread mark via Digitalmars-d-learn
Turns out I didn't need to add lines to dub.sdl at all. So my dub.sdl is now just: name "gtktest" description "Gtk Test" authors "Mark" targetType "executable" dependency "gtk-d:gtkd" version=">=3.9.0" The solution was to do this: $ dub add-path ~/opt/GtkD3/ After that it does static builds,

Re: How to compile with GtkD

2020-02-09 Thread mark via Digitalmars-d-learn
On Sunday, 9 February 2020 at 12:03:23 UTC, Ron Tarrant wrote: On Sunday, 9 February 2020 at 11:52:19 UTC, mark wrote: right now I want to start on Linux and I'm stuck. Maybe this will help... https://gtkdcoding.com/2019/03/31/x0002-gtkd-in-a-linux-environment.html Unfortunately it didn't

How to compile with GtkD

2020-02-09 Thread mark via Digitalmars-d-learn
According to the GtkD web site https://gtkd.org/ this GUI library is cross-platform, so hopefully just what I need. The introductory blog https://gtkdcoding.com/2019/01/11/-introduction-to-gtkDcoding.html explains how to install and get started with GtkD on Windows (which I plan to use

Re: How to use sets in D?

2020-02-07 Thread mark via Digitalmars-d-learn
On Friday, 7 February 2020 at 22:03:00 UTC, H. S. Teoh wrote: On Fri, Feb 07, 2020 at 07:37:08PM +, mark via Digitalmars-d-learn wrote: [snip] bool[E] works just fine. [snip] Or you can wrap void[0][E] in a nice user-defined type that gives nice set-like syntax. But IMO, this is all

How to use sets in D?

2020-02-07 Thread mark via Digitalmars-d-learn
I am porting code from other languages to D as part of learning D, and I find I've used sets quite a lot. AFAIK D doesn't have a built-in set type or one in the std. lib. However, I've been perfectly successfully using int[E] where E is my ElementType, and adding with set[element] = 0. I

Re: Does D have an equvalent of: if (auto = expr; expr)

2020-02-07 Thread mark via Digitalmars-d-learn
Thanks for the excellent replies.

Does D have an equvalent of: if (auto = expr; expr)

2020-02-07 Thread mark via Digitalmars-d-learn
Some languages support this kind of thing: if ((var x = expression) > 50) print(x, " is > 50") Is there anything similar in D?

Re: Trying to use a template class with ranges

2020-02-06 Thread mark via Digitalmars-d-learn
On Thursday, 6 February 2020 at 16:29:57 UTC, Steven Schveighoffer wrote: On 2/6/20 11:05 AM, mark wrote: src/package.d(50,35): Error: no property opCall for type diffrange.Diff!(dchar[]), did you mean new Diff!(dchar[])? Hah, forgot that it's a class. Yes, I DID mean new Diff ;) -Steve

Re: Trying to use a template class with ranges

2020-02-06 Thread mark via Digitalmars-d-learn
On Thursday, 6 February 2020 at 15:21:46 UTC, Steven Schveighoffer wrote: [snip] 3. You should declare constraints signifying what types are valid. i.e.: class Diff(T) if ( isForwardRange!T // it's a forward range && is(typeof(T.init.front == T.init.front)) // elements are comparable

Re: Trying to use a template class with ranges

2020-02-06 Thread mark via Digitalmars-d-learn
I forgot to mention: I want the class to work with: Diff(aForwardRange, bForwardRange) where T = ForwardRange, E = anything that supports == A common use case is for two sequences of strings (i.e., lines read from two files). Diff(aString, bString) where T = char[] or wchar[] or dchar[] E =

Trying to use a template class with ranges

2020-02-06 Thread mark via Digitalmars-d-learn
I am starting on porting Python's difflib's sequence matcher to D. I want to have a class that will accept two ranges whose elements are of the same type and whose elements can be compared for equality. How do I make a class declaration that specifies a (forward) range type and an

Re: dub for lib & app?

2020-02-04 Thread mark via Digitalmars-d-learn
On Tuesday, 4 February 2020 at 09:21:17 UTC, Andre Pany wrote: On Tuesday, 4 February 2020 at 09:13:48 UTC, mark wrote: Is it possible to create a dub project that has one library and one or more executables (that use the library)? If so, could someone point me to the docs for this since I

dub for lib & app?

2020-02-04 Thread mark via Digitalmars-d-learn
Is it possible to create a dub project that has one library and one or more executables (that use the library)? If so, could someone point me to the docs for this since I couldn't find this in the dub docs? Aside: I'm learning D to give me something approaching the convenience of Python with

Re: Empty string vs null

2020-02-04 Thread mark via Digitalmars-d-learn
Thanks for that thorough and careful explanation. Since I'm trying to learn to write D in good style and want my code to be reliable and maintainable, I've now switched to using "" rather than null.

Re: Empty string vs null

2020-02-03 Thread mark via Digitalmars-d-learn
Just found this post by Mark Parker that explains: https://forum.dlang.org/post/gvveit$10i5$1...@digitalmars.com // test.d import std.stdio; import std.string; void main() { report(null, "null"); report(""); report("x"); } void report(const string x, const string name=null) {

Empty string vs null

2020-02-03 Thread mark via Digitalmars-d-learn
I have just discovered that D seems to treat empty and null strings as the same thing: // test.d import std.stdio; import std.string; void main() { string x = null; writeln("x = \"", x, "\""); writeln("null = ", x == null); writeln("\"\"= ", x == ""); writeln("empty

Is there a std.zip.ZipArchive isDir or isFile method?

2020-02-03 Thread mark via Digitalmars-d-learn
I'm using std.zip.ZipArchive to read zip files, e.g.: auto zip = new ZipArchive(read(filename)); // ... foreach (name, member; zip.directory) { if (name.endsWith('/')) // skip dirs continue; mkdirRecurse(dirName(name)); zip.expand(member);

Re: How do I fix my failed PRs?

2020-02-03 Thread mark via Digitalmars-d-learn
Thanks Petar... I'm in no hurry, just glad that they're in process:-)

Re: How do I fix my failed PRs?

2020-02-02 Thread mark via Digitalmars-d-learn
On Sunday, 2 February 2020 at 12:49:31 UTC, MoonlightSentinel wrote: On Sunday, 2 February 2020 at 08:54:02 UTC, mark wrote: However, four have not been accepted, apparently for technical reasons. But I don't understand what's wrong or what I need to do to fix them. (I'm not very knowledgeable

How do I fix my failed PRs?

2020-02-02 Thread mark via Digitalmars-d-learn
I've done quite a few small corrections/improvements to the D-tour's English. Almost all have been accepted. However, four have not been accepted, apparently for technical reasons. But I don't understand what's wrong or what I need to do to fix them. (I'm not very knowledgeable about github.)

Re: books for learning D

2020-01-31 Thread mark via Digitalmars-d-learn
On Wednesday, 29 January 2020 at 11:57:14 UTC, Jan Hönig wrote: On Monday, 13 January 2020 at 16:37:31 UTC, Ron Tarrant wrote: On Monday, 13 January 2020 at 10:28:48 UTC, mark wrote: I'm just starting out learning D. Andrei Alexandrescu's "The D Programming Language" is 10 years old, so is

Re: wordladder - code improvement

2020-01-31 Thread mark via Digitalmars-d-learn
I forgot to mention: I know it isn't worth bothering with const/immutable for this tiny example. But I want to learn how to write large D programs, so I need to get into the right habits and know the right things.

Re: wordladder - code improvement

2020-01-31 Thread mark via Digitalmars-d-learn
Thanks for your implementation. I can't use the levenshtien distance because although it is a better solution, I want to keep the implementation as compatible with those in the other languages as possible. Your main() is much shorter than mine, but doesn't match the behaviour (and again I

wordladder - code improvement

2020-01-30 Thread mark via Digitalmars-d-learn
Below is a program that produces a wordladder. The algorithm is probably suboptimal, but I don't care since I've implemented the same one in Python, Rust, Go, Java, and Nim, so I find it useful for language comparison purposes. What I'd like some feedback on is how to improve the code

D Cookbook range save question

2020-01-30 Thread mark via Digitalmars-d-learn
In the D Cookbook it has as part of the FibonacciRange example: @property FibonacciRange save() { return this; } And in the description it says: "...save, which returns a new range that is a copy of the current range and can be advanced independently..." Why is this a *copy*? (For a copy

Re: D Cookbook range save question

2020-01-30 Thread mark via Digitalmars-d-learn
On Thursday, 30 January 2020 at 10:31:08 UTC, mark wrote: In the D Cookbook it has as part of the FibonacciRange example: @property FibonacciRange save() { return this; } And in the description it says: "...save, which returns a new range that is a copy of the current range and can be

Re: compiler error when trying to get random key from AA

2020-01-25 Thread mark via Digitalmars-d-learn
In the end I used this line since I'm not fussy about the rnd for this: auto word = compatibles.byKey.array.choice; Thank you!

Re: compiler error when trying to get random key from AA

2020-01-25 Thread mark via Digitalmars-d-learn
On Saturday, 25 January 2020 at 08:59:23 UTC, Basile B. wrote: On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote: I have this code: import std.random; import std.stdio; void main() { auto aa = ["one": 1, "two": 2, "three": 3]; writeln(aa); auto rnd = rndGen; auto word =

compiler error when trying to get random key from AA

2020-01-25 Thread mark via Digitalmars-d-learn
I have this code: import std.random; import std.stdio; void main() { auto aa = ["one": 1, "two": 2, "three": 3]; writeln(aa); auto rnd = rndGen; auto word = aa.byKey.choice(rnd); writeln(word); } And in the D playground it gives this error: onlineapp.d(8): Error: template

weekly news?

2020-01-22 Thread mark via Digitalmars-d-learn
Is there a "D weekly news" I could do an email subscription to? Or at least a way to get notified by email when a new item appears on https://dlang.org/blog/ ?

  1   2   >