Re: Why is stdio ... stdio?

2018-11-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 8, 2018 7:25:45 PM MST Neia Neutuladh via Digitalmars- d-learn wrote: > It's not a forum. It's a newsgroup that happens to have a web interface. > Newsgroups are text-only. So bbcode is out, html is out, but interpreting > markdown might be reasonable. But nobody's done that

Re: Is this a bug? +goto

2018-11-08 Thread Michelle Long via Digitalmars-d-learn
On Thursday, 8 November 2018 at 10:31:31 UTC, Jonathan M Davis wrote: On Thursday, November 8, 2018 2:34:34 AM MST Michelle Long via Digitalmars- d-learn wrote: Obviously, but that is not the case I mentioned. You can assume that I know how scopes work. No need to assume everyone that shows

Re: Why is stdio ... stdio?

2018-11-08 Thread Neia Neutuladh via Digitalmars-d-learn
On Fri, 09 Nov 2018 02:03:36 +, Chris Katko wrote: > Simple curious question. > > Why isn't : > > import std.stdio; > > instead: > > import std.io; IO includes things like memory mapping, sockets, listing files, named pipes, that sort of thing. Standard IO includes only reading and

Re: Why is stdio ... stdio?

2018-11-08 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Nov 09, 2018 at 02:03:36AM +, Chris Katko via Digitalmars-d-learn wrote: > Simple curious question. > > Why isn't : > > import std.stdio; > > instead: > > import std.io; The reason is that std.stdio is basically just a nice D wrapper with syntactic sugar around the C library's

Re: Exception slipping through the catch block?

2018-11-08 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Nov 09, 2018 at 01:14:08AM +, Neia Neutuladh via Digitalmars-d-learn wrote: [...] > This isn't, strictly speaking, safe. Your program detected an error, > and in Walter's book, that means you can't trust the program to do > *anything*. Unwinding the stack, formatting a stacktrace,

Why is stdio ... stdio?

2018-11-08 Thread Chris Katko via Digitalmars-d-learn
Simple curious question. Why isn't : import std.stdio; instead: import std.io; (Also, while we're at it. Why doesn't this form have code highlighting? It would much improve readibility. Doesn't that seem almost essential for a programming forum?) I mean, I get it. stdio is the c header

Re: How do I install a library?

2018-11-08 Thread bachmeier via Digitalmars-d-learn
On Friday, 9 November 2018 at 00:18:28 UTC, H. S. Teoh wrote: It's not true that you're stuck with dub. And I'm not among the people who think dub is the way to go (though it's true that that's a minority opinion around here). Where I have a choice, my own D projects do not use dub. I have

Re: Exception slipping through the catch block?

2018-11-08 Thread Neia Neutuladh via Digitalmars-d-learn
On Thu, 08 Nov 2018 17:27:40 -0700, Jonathan M Davis wrote: > You ran into one of the rare cases where it makes sense catch an Error > or a Throwable, and you're one of the few people who understands the > situation well enough to deal with it properly. The vast majority of D > programmers don't.

Re: Exception slipping through the catch block?

2018-11-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 8, 2018 2:34:38 PM MST H. S. Teoh via Digitalmars-d- learn wrote: > On Thu, Nov 08, 2018 at 01:28:47PM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > > On Thursday, November 8, 2018 10:55:45 AM MST Stanislav Blinov via > > > > Digitalmars-d-learn wrote: > > > On

Re: How do I install a library?

2018-11-08 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Nov 08, 2018 at 11:51:39PM +, bachmeier via Digitalmars-d-learn wrote: > On Thursday, 8 November 2018 at 23:43:38 UTC, Murilo wrote: > > > It finally worked, but I can't just compile it normally, I have to > > use dub run, I wish it were something simple that I just download > > into

Re: How do I install a library?

2018-11-08 Thread Dennis via Digitalmars-d-learn
On Thursday, 8 November 2018 at 23:43:38 UTC, Murilo wrote: It finally worked, but I can't just compile it normally, I have to use dub run, I wish it were something simple that I just download into the folder and then use an import statement and then compile it like any other program. I wish

