Re: Should a parser type be a struct or class?

2020-06-17 Thread user1234 via Digitalmars-d-learn
On Wednesday, 17 June 2020 at 11:50:27 UTC, Per Nordlöw wrote: Should a range-compliant aggregate type realizing a parser be encoded as a struct or class? In dmd `Lexer` and `Parser` are both classes. In general how should I reason about whether an aggregate type should be encoded as a struct

Re: "if not" condition check (for data validation)

2020-06-17 Thread Ali Çehreli via Digitalmars-d-learn
On 6/17/20 4:46 PM, Denis wrote:> Is there a cleaner way to implement an "if not" condition check? >if ( configfile.isFile && configfile.extension == ".conf", message ) { } >else if (isConfigFile(name)) { // ... } else { // ... } The following is suitable in many case

Re: Does std.net.curl: download have support for callbacks?

2020-06-17 Thread dangbinghoo via Digitalmars-d-learn
On Thursday, 11 June 2020 at 06:13:59 UTC, adnan338 wrote: On Thursday, 11 June 2020 at 06:05:09 UTC, adnan338 wrote: I would like to set a callback for the `download()` function but I do not seem to find a way to add a callback to the procedure. [...] I have also been told that Gtk is not

Re: "if not" condition check (for data validation)

2020-06-17 Thread Denis via Digitalmars-d-learn
On Thursday, 18 June 2020 at 00:43:40 UTC, Stanislav Blinov wrote: if( ! (configfile.isFile && configfile.extension == ".conf") ) ? That does indeed clean up the compound logic. One is still left with: if( !( if( ! if( !( if( ! : I was hoping to get away from all the `not`s too

Re: "if not" condition check (for data validation)

2020-06-17 Thread Stanislav Blinov via Digitalmars-d-learn
On Wednesday, 17 June 2020 at 23:46:54 UTC, Denis wrote: `if` is not a good substitute, because it works in the opposite sense, often requiring lots of `not`s. As a trivial example: assert( configfile.isFile && configfile.extension == ".conf" ) -vs- if ( !configfile.isFile || configfile

"if not" condition check (for data validation)

2020-06-17 Thread Denis via Digitalmars-d-learn
Is there a cleaner way to implement an "if not" condition check? WHY NOT JUST USE "IF"? For data validation, code is cleaner and more intelligible if the condition being checked is written in an affirmative sense; that is, in the same way that `assert` is written. This is especially true when

Re: Should a parser type be a struct or class?

2020-06-17 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jun 17, 2020 at 02:32:09PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Wednesday, 17 June 2020 at 14:24:01 UTC, Stefan Koch wrote: > > Parser in dmd does even inherit from Lexer. > > why would a parser ever inherit from a lexer? Because, unlike a regular parser-driven compil

Re: Should a parser type be a struct or class?

2020-06-17 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 17 June 2020 at 14:24:01 UTC, Stefan Koch wrote: Parser in dmd does even inherit from Lexer. why would a parser ever inherit from a lexer?

Re: Should a parser type be a struct or class?

2020-06-17 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 17 June 2020 at 11:50:27 UTC, Per Nordlöw wrote: Should a range-compliant aggregate type realizing a parser be encoded as a struct or class? In dmd `Lexer` and `Parser` are both classes. In general how should I reason about whether an aggregate type should be encoded as a struct

Re: Should a parser type be a struct or class?

2020-06-17 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jun 17, 2020 at 11:50:27AM +, Per Nordlöw via Digitalmars-d-learn wrote: > Should a range-compliant aggregate type realizing a parser be encoded > as a struct or class? Preferably a struct IMO, but see below. > In dmd `Lexer` and `Parser` are both classes. Probably for historical r

Re: Link error triggered by `dub test` but not by `dub build --unittest`

2020-06-17 Thread Per Nordlöw via Digitalmars-d-learn
On Wednesday, 17 June 2020 at 12:12:24 UTC, Per Nordlöw wrote: On Tuesday, 16 June 2020 at 12:21:26 UTC, Per Nordlöw wrote: when dub test doesn't? I'm trying to reduce it through dustmite phobos-next "dub test 2>&1 | grep -F '_D6object10_xopEqualsFMxPvMxQeZb'" Is this the best wa

Re: How to compile to .bin/.iso format

2020-06-17 Thread FeepingCreature via Digitalmars-d-learn
On Wednesday, 17 June 2020 at 12:39:11 UTC, FeepingCreature wrote: On Wednesday, 17 June 2020 at 12:30:24 UTC, Quantium wrote: Hi all! I have a programm in D (The simplest OS), which should be compiled into .bin or .iso format to be possible to run it on VirtualBox. How can I compile it to .bin

Re: How to compile to .bin/.iso format

2020-06-17 Thread FeepingCreature via Digitalmars-d-learn
On Wednesday, 17 June 2020 at 12:30:24 UTC, Quantium wrote: Hi all! I have a programm in D (The simplest OS), which should be compiled into .bin or .iso format to be possible to run it on VirtualBox. How can I compile it to .bin / .iso format and which compiler should I use? Try this page? ht

Re: Should a parser type be a struct or class?

2020-06-17 Thread Stanislav Blinov via Digitalmars-d-learn
On Wednesday, 17 June 2020 at 11:50:27 UTC, Per Nordlöw wrote: Should a range-compliant aggregate type realizing a parser be encoded as a struct or class? In dmd `Lexer` and `Parser` are both classes. In general how should I reason about whether an aggregate type should be encoded as a struct

Re: Should a parser type be a struct or class?

2020-06-17 Thread Simen Kjærås via Digitalmars-d-learn
On Wednesday, 17 June 2020 at 11:50:27 UTC, Per Nordlöw wrote: Should a range-compliant aggregate type realizing a parser be encoded as a struct or class? In dmd `Lexer` and `Parser` are both classes. In general how should I reason about whether an aggregate type should be encoded as a struct

How to compile to .bin/.iso format

2020-06-17 Thread Quantium via Digitalmars-d-learn
Hi all! I have a programm in D (The simplest OS), which should be compiled into .bin or .iso format to be possible to run it on VirtualBox. How can I compile it to .bin / .iso format and which compiler should I use?

Re: Link error triggered by `dub test` but not by `dub build --unittest`

2020-06-17 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 16 June 2020 at 12:21:26 UTC, Per Nordlöw wrote: when dub test doesn't? I'm trying to reduce it through dustmite phobos-next "dub test 2>&1 | grep -F '_D6object10_xopEqualsFMxPvMxQeZb'" Is this the best way to use dustmite in this case?

Should a parser type be a struct or class?

2020-06-17 Thread Per Nordlöw via Digitalmars-d-learn
Should a range-compliant aggregate type realizing a parser be encoded as a struct or class? In dmd `Lexer` and `Parser` are both classes. In general how should I reason about whether an aggregate type should be encoded as a struct or class?

Re: Link error triggered by `dub test` but not by `dub build --unittest`

2020-06-17 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 16 June 2020 at 12:21:26 UTC, Per Nordlöw wrote: All the linker errors originate from zio.d but zio.d has its unittests disabled so how come this fails to link? zio.d is not the source of the problem. Something else is. The common denominator seems to be that the builtins xopEqual