Re: Should D file end with newline?

2019-02-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, February 9, 2019 2:19:27 PM MST Victor Porton via Digitalmars- d-learn wrote: > ISO C++ specifies that the C++ file must end with a newline. > > Should D file end with newline, too? No, there is no need to end D files with a newline. I would guess that the vast majority of D files

Re: Is it possible to modify shared struct array in a function.

2019-02-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, February 8, 2019 4:27:44 AM MST Eduard Staniloiu via Digitalmars- d-learn wrote: > On Friday, 8 February 2019 at 06:55:15 UTC, Jerry wrote: > > On Friday, 8 February 2019 at 04:51:08 UTC, Sudhi wrote: > >> On Friday, 8 February 2019 at 04:30:23 UTC, Arun > >> > >> Chandrasekaran wrote:

Re: Singleton in Action?

2019-02-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, February 3, 2019 2:41:48 AM MST Ron Tarrant via Digitalmars-d- learn wrote: > On Saturday, 2 February 2019 at 19:40:25 UTC, Andre Pany wrote: > > https://rosettacode.org/wiki/Singleton#D > > Do you know if this is for a current version of D? The compiler > is choking on the import

Re: Implement Interface Using Super

2019-01-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 28, 2019 10:41:55 PM MST Meta via Digitalmars-d-learn wrote: > On Monday, 28 January 2019 at 22:17:56 UTC, Steven Schveighoffer > > wrote: > > On 1/28/19 3:28 PM, Jonathan Levi wrote: > >> On Sunday, 27 January 2019 at 09:31:46 UTC, bauss wrote: > >>> On Sunday, 27 January 2019

Re: opEquals() non-standard return type

2019-01-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 23, 2019 8:19:06 AM MST Jacob Shtokolov via Digitalmars-d-learn wrote: > Hi, > > I'm trying to check whether it's possible to implement Python's > SQLAlchemy-like query syntax in D, but I get stuck a bit. > > Here is a simple example of what I want to achieve: > > ``` > auto

Re: How to ensure string compatibility In D?

2019-01-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 23, 2019 5:42:55 AM MST FrankLike via Digitalmars-d- learn wrote: > On Wednesday, 23 January 2019 at 10:44:51 UTC, Jonathan M Davis > > wrote: > > On Tuesday, January 22, 2019 2:49:00 PM MST bauss via > > Digitalmars-d-learn wrote: > > > > toUTFz is the generic solution.

Re: How to ensure string compatibility In D?

2019-01-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 22, 2019 2:49:00 PM MST bauss via Digitalmars-d-learn wrote: > On Tuesday, 22 January 2019 at 19:14:43 UTC, Jonathan M Davis > > wrote: > > On Tuesday, January 22, 2019 12:05:32 PM MST Stefan Koch via > > > > Digitalmars-d- learn wrote: > >> On Tuesday, 22 January 2019 at

Re: How to ensure string compatibility In D?

2019-01-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 22, 2019 12:05:32 PM MST Stefan Koch via Digitalmars-d- learn wrote: > On Tuesday, 22 January 2019 at 16:47:45 UTC, FrankLike wrote: > > On Tuesday, 22 January 2019 at 16:18:17 UTC, Adam D. Ruppe > > > > wrote: > >> Use "mystring"w, notice the w after the closing quote. > > > >

Re: Compiling to 68K processor (Maybe GDC?)

2019-01-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 21, 2019 10:08:23 AM MST Johan Engelen via Digitalmars-d- learn wrote: > On Saturday, 19 January 2019 at 17:45:41 UTC, Patrick Schluter > > wrote: > > Afaict NULL pointer derefernecing must fault for D to be > > "usable". At least all code is written with that assumption. > >

Re: Compiling to 68K processor (Maybe GDC?)

2019-01-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, January 19, 2019 10:45:41 AM MST Patrick Schluter via Digitalmars-d-learn wrote: > On Saturday, 19 January 2019 at 12:54:28 UTC, rikki cattermole > > wrote: > > On 20/01/2019 1:38 AM, Edgar Vivar wrote: > >> Hi, > >> > >> I have a project aiming to old 68K processor. While I don't >

Re: Deprecation: foreach: loop index implicitly converted from size_t to int

2019-01-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 18, 2019 8:34:22 AM MST Michael via Digitalmars-d-learn wrote: > On Friday, 18 January 2019 at 13:29:29 UTC, Adam D. Ruppe wrote: > > On Friday, 18 January 2019 at 12:27:17 UTC, Michael wrote: > >> This, to be, looks like quite the explicit conversion, no? > > > > Yeah, I