Re: How do I install a library?

2018-11-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/8/18 6:43 PM, Murilo wrote: On Thursday, 8 November 2018 at 23:28:05 UTC, Steven Schveighoffer wrote: On 11/8/18 6:07 PM, Steven Schveighoffer wrote: If you want to build the dlangui library directly and install it on your own without dub, you would need to download the source (probably

Re: How do I install a library?

2018-11-08 Thread bachmeier via Digitalmars-d-learn
On Thursday, 8 November 2018 at 23:43:38 UTC, Murilo wrote: It finally worked, but I can't just compile it normally, I have to use dub run, I wish it were something simple that I just download into the folder and then use an import statement and then compile it like any other program. I wish

Re: How do I install a library?

2018-11-08 Thread Murilo via Digitalmars-d-learn
On Thursday, 8 November 2018 at 23:28:05 UTC, Steven Schveighoffer wrote: On 11/8/18 6:07 PM, Steven Schveighoffer wrote: If you want to build the dlangui library directly and install it on your own without dub, you would need to download the source (probably from github) and build it using

Re: How do I install a library?

2018-11-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/8/18 6:07 PM, Steven Schveighoffer wrote: If you want to build the dlangui library directly and install it on your own without dub, you would need to download the source (probably from github) and build it using dub. When I said without using dub, I meant without using dub to build

Re: How do I install a library?

2018-11-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/8/18 5:46 PM, Murilo wrote: On Thursday, 8 November 2018 at 22:28:38 UTC, Steven Schveighoffer wrote: On 11/8/18 4:46 PM, Murilo wrote: I want to install the library DlangUI but I don't know how to do it. In python I just type pip and it works, but in D I don't know how to do it. Can

Re: How do I install a library?

2018-11-08 Thread Murilo via Digitalmars-d-learn
On Thursday, 8 November 2018 at 22:28:38 UTC, Steven Schveighoffer wrote: On 11/8/18 4:46 PM, Murilo wrote: I want to install the library DlangUI but I don't know how to do it. In python I just type pip and it works, but in D I don't know how to do it. Can anyone help me? dlangui will be

Re: How do I install a library?

2018-11-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/8/18 4:46 PM, Murilo wrote: I want to install the library DlangUI but I don't know how to do it. In python I just type pip and it works, but in D I don't know how to do it. Can anyone help me? dlangui will be fetched if you make it a dependency of your project. When you run dub init

How do I install a library?

2018-11-08 Thread Murilo via Digitalmars-d-learn
I want to install the library DlangUI but I don't know how to do it. In python I just type pip and it works, but in D I don't know how to do it. Can anyone help me?

Re: Exception slipping through the catch block?

2018-11-08 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Nov 08, 2018 at 01:28:47PM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: > On Thursday, November 8, 2018 10:55:45 AM MST Stanislav Blinov via > Digitalmars-d-learn wrote: > > On Thursday, 8 November 2018 at 16:13:55 UTC, Mike Parker wrote: [...] > > > No, you should never catch

Re: scoped classes and dependency inversion

2018-11-08 Thread Sjoerd Nijboer via Digitalmars-d-learn
On Thursday, 8 November 2018 at 16:31:26 UTC, Neia Neutuladh wrote: I believe what you need to do is pass a factory function into the constructor. This is a bit awkward. Yep, but I want a "nice and descriptive syntax" for it. Anyway, here's some code to make it work. It's kind of ugly. ---

Re: Exception slipping through the catch block?

2018-11-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 8, 2018 10:55:45 AM MST Stanislav Blinov via Digitalmars-d-learn wrote: > On Thursday, 8 November 2018 at 16:13:55 UTC, Mike Parker wrote: > > On Thursday, 8 November 2018 at 15:50:38 UTC, helxi wrote: > >> Although it's pretty frustrating, isn't it? Now not only I > >> have

Re: Exception slipping through the catch block?

2018-11-08 Thread Stanislav Blinov via Digitalmars-d-learn
On Thursday, 8 November 2018 at 16:13:55 UTC, Mike Parker wrote: On Thursday, 8 November 2018 at 15:50:38 UTC, helxi wrote: Although it's pretty frustrating, isn't it? Now not only I have to think about catching exceptions but also about Errors, and have no guarantee that I have everything

Re: Creating InputRanges from strings, files etc.

2018-11-08 Thread Vinay Sajip via Digitalmars-d-learn
On Thursday, 8 November 2018 at 16:41:50 UTC, Steven Schveighoffer wrote: I did this in a run.dlang.org playground: pragma(msg, ElementType!(typeof(b))); pragma(msg, ElementType!(typeof(d))); I get: immutable(ubyte) ubyte Which means they aren't the same type, and they don't define the same

Re: Creating InputRanges from strings, files etc.

2018-11-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 11/8/18 11:15 AM, Vinay Sajip wrote: On Thursday, 8 November 2018 at 14:38:37 UTC, Paul Backus wrote: To pass these ranges around using the `InputRange` interface, use `inputRangeObject` to wrap them:     InputRange!ubyte r3 = inputRangeObject(r1);     InputRange!(immutable(ubyte)) r4 =

Re: scoped classes and dependency inversion

2018-11-08 Thread Neia Neutuladh via Digitalmars-d-learn
On Thu, 08 Nov 2018 11:04:19 +, Sjoerd Nijboer wrote: > I'm trying to invert the dependency from the classes `Bar -> Foo` to > `Foo -> IFoo <- Bar` at compile time. > > I do want `Foo's` to be embedded into `Bar` These goals are a *little* at odds with each other; having a scoped!Foo puts

Re: Creating InputRanges from strings, files etc.

2018-11-08 Thread Alex via Digitalmars-d-learn
On Thursday, 8 November 2018 at 16:15:25 UTC, Vinay Sajip wrote: On Thursday, 8 November 2018 at 14:38:37 UTC, Paul Backus wrote: To pass these ranges around using the `InputRange` interface, use `inputRangeObject` to wrap them: InputRange!ubyte r3 = inputRangeObject(r1);

Re: Creating InputRanges from strings, files etc.

2018-11-08 Thread Vinay Sajip via Digitalmars-d-learn
On Thursday, 8 November 2018 at 14:38:37 UTC, Paul Backus wrote: To pass these ranges around using the `InputRange` interface, use `inputRangeObject` to wrap them: InputRange!ubyte r3 = inputRangeObject(r1); InputRange!(immutable(ubyte)) r4 = inputRangeObject(r2); I did a bit more

Re: Exception slipping through the catch block?

2018-11-08 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 8 November 2018 at 15:50:38 UTC, helxi wrote: On Thursday, 8 November 2018 at 15:41:11 UTC, Adam D. Ruppe wrote: On Thursday, 8 November 2018 at 15:08:40 UTC, helxi wrote: Shouldn't the catch block in the function catch the exception? You caught Exception, but it throws Error.

Re: scoped classes and dependency inversion

2018-11-08 Thread Neia Neutuladh via Digitalmars-d-learn
On Thu, 08 Nov 2018 12:45:57 +, Alex wrote: > Hmm... not sure, if I got your idea... Do you think about something like > this? The point is dependency inversion. The class shouldn't need to know how to build its dependencies; it should leave that to other code. The fact that you can use the

Re: Exception slipping through the catch block?

2018-11-08 Thread Bauss via Digitalmars-d-learn
On Thursday, 8 November 2018 at 15:50:38 UTC, helxi wrote: On Thursday, 8 November 2018 at 15:41:11 UTC, Adam D. Ruppe wrote: On Thursday, 8 November 2018 at 15:08:40 UTC, helxi wrote: Shouldn't the catch block in the function catch the exception? You caught Exception, but it throws Error.

Re: Exception slipping through the catch block?

2018-11-08 Thread helxi via Digitalmars-d-learn
On Thursday, 8 November 2018 at 15:41:11 UTC, Adam D. Ruppe wrote: On Thursday, 8 November 2018 at 15:08:40 UTC, helxi wrote: Shouldn't the catch block in the function catch the exception? You caught Exception, but it throws Error. They have separate inheritance trees. The common ancestor

Re: Exception slipping through the catch block?

2018-11-08 Thread Alex via Digitalmars-d-learn
On Thursday, 8 November 2018 at 15:50:38 UTC, helxi wrote: Thanks. Although it's pretty frustrating, isn't it? Now not only I have to think about catching exceptions but also about Errors, and have no guarantee that I have everything under control. Isn't it rather the case, that you have

Re: scoped classes and dependency inversion

2018-11-08 Thread Alex via Digitalmars-d-learn
On Thursday, 8 November 2018 at 15:11:16 UTC, Sjoerd Nijboer wrote: Except if you want to pass a parameter to TFoo it'll become a mess. And I expecially don't want it to become messy. I thought of this case... But passing the argument to TFoo directly while constructing Bar is messier, I

Re: Exception slipping through the catch block?

2018-11-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 8 November 2018 at 15:08:40 UTC, helxi wrote: Shouldn't the catch block in the function catch the exception? You caught Exception, but it throws Error. They have separate inheritance trees. The common ancestor is actually Throwable, though note that there is no guarantee that

Re: Creating InputRanges from strings, files etc.

2018-11-08 Thread Vinay Sajip via Digitalmars-d-learn
On Thursday, 8 November 2018 at 14:38:37 UTC, Paul Backus wrote: You can iterate through a file one ubyte at a time using `byChunk` and `joiner`: auto r1 = stdin.byChunk(1024).joiner; assert(is(typeof(r1.front) == ubyte)); You can iterate through a string one ubyte at a time using

Re: scoped classes and dependency inversion

2018-11-08 Thread Sjoerd Nijboer via Digitalmars-d-learn
On Thursday, 8 November 2018 at 12:45:57 UTC, Alex wrote: Hmm... not sure, if I got your idea... Do you think about something like this? **snip** class Bar(TFoo) if(is(TFoo : IFoo)) { typeof(scoped!TFoo()) _foo; this() { _foo = scoped!TFoo();

Re: A `dub test` problem...

2018-11-08 Thread duge via Digitalmars-d-learn
On Thursday, 8 November 2018 at 15:01:04 UTC, duge wrote: WTF, why i got a this modal messagebox when i trying `dub test --build=unittest` ?? i just captured messagebox and using OCR, and that's it. here:

Exception slipping through the catch block?

2018-11-08 Thread helxi via Digitalmars-d-learn
How does exception work? I am inside a function that calls a constructor. Inside the constructor, an exception is thrown. However even though I have wrapped the body of the function inside a try/catch block, the program crashes from inside that constructor. Shouldn't the catch block in the

A `dub test` problem...

2018-11-08 Thread duge via Digitalmars-d-learn
WTF, why i got a this modal messagebox when i trying `dub test --build=unittest` ?? i just captured messagebox and using OCR, and that's it. here: core.exceptionAssertError@source\dub\internal\vibecompat\core\log.d(85): Enforcement failed (No error)

Re: Creating InputRanges from strings, files etc.

2018-11-08 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 8 November 2018 at 13:58:55 UTC, Vinay Sajip wrote: Excuse my ignorance, but from looking at the documentation on std.range and a quick skim of the guides mentioned there near the top, I can't see what the simple way is of creating an InputRange!(ubyte) from strings, files etc. I

Re: Creating InputRanges from strings, files etc.

2018-11-08 Thread rikki cattermole via Digitalmars-d-learn
On 09/11/2018 2:58 AM, Vinay Sajip wrote: Excuse my ignorance, but from looking at the documentation on std.range and a quick skim of the guides mentioned there near the top, I can't see what the simple way is of creating an InputRange!(ubyte) from strings, files etc. I would have expected to

Creating InputRanges from strings, files etc.

2018-11-08 Thread Vinay Sajip via Digitalmars-d-learn
Excuse my ignorance, but from looking at the documentation on std.range and a quick skim of the guides mentioned there near the top, I can't see what the simple way is of creating an InputRange!(ubyte) from strings, files etc. I would have expected to find something in the DLang Tour about

Re: scoped classes and dependency inversion

2018-11-08 Thread Alex via Digitalmars-d-learn
On Thursday, 8 November 2018 at 11:04:19 UTC, Sjoerd Nijboer wrote: I'm trying to invert the dependency from the classes `Bar -> Foo` to `Foo -> IFoo <- Bar` at compile time. I do want `Foo's` to be embedded into `Bar` So silly me tried something like this: [...] So how can I delay the

Re: new returning the same memory....

2018-11-08 Thread Daniel Kozak via Digitalmars-d-learn
Did you try disable gc? import core.memory : GC; GC.disable; aclass a = new aclass(); I believe that your aclass go out of scope and there is no active reference to this so GC can collected it and reuse its memory On Thu, Nov 8, 2018 at 12:50 PM Codifies via Digitalmars-d-learn <

Re: new returning the same memory....

2018-11-08 Thread drug via Digitalmars-d-learn
08.11.2018 14:48, Codifies пишет: On Thursday, 8 November 2018 at 11:46:44 UTC, Codifies wrote: when creating a new instance of a class aclass a = new aclass(); I was under the impression that this created a new chunk of memory on the heap... however I'm trying to create this class

Re: new returning the same memory....

2018-11-08 Thread Codifies via Digitalmars-d-learn
On Thursday, 8 November 2018 at 11:46:44 UTC, Codifies wrote: when creating a new instance of a class aclass a = new aclass(); I was under the impression that this created a new chunk of memory on the heap... however I'm trying to create this class instance in another classes method, I

new returning the same memory....

2018-11-08 Thread Codifies via Digitalmars-d-learn
when creating a new instance of a class aclass a = new aclass(); I was under the impression that this created a new chunk of memory on the heap... however I'm trying to create this class instance in another classes method, I also need to store a pointer to this newly created instance in

scoped classes and dependency inversion

2018-11-08 Thread Sjoerd Nijboer via Digitalmars-d-learn
I'm trying to invert the dependency from the classes `Bar -> Foo` to `Foo -> IFoo <- Bar` at compile time. I do want `Foo's` to be embedded into `Bar` So silly me tried something like this: module main; ```import std.stdio; import std.typecons; void main() { auto bar = new

Re: Is this a bug? +goto

2018-11-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 8, 2018 2:34:34 AM MST Michelle Long via Digitalmars- d-learn wrote: > Obviously, but that is not the case I mentioned. You can assume > that I know how scopes work. No need to assume everyone that > shows two cases that you have to bring up an unrelated case as a > potential

Re: is opOpAssign returning a value less than ideal ?

2018-11-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 8, 2018 2:15:43 AM MST Codifies via Digitalmars-d-learn wrote: > On Thursday, 8 November 2018 at 06:01:57 UTC, Jonathan M Davis > > wrote: > > On Wednesday, November 7, 2018 10:45:07 PM MST Jonathan M Davis > > > > via Digitalmars-d-learn wrote: > >> [...] > > > > Rereading

Re: Is this a bug? +goto

2018-11-08 Thread Michelle Long via Digitalmars-d-learn
On Thursday, 8 November 2018 at 06:56:14 UTC, Jonathan M Davis wrote: On Wednesday, November 7, 2018 10:50:29 PM MST Michelle Long via Digitalmars-d-learn wrote: On Thursday, 8 November 2018 at 02:22:42 UTC, Jonathan M Davis wrote: > On Wednesday, November 7, 2018 1:03:47 PM MST Michelle Long

Re: is opOpAssign returning a value less than ideal ?

2018-11-08 Thread Codifies via Digitalmars-d-learn
On Thursday, 8 November 2018 at 06:01:57 UTC, Jonathan M Davis wrote: On Wednesday, November 7, 2018 10:45:07 PM MST Jonathan M Davis via Digitalmars-d-learn wrote: [...] Rereading what you wrote, are you asking whether it's reasonable to return a value instead of a reference? Personally, I