Re: Alternative to Interfaces

2019-01-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 18, 2019 8:08:47 AM MST Kagamin via Digitalmars-d-learn wrote: > On Friday, 18 January 2019 at 00:08:00 UTC, 1001Days wrote: > > It works, but I have two questions regarding its efficacy: is > > it viable in the long run, and is it now possible to use > > delegates without the

Re: Runtime heterogeneous collections?

2019-01-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 17, 2019 1:21:41 AM MST Dukc via Digitalmars-d-learn wrote: > On Thursday, 17 January 2019 at 02:27:20 UTC, Neia Neutuladh > > wrote: > > 1. Make a wrapper class. Now you can store Object[], or you can > > make a > > base class or base interface and use that. > > 2. Use

Re: Compile time opAssign/@property constraints

2019-01-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 4, 2019 4:50:30 AM MST Jacob Shtokolov via Digitalmars-d- learn wrote: > On Friday, 4 January 2019 at 11:41:59 UTC, Simen Kjærås wrote: > > The thing is, compile-time tests like static if and static > > assert can only test values that are known at compile-time, and > > are for

Re: DIP 1000 and classes

2019-01-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, January 3, 2019 3:28:35 AM MST Nordlöw via Digitalmars-d-learn wrote: > How does DIP 1000 treat the lifetime scoped class parameters and > containers of classes? scope isn't transitive, and putting an object inside a container would be escaping it, which would violate scope. So, you

Re: Qualified class opEquals()

2018-12-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 25, 2018 7:27:39 AM MST Per Nordlöw via Digitalmars-d- learn wrote: > On Tuesday, 25 December 2018 at 00:32:55 UTC, Paul Backus wrote: > > No, because equality comparison between classes lowers to > > `object.opEquals` [1], which takes both parameters as `Object`. > > This is

Re: Temporary @trusted scope

2018-12-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, December 19, 2018 1:19:42 AM MST rikki cattermole via Digitalmars-d-learn wrote: > On 19/12/2018 7:11 PM, Jonathan M Davis wrote: > > Really? I would have thought that that would be a pretty obvious > > optimization (especially if inlining is enabled). > > Assembly doesn't lie. I'm

Re: Checking if CTFE is used?

2018-12-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 18, 2018 9:20:11 AM MST berni via Digitalmars-d-learn wrote: > On Tuesday, 18 December 2018 at 14:32:29 UTC, Adam D. Ruppe wrote: > > CTFE is used if and only if it MUST be used by context. That's > > a runtime function, so no ctfe. > > > > Do something like: > > > > int[4]

Re: Temporary @trusted scope

2018-12-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 18, 2018 5:42:12 AM MST rikki cattermole via Digitalmars-d-learn wrote: > On 19/12/2018 1:34 AM, Per Nordlöw wrote: > > On Tuesday, 18 December 2018 at 10:42:51 UTC, Jonathan M Davis wrote: > >> Unfortunately, D does not currently have a way to do that. Only > >> functions

Re: Temporary @trusted scope

2018-12-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 18, 2018 3:14:50 AM MST Per Nordlöw via Digitalmars-d- learn wrote: > What's the preferred way of creating a temporary @trusted scope > without writing a separate function? > > Similar to Rust's > > unsafe { /* unsafe stuff here */ } Unfortunately, D does not currently have

Re: Shared static this() not executed for unittest

2018-12-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, December 16, 2018 12:53:43 PM MST Steven Schveighoffer via Digitalmars-d-learn wrote: > On 12/15/18 5:14 PM, Jonathan M Davis wrote: > > On Saturday, December 15, 2018 10:27:36 AM MST Neia Neutuladh via > > > > Digitalmars-d-learn wrote: > >> On Sat, 15 Dec 2018 17:19:05 +, Timoses

Re: Shared static this() not executed for unittest

2018-12-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, December 15, 2018 10:27:36 AM MST Neia Neutuladh via Digitalmars-d-learn wrote: > On Sat, 15 Dec 2018 17:19:05 +, Timoses wrote: > > Running `dub test` will output: > > Running ./unit-test-library writeln: unittest All unit tests have been > > run successfully. > > > > Why is the

Re: Bug in shifting

2018-12-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, December 13, 2018 6:56:33 PM MST Steven Schveighoffer via Digitalmars-d-learn wrote: > On 12/13/18 7:16 PM, Michelle Long wrote: > > I've noticed the compiler is not throwing up errors and warnings like it > > used to: > > > > I thought D required breaks for cases? Seems it doesn't

Re: OT (Was: Re: is(ElementType!(char[2]) == dchar - why?)

2018-12-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 11, 2018 2:11:49 PM MST H. S. Teoh via Digitalmars-d- learn wrote: > On Tue, Dec 11, 2018 at 09:02:41PM +, bauss via Digitalmars-d-learn wrote: > > On Tuesday, 11 December 2018 at 18:10:48 UTC, H. S. Teoh wrote: > [...] > > > > Autodecoding raises its ugly head again. :-/

Re: Working with ranges

2018-12-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 7, 2018 8:46:11 PM MST Adam D. Ruppe via Digitalmars-d- learn wrote: > On Saturday, 8 December 2018 at 03:37:56 UTC, Murilo wrote: > > Hi guys, I have created an array of strings with "string[12] ps > > string[12] isn't a range, but string[] is. > > Try passing `ps[]` to the

Re: Writing Program Without main Function

2018-12-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 7, 2018 2:42:33 PM MST Samir via Digitalmars-d-learn wrote: > Ok. Upon further investigation, I think I see what is going on. > Most of the repos I am skimming are for this year's Advent of > Code. They structure their repo with an `app.d` file which does > contain a `main`

Re: Writing Program Without main Function

2018-12-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 7, 2018 2:02:59 PM MST Samir via Digitalmars-d-learn wrote: > Is it possible to write and execute a D program without a main > function? > > Most of my programs will start with some `import` statements, > followed by any functions and then ending with the `main` > function

Re: int[] as constructor

2018-12-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 4, 2018 3:17:04 PM MST jmh530 via Digitalmars-d-learn wrote: > I've noticed that I can use int like a constructor, as in: > int x = int(1); > but I can't do the same thing with slices > int[] y = int[]([1, 2]); > > Is there something I'm missing here or is this a

Re: .dup vs operation on all elements

2018-12-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 3, 2018 1:07:24 PM MST Goksan via Digitalmars-d-learn wrote: > Are there any differences between these 2 methods of copying > elements? > > double[] array = [ 1, 20, 2, 30, 7, 11 ]; > > // Non dup > double[6] bracket_syntax_dup = array; > bracket_syntax_dup[] = array; >

Re: gcc 9 vs. dmd?

2018-11-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 30, 2018 2:43:41 AM MST welkam via Digitalmars-d-learn wrote: > On Friday, 30 November 2018 at 04:47:26 UTC, Andrew Pennebaker > > wrote: > > gcc is currently required for dmd on FreeBSD, as dmd links to > > libstdc++. > > Parts of dmd are still written in C++ but most of it

Re: version(StdDoc)

2018-11-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 24, 2018 10:41:56 PM MST H. S. Teoh via Digitalmars-d- learn wrote: > On Sat, Nov 24, 2018 at 05:48:16PM +, Stanislav Blinov via Digitalmars-d-learn wrote: > > On Saturday, 24 November 2018 at 17:43:35 UTC, Jonathan M Davis wrote: > > > I'm still inclined to think though

Re: version(StdDoc)

2018-11-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 24, 2018 9:28:47 AM MST Stanislav Blinov via Digitalmars-d-learn wrote: > On Saturday, 24 November 2018 at 07:00:31 UTC, Jonathan M Davis > > wrote: > > [not legal] > > > > enum Foo > > { > > > > a, > > b, > > version(linux) c = 42, > > else version(Windows)

Re: version(StdDoc)

2018-11-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 23, 2018 11:22:24 PM MST Neia Neutuladh via Digitalmars- d-learn wrote: > On Fri, 23 Nov 2018 21:43:01 -0700, Jonathan M Davis wrote: > > A solution like that might work reasonably well, but you still > > have the problem of what to do when a symbol is documented in multiple >

Re: D is supposed to compile fast.

2018-11-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 23, 2018 11:13:24 AM MST H. S. Teoh via Digitalmars-d- learn wrote: > All in all, though, the fact that we're complaining about extra seconds > in compilation times still does show just how fast D compilation can be. > In the old days, compiling large C++ codebases usually

Re: version(StdDoc)

2018-11-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 23, 2018 7:55:04 PM MST H. S. Teoh via Digitalmars-d- learn wrote: > Adam does have a very good point about showing all alternatives to docs, > though. Arguably, that's what ddoc *should* do. If the programmer > wrote a ddoc comment in the code, it probably should be

Re: version(StdDoc)

2018-11-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 23, 2018 2:47:51 PM MST Tony via Digitalmars-d-learn wrote: > In std.compiler there is this code: > > /// Which vendor produced this compiler. > version(StdDdoc) Vendor vendor; > else version(DigitalMars) Vendor vendor = Vendor.digitalMars; > else

Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 21, 2018 3:24:06 PM MST Johan Engelen via Digitalmars-d-learn wrote: > On Wednesday, 21 November 2018 at 07:47:14 UTC, Jonathan M Davis > > wrote: > > IMHO, requiring something in the spec like "it must segfault > > when dereferencing null" as has been suggested before is >

Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 20, 2018 11:04:08 AM MST Johan Engelen via Digitalmars- d-learn wrote: > On Tuesday, 20 November 2018 at 03:38:14 UTC, Jonathan M Davis > > wrote: > > For @safe to function properly, dereferencing null _must_ be > > guaranteed to be memory safe, and for dmd it is, since it

Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, November 20, 2018 8:38:40 AM MST Kagamin via Digitalmars-d-learn wrote: > On Monday, 19 November 2018 at 21:23:31 UTC, Jordi Gutiérrez > > Hermoso wrote: > > When I was first playing with D, I managed to create a segfault > > by doing `SomeClass c;` and then trying do something with

Re: Why does nobody seem to think that `null` is a serious problem in D?

2018-11-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, November 19, 2018 5:30:00 PM MST Steven Schveighoffer via Digitalmars-d-learn wrote: > On 11/19/18 7:21 PM, Jordi Gutiérrez Hermoso wrote: > > On Monday, 19 November 2018 at 21:52:47 UTC, Steven Schveighoffer wrote: > >> A null pointer dereference is an immediate error, and it's also a

Re: opDispatch doesn't play nice with inheritance

2018-11-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 17, 2018 11:09:51 PM MST Carl Sturtivant via Digitalmars-d-learn wrote: > On Thursday, 15 November 2018 at 19:01:45 UTC, Ali Çehreli wrote: > > On 11/15/2018 09:14 AM, Carl Sturtivant wrote: > > > opDispatch is special in that it allows for functions to be > > > > added to a

Re: Problem with opBinary

2018-11-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 14, 2018 2:54:27 AM MST realhet via Digitalmars-d- learn wrote: > Hi, > > Just a little weird thing I noticed and don't know why it is: > > I have a FilePath struct and I wanted to make it work with the > "~" operator and an additional string. > > So I've created a global

Re: Why is stdio ... stdio?

2018-11-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 10, 2018 7:51:36 PM MST Adam D. Ruppe via Digitalmars- d-learn wrote: > On Saturday, 10 November 2018 at 23:29:12 UTC, Jonathan M Davis > > wrote: > > The fact that they got added to ddoc just further degrades it > > as a proper, macro-based markup language. > > The backticks

Re: Why is stdio ... stdio?

2018-11-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 10, 2018 6:53:14 AM MST Kagamin via Digitalmars-d- learn wrote: > On Friday, 9 November 2018 at 09:11:37 UTC, Jonathan M Davis > > wrote: > > No, I didn't. I just used underscores, which has been used with > > plain text for emphasis for decades. Supporting markdown, would >

Re: Using decodeFront with a generalised input range

2018-11-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 9, 2018 5:22:27 AM MST Vinay Sajip via Digitalmars-d- learn wrote: > On Friday, 9 November 2018 at 11:24:42 UTC, Jonathan M Davis > > wrote: > > decode and decodeFront are for converting a UTF code unit to a > > Unicode code point. So, you're taking UTF-8 code unit (char), > >

Re: Using decodeFront with a generalised input range

2018-11-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 9, 2018 3:45:49 AM MST Vinay Sajip via Digitalmars-d- learn wrote: > On Friday, 9 November 2018 at 10:26:46 UTC, Dennis wrote: > > On Friday, 9 November 2018 at 09:47:32 UTC, Vinay Sajip wrote: > >> std.utf.decodeFront(Flag useReplacementDchar = > >> No.useReplacementDchar,

Re: Why is stdio ... stdio?

2018-11-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 9, 2018 1:27:44 AM MST Kagamin via Digitalmars-d-learn wrote: > On Friday, 9 November 2018 at 06:42:37 UTC, Jonathan M Davis > > wrote: > > Honestly, having markdown in messages being typical would be > > _really_ annoying for those of us not using the web interface, > >

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: 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 > > > > Digi

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: 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: &

Re: Is this a bug? +goto

2018-11-07 Thread Jonathan M Davis via Digitalmars-d-learn
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 via > > > > Digitalmars- d-learn wrote: > >> Don't let their

Re: is opOpAssign returning a value less than ideal ?

2018-11-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 7, 2018 10:45:07 PM MST Jonathan M Davis via Digitalmars-d-learn wrote: > On Wednesday, November 7, 2018 9:28:19 PM MST Codifies via Digitalmars-d- > > learn wrote: > > I noticed that opOpAsign allows you to return a value... > > > > this means I

Re: is opOpAssign returning a value less than ideal ?

2018-11-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 7, 2018 9:28:19 PM MST Codifies via Digitalmars-d- learn wrote: > I noticed that opOpAsign allows you to return a value... > > this means I can do this (return a node from my list class when > adding a new node) > ``` > anode = alist ~= > ``` > to me this looks a little

Re: Is this a bug? +goto

2018-11-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 7, 2018 1:03:47 PM MST Michelle Long via Digitalmars- d-learn wrote: > Don't let their psychobabble fool you. They are wrong and you > were right from the start. ... > Case A: > { > if (true) goto X; > int x; > } > X: > > > Case B: > { > if (true) goto X; >

Re: Is this a bug? +goto

2018-11-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, November 5, 2018 7:55:46 PM MST MatheusBN via Digitalmars-d-learn wrote: > On Tuesday, 6 November 2018 at 01:55:04 UTC, Jonathan M Davis > > wrote: > >> And I found a bit strange that in such code, since "x" is > >> never used, why it isn't skipped. > > > > It's skipped right over. The

Re: Is this a bug? +goto

2018-11-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, November 5, 2018 5:33:56 PM MST MatheusBN via Digitalmars-d-learn wrote: > On Tuesday, 6 November 2018 at 00:14:26 UTC, Jonathan M Davis > > wrote: > > On Monday, November 5, 2018 4:54:59 PM MST MatheusBN via > > > > Digitalmars-d-learn wrote: > >> Hi, > >> > >> I posted this in

Re: Is this a bug? +goto

2018-11-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, November 5, 2018 4:54:59 PM MST MatheusBN via Digitalmars-d-learn wrote: > Hi, > > I posted this in another thread but without any response. > > This code: > > void main(){ > goto Q; > int x; > Q: > writeln("a"); > } > > Gives me this error: "source_file.d(4):

Re: Why use while if only iterating once ?

2018-11-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, November 3, 2018 3:03:16 PM MDT Venkat via Digitalmars-d-learn wrote: > while (1) > { > FLAGS f; > switch (*p) > { > case 'U': > case 'u': > f = FLAGS.unsigned; > goto

Re: anyway to set a const object after the fact?

2018-10-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 30, 2018 2:18:15 AM MDT Laurent Tréguier via Digitalmars-d-learn wrote: > On Monday, 29 October 2018 at 21:50:32 UTC, aliak wrote: > > Hi, so if you have this piece of code: > > > > struct C { > > > > void f() { > > > > string[] others; > > const string[] restArgs; >

Re: how to make '==' safe for classes?

2018-10-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 28, 2018 12:56:10 PM MDT ikod via Digitalmars-d-learn wrote: > On Sunday, 28 October 2018 at 18:00:06 UTC, Stanislav Blinov > > wrote: > > On Sunday, 28 October 2018 at 12:38:12 UTC, ikod wrote: > >> and object.opEquals(a,b) do not inherits safety from class C > >> properties,

Re: how to make '==' safe for classes?

2018-10-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 28, 2018 6:38:12 AM MDT ikod via Digitalmars-d-learn wrote: > Hello > > How to make this code to compile? My goal is safe(not @trusted) > longFunction(). > > > --- > class C > { > override bool opEquals(Object o) const @safe > { > return true; > } > } >

Re: how to make '==' safe for classes?

2018-10-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 28, 2018 12:17:41 PM MDT Neia Neutuladh via Digitalmars- d-learn wrote: > On Sun, 28 Oct 2018 18:00:06 +, Stanislav Blinov wrote: > > On Sunday, 28 October 2018 at 12:38:12 UTC, ikod wrote: > >> and object.opEquals(a,b) do not inherits safety from class C > >> properties,

Re: Error: non-shared method core.sync.condition.Condition.notify is not callable using a shared object

2018-10-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, October 18, 2018 4:50:18 AM MDT Paolo Invernizzi via Digitalmars-d-learn wrote: > There's a rational behind the fact that there's not a 'shared' > version of notify/wait method in Condition? > > Thanks, > Paolo The original author of the stuff in core.sync didn't want to update it

Re: custom sorting of lists ?

2018-10-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, October 13, 2018 6:52:05 PM MDT Steven Schveighoffer via Digitalmars-d-learn wrote: > You can't quick-sort a list. You can merge sort it, and it's O(nlgn). > > I'll work on getting a sort routine into Phobos for it, but I don't know > what the appropriate location for it is, as a

Re: Why are 2-D arrays reversed?

2018-10-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, October 10, 2018 4:26:40 PM MDT Chris Katko via Digitalmars-d- learn wrote: > On Wednesday, 10 October 2018 at 16:00:42 UTC, Steven > > Schveighoffer wrote: > > On 10/10/18 9:22 AM, Chris Katko wrote: > >> int[][] data = > >> > >> [ > >> [1, 0, 1, 0, 0], > >>

Re: Compile time sequences

2018-10-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, October 4, 2018 5:44:55 AM MDT drug via Digitalmars-d-learn wrote: > I was incorrect with description of the problem. The problem is that > there is no simple way to distinct types and symbols if symbols are > private. Because private symbol is not accessible you can not get any >

Re: Dlang tour - Unittesting example

2018-10-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 2, 2018 3:59:28 AM MDT bauss via Digitalmars-d-learn wrote: > On Tuesday, 2 October 2018 at 04:13:01 UTC, Joe wrote: > > There appears to be a problem with the example at > > > > https://tour.dlang.org/tour/en/gems/unittesting > > > > If compiled with -unittest, the resulting

Re: How to convert this function into a template ?

2018-10-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 2, 2018 6:09:53 AM MDT Vinod K Chandran via Digitalmars- d-learn wrote: > On Tuesday, 2 October 2018 at 11:49:06 UTC, Jonathan M Davis > > wrote: > > Why do you have a function for that? All you need to do is use > > the append operator. e.g. > > > > x ~= value; > > > > -

Re: How to convert this function into a template ?

2018-10-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, October 2, 2018 5:40:18 AM MDT Vinod K Chandran via Digitalmars- d-learn wrote: > Hi all, > I have a function and i want to convert this into a template so > that i can use this function for more than one data type. > This is my function. > ```D > void ArrayAdd( ref int[] x, int value)

Re: Can I create static c callable library?

2018-09-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 27, 2018 6:16:13 AM MDT Atila Neves via Digitalmars- d-learn wrote: > On Tuesday, 25 September 2018 at 14:13:50 UTC, Jacob Carlborg > > wrote: > > On Tuesday, 25 September 2018 at 12:05:21 UTC, Jonathan M Davis > > > > wrote: > >> If you use -betterC, then it's trivial,

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 27, 2018 2:44:25 AM MDT Chad Joan via Digitalmars-d- learn wrote: > The spec seems to have the homogeneous cases covered: classes > with classes or structs with structs. What I'm more worried > about is stuff like when you have a class compared to a struct or > builtin

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 27, 2018 1:41:23 AM MDT Chad Joan via Digitalmars-d- learn wrote: > On Thursday, 27 September 2018 at 05:12:06 UTC, Jonathan M Davis > This is also reminding me of how it's always bugged me that there > isn't a way to operator overload opEquals with a static method > (or

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, September 26, 2018 10:20:58 PM MDT Chad Joan via Digitalmars- d-learn wrote: > On Wednesday, 26 September 2018 at 23:32:36 UTC, Jonathan M Davis > > wrote: > > On Wednesday, September 26, 2018 3:24:07 PM MDT Adam D. Ruppe > > > > via Digitalmars-d-learn wrote: > >> Object.factory

Re: Is there a way to use Object.factory with templated classes? Or some way to construct templated classes given RTTI of an instance?

2018-09-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, September 26, 2018 3:24:07 PM MDT Adam D. Ruppe via Digitalmars-d-learn wrote: > Object.factory kinda sux and I'd actually like to remove it > (among other people). There's no plan to actually do that, but > still, just on principle I want to turn people away. While there may not

Re: Can I create static c callable library?

2018-09-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 25, 2018 5:03:11 AM MDT John Burton via Digitalmars-d- learn wrote: > I need to write a library to statically link into a c program. > Can I write this library in D? > Will I be able to use proper D abilities like gc? Obviously the > public interface will need to be basic c

Re: Is it possible to translate this API's C headers?

2018-09-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 18, 2018 7:39:40 AM MDT Atila Neves via Digitalmars-d- learn wrote: > On Monday, 17 September 2018 at 19:13:06 UTC, Jonathan M Davis > > wrote: > > On Monday, September 17, 2018 7:43:21 AM MDT Kagamin via > > > > Digitalmars-d-learn wrote: > >> try dpp

Re: Is it possible to translate this API's C headers?

2018-09-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 17, 2018 7:43:21 AM MDT Kagamin via Digitalmars-d-learn wrote: > try dpp https://github.com/atilaneves/dpp Since according to Mike's post, it's C++ code, dpp wouldn't help, because it currently only supports C and not C++. - Jonathan M Davis

Re: Pass 'this' as reference

2018-09-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, September 15, 2018 11:44:05 AM MDT Jan via Digitalmars-d-learn wrote: > On Thursday, 13 September 2018 at 11:08:30 UTC, Jonathan M Davis > > wrote: > > [...] > > Thanks for clarifying Jonathan :) > But aren't the variables considered rvalues then? No. variables are _always_ lvalues.

Re: dealing with very long paths and names

2018-09-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, September 15, 2018 8:45:55 AM MDT Vladimir Panteleev via Digitalmars-d-learn wrote: > On Friday, 14 September 2018 at 21:16:31 UTC, Jonathan M Davis > > wrote: > > Yeah, though if you write cross-platform applications or > > libraries (and ideally, most applications and libraries

Re: array to string functional?

2018-09-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 14, 2018 11:39:48 PM MDT berni via Digitalmars-d-learn wrote: > On Saturday, 15 September 2018 at 03:25:38 UTC, Paul Backus wrote: > > On Friday, 14 September 2018 at 20:43:45 UTC, SrMordred wrote: > >> What you want is std.range.chunks > >> > >> > >> auto a =

Re: dealing with very long paths and names

2018-09-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 14, 2018 2:52:42 PM MDT H. S. Teoh via Digitalmars-d- learn wrote: > On Fri, Sep 14, 2018 at 07:05:35PM +, Basile B. via Digitalmars-d- learn wrote: > > On Friday, 14 September 2018 at 17:59:38 UTC, Josphe Brigmo wrote: > > > Seems to break dirEntries when trying to deal

Re: Pass 'this' as reference

2018-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 13, 2018 4:04:58 AM MDT Jan via Digitalmars-d-learn wrote: > Many thanks Adam and Steve! Works like a charm! :D > I presumed classes are lvalues. I shouldn't make things more > complicated than they are ;-) Well, the variables _are_ lvalues. It's just that they're

Re: Shared, ref, arrays, and reserve template instantiation

2018-09-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, September 12, 2018 9:42:19 PM MDT James Blachly via Digitalmars-d-learn wrote: > Neia is right that I tried to cast as in the second case ( but > without UFCS -- reserve( cast(int[]), N); ). As an aside, what > is going on behind the scenes with the compiler when casting away > a

Re: Shared, ref, arrays, and reserve template instantiation

2018-09-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, September 12, 2018 5:41:16 PM MDT James Blachly via Digitalmars-d-learn wrote: > When I add the "shared" attribute to an array, I am no longer > able to call reserve because the template won't instantiate: > > Error: template object.reserve cannot deduce function from > argument

Re: Bug with writeln?

2018-09-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 9, 2018 8:30:12 AM MDT Saurabh Das via Digitalmars-d- learn wrote: > Thank you for explaining all this. > > It is frustrating because the behaviour is very counterintuitive. > > I will use a workaround for now. Ranges are fantastic, and the basic concept is solid, but a

Re: "immutable string" vs "const string*"

2018-09-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 9, 2018 2:49:56 AM MDT rikki cattermole via Digitalmars-d-learn wrote: > On 09/09/2018 8:41 PM, Christian Mayer wrote: > > On Sunday, 9 September 2018 at 08:14:41 UTC, rikki cattermole wrote: > >> Are you aware that a string is just an alias of immutable(char)[]? > > > > Yes,

Re: Bug with writeln?

2018-09-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 6, 2018 1:05:03 PM MDT Steven Schveighoffer via Digitalmars-d-learn wrote: > On 9/6/18 2:52 PM, Jonathan M Davis wrote: > > On Thursday, September 6, 2018 12:21:24 PM MDT Steven Schveighoffer via > > > > Digitalmars-d-learn wrote: > >> On 9/6/18 12:55 PM, Jonathan M Davis

Re: Bug with writeln?

2018-09-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 6, 2018 12:21:24 PM MDT Steven Schveighoffer via Digitalmars-d-learn wrote: > On 9/6/18 12:55 PM, Jonathan M Davis wrote: > > On Thursday, September 6, 2018 2:40:08 AM MDT Saurabh Das via > > Digitalmars-d-> > > learn wrote: > >> Is this a bug with writeln? > >> > >> void

Re: Slicing betterC

2018-09-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 6, 2018 11:34:18 AM MDT Adam D. Ruppe via Digitalmars-d-learn wrote: > On Thursday, 6 September 2018 at 17:10:49 UTC, Oleksii wrote: > > struct Slice(T) { > > > > size_t capacity; > > size_t size; > > T* memory; > > > > } > > There's no capacity in the slice, that

Re: Bug with writeln?

2018-09-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 6, 2018 2:40:08 AM MDT Saurabh Das via Digitalmars-d- learn wrote: > Is this a bug with writeln? > > void main() > { > import std.stdio, std.range, std.algorithm; > > auto a1 = sort([1,3,5,4,2]); > auto a2 = sort([9,8,9]); > auto a3 = sort([5,4,5,4]); > >

Re: Function parameter type inference: is this example working as intended?

2018-09-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 4, 2018 8:33:47 PM MDT Nathan S. via Digitalmars-d- learn wrote: > The below writes "uint". Is this working as intended? > https://run.dlang.io/is/Dx2e7f > > --- > import std.stdio; > > auto foo(T = uint)(uint x) > { > return T.stringof; > } > > auto foo(T = ulong)(ulong

Re: Mutable ForwardRange save() method not callable using const object

2018-09-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 4, 2018 9:22:26 AM MDT Timoses via Digitalmars-d-learn wrote: > On Tuesday, 4 September 2018 at 14:26:44 UTC, Steven > > Schveighoffer wrote: > > [...] > > As general advice, I wouldn't expect const to work well with > > Ranges anyway -- const ranges are useless (you can't

Re: Can passing an address of this to a non-copyable object be made trusted? - i.e. can I disable moving?

2018-08-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 26, 2018 5:10:29 PM MDT Nicholas Wilson via Digitalmars-d- learn wrote: > On Sunday, 26 August 2018 at 20:17:30 UTC, aliak wrote: > > So if we had this: > > > > struct A(T) { > > > > auto proxy() @trusted { > > > > return B!T(); > > > > } > > > > } > > > > struct B(T) { >

Re: Clock.currTime differs from SysTime

2018-08-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, August 25, 2018 6:53:24 AM MDT Ivo via Digitalmars-d-learn wrote: > I am using Clock.currTime.stdTime to get a unique timestamp in my > program. > Now I need to produce something similar in a different > programming language; so I'm trying to understand how > Clock.currTime works. >

Re: "The D Way" to run a sequence of executables?

2018-08-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 24, 2018 11:36:25 AM MDT Matthew OConnor via Digitalmars- d-learn wrote: > I'd like to run a sequence of executables with something like > std.process.execute, but I would like the sequence to error out > if one of the executables returns a non-zero return code. What is > the

Re: Cross compile windows programs on linux

2018-08-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 24, 2018 3:28:37 PM MDT Nick Sabalausky (Abscissa) via Digitalmars-d-learn wrote: > On 08/24/2018 12:30 PM, John Burton wrote: > > On Friday, 24 August 2018 at 15:26:30 UTC, kinke wrote: > >> On Friday, 24 August 2018 at 13:10:40 UTC, John Burton wrote: > >>> Is in the subject.

Re: Deduce type of struct in function arguments

2018-08-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, August 21, 2018 6:56:06 PM MDT Mike Parker via Digitalmars-d- learn wrote: > On Tuesday, 21 August 2018 at 14:56:21 UTC, Seb wrote: > > I'm aware, but we don't have any other process for people to > > show their support for a DIP, do we? > > > > > > And for DMD/Druntime/Phobos etc.

Re: Are properties mature enough?

2018-08-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, August 21, 2018 1:46:31 PM MDT Jim Balter via Digitalmars-d- learn wrote: > That's a lot of detail. The bottom line is that the warning in > the spec is completely wrong and should be removed -- using > property functions is not discouraged, nor is @property. > @property should be

<    1   2   3   4   5   6   7   8   9   10   >