Re: Confusion/trying to understand CTFE keywords

2018-06-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, June 03, 2018 21:32:06 gdelazzari via Digitalmars-d-learn wrote: > Hello everyone, I'm new here on the forum but I've been exploring > D for quite a while. I'm not an expert programmer by any means, > so this one may be a really silly question and, in that case, > please forgive me. > >

Re: Generate documentation for mixin'd function?

2018-06-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 01, 2018 21:26:18 rjframe via Digitalmars-d-learn wrote: > Hi > > I'm making an API for a web service, and have a small collection of > endpoints where I'd basically be creating copy+paste functions (a small > enough number that this isn't really that important for this project). I

Re: question about keeeping reference to toStringz()

2018-05-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 31, 2018 01:12:34 Dr.No via Digitalmars-d-learn wrote: > On Wednesday, 30 May 2018 at 20:43:48 UTC, Ali Çehreli wrote: > > On 05/30/2018 01:09 PM, Dr.No wrote: > > > consider a C function with this prototype: > > >> void foo(const char *baa); > > > > > > Does it means I should do:

Re: What's the purpose of the 'in' keyword ?

2018-05-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 30, 2018 22:16:28 aberba via Digitalmars-d-learn wrote: > On Sunday, 27 May 2018 at 16:00:15 UTC, Jonathan M Davis wrote: > > On Sunday, May 27, 2018 16:28:56 Russel Winder via > > > > Digitalmars-d-learn wrote: > >> On Sun, 2018-05-27 at 13:10 +, Adam D. Ruppe via > >>

Re: What's the purpose of the 'in' keyword ?

2018-05-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 30, 2018 15:28:53 Ali Çehreli via Digitalmars-d-learn wrote: > On 05/30/2018 03:16 PM, aberba wrote: > > On Sunday, 27 May 2018 at 16:00:15 UTC, Jonathan M Davis wrote: > >> On Sunday, May 27, 2018 16:28:56 Russel Winder via Digitalmars-d-learn > >> > >> wrote: > >>> On Sun,

Re: Move and CTFE

2018-05-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 30, 2018 22:42:13 Q. Schroll via Digitalmars-d-learn wrote: > On Wednesday, 30 May 2018 at 21:02:07 UTC, Jonathan M Davis wrote: > > On Wednesday, May 30, 2018 20:42:38 Q. Schroll via > > > > Digitalmars-d-learn wrote: > >> It seems one cannot std.algorithm.mutation.move objects

Re: Move and CTFE

2018-05-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 30, 2018 20:42:38 Q. Schroll via Digitalmars-d-learn wrote: > It seems one cannot std.algorithm.mutation.move objects > explicitly. Say I have a non-copyable type > > struct NoCopy > { > int payload; // some payload > pure nothrow @nogc @safe @disable: >

Re: Why 'getSymbolsByUDA' filters private members?

2018-05-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 28, 2018 05:43:23 Simen Kjærås via Digitalmars-d-learn wrote: > On Sunday, 27 May 2018 at 17:42:15 UTC, Sobaya wrote: > > I'd like to get symbols that have an UDA. > > > > But when the member is private, it is not obtained. > > > > And I found a comment saying "Filtering

Re: What is special about an immutable array of class objects, and why can I not .dup ?

2018-05-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 28, 2018 13:51:49 James Blachly via Digitalmars-d-learn wrote: > Consider the below: > > ``` > class C > { > int x; > } > > struct S > { > int x; > } > > > void main() > { > immutable C[] c = [ new C(), new C()]; > immutable S[] s = [ S(), S() ]; > immutable

Re: Naming conventions for export and import members of a struct

2018-05-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 27, 2018 21:54:42 Per Nordlöw via Digitalmars-d-learn wrote: > The integer type in gmp-z just got export (binary serialization) > support at > > https://github.com/nordlow/gmp-d/pull/8 > > Next up is import (binary deserialization). > > What's the preferred D-style naming convention

Re: What's the purpose of the 'in' keyword ?

2018-05-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 27, 2018 16:28:56 Russel Winder via Digitalmars-d-learn wrote: > On Sun, 2018-05-27 at 13:10 +, Adam D. Ruppe via Digitalmars-d-learn > > wrote: > > On Sunday, 27 May 2018 at 13:02:23 UTC, loloof64 wrote: > > > What's the purpose of this 'in' keyword ? I could not process a > >

Re: Why char[] is not @nogc on this case

2018-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 25, 2018 00:09:28 SrMordred via Digitalmars-d-learn wrote: > On Friday, 25 May 2018 at 00:04:10 UTC, Adam D. Ruppe wrote: > > On Thursday, 24 May 2018 at 23:55:24 UTC, SrMordred wrote: > >> //Error: @nogc delegate onlineapp.main.__lambda1 cannot call > >> non-@nogc function

Re: Why char[] is not @nogc on this case

2018-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 24, 2018 23:55:24 SrMordred via Digitalmars-d-learn wrote: > int[] a; > int[] b; > > ()@nogc { > foreach(v ; chain( a,b ) ) printf("%d\n", v); > }(); > > //Ok, everything fine; > > char[] a; > char[] b; > > ()@nogc { > foreach(v ; chain( a,b ) ) printf("%c\n", v); > }(); >

Re: try & catch / repeating code - DRY

2018-05-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 24, 2018 19:39:07 Jacob Carlborg via Digitalmars-d-learn wrote: > On 2018-05-24 08:05, Robert M. Münch wrote: > > Hi, great! Thanks for the examples... BTW: Is there a place where such > > generic and fundamental examples are collected? > > Not as far as I know. > > >> void

Re: How to convert ubyte[] to uint?

2018-05-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 23, 2018 19:36:07 Dr.No via Digitalmars-d-learn wrote: > read fails with both uint and ulong on 64bit platform: > > Error: template std.bitmanip.read cannot deduce function from > argument types !(ulong)(ubyte[8]), candidates are: >

Re: try & catch / repeating code - DRY

2018-05-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 23, 2018 04:07:25 Ali Çehreli via Digitalmars-d-learn wrote: > On 05/23/2018 12:47 AM, Robert M. Münch wrote: > > On 2018-05-22 18:34:34 +, Ali ‡ehreli said: > >> An idiom known in C++ circles is a Lippincott function: > >> > >> > >>

Re: UFCS syntax I never saw before.

2018-05-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 22, 2018 13:48:16 aliak via Digitalmars-d-learn wrote: > On Monday, 21 May 2018 at 18:53:19 UTC, Jonathan M Davis wrote: > > writeln = "foo"; > > > > is legal, and it's dumb, but it hasn't mattered much in > > practice. So, causing a bunch of code breakage in order to > > disallow

Re: auto & class members

2018-05-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 22, 2018 10:40:55 Robert M. Münch via Digitalmars-d-learn wrote: > This would require one wrap function per different lambda, right? > Assume I have 50-100 of these. Maybe the myMessage value can be given > as parameter and with this becomes more like a "filter factory". Not >

Re: auto & class members

2018-05-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 22, 2018 10:43:38 Robert M. Münch via Digitalmars-d-learn wrote: > On 2018-05-21 20:17:04 +, Jonathan M Davis said: > > On Monday, May 21, 2018 16:05:00 Steven Schveighoffer via Digitalmars-d- > > > > learn wrote: > >> Well one thing that seems clear from this example -- we

Re: auto & class members

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 16:05:00 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 5/21/18 3:22 PM, Jonathan M Davis wrote: > > That's basically what I was suggesting that he do, but I guess that I > > wasn't clear enough. > > Well one thing that seems clear from this example -- we now

Re: Can I work out error: reinterpreting cast from const(ubyte)* to const(uint)* is not supported in CTFE?

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 18:13:26 Dr.No via Digitalmars-d-learn wrote: > I'm trying to do some hashing at compile time with xxhash > algorithm but I get this error: > > ..\..\..\AppData\Local\dub\packages\xxhash-master\xxhash\src\xxhash.d(39,3 > 7): Error: reinterpreting cast from const(ubyte)* to

Re: assertNotThrown (and asserts in general)

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 12:44:21 Malte via Digitalmars-d-learn wrote: > I was interested by asserts and how the compiler uses them to > optimize the code. So I looked at the compiler explorer to see > how and found it, it doesn't. > > What I tried to do is turn a std.conv.to!ulong(byte) to a

Re: auto & class members

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 11:13:16 Ali Çehreli via Digitalmars-d-learn wrote: > On 05/20/2018 10:46 AM, Robert M. Münch wrote: > > But I still don't understand why I can't write things explicitly but > > have to use an alias for this. > > Templatized range types work well when they are used as

Re: auto & class members

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 14:55:36 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 5/20/18 1:46 PM, Robert M. Münch wrote: > > On 2018-05-20 17:40:39 +, Robert M. Münch said: > >> Hi Jonathan, great! This got me a step further. So I can declare my > >> member now. But I get an implict

Re: is ==

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 14:40:24 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 5/21/18 2:05 PM, Jonathan M Davis wrote: > > The core problem here is that no one reading a piece of code has any way > > of knowing whether the programmer knew what they were doing or not when > > using ==

Re: UFCS syntax I never saw before.

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 14:00:55 ANtlord via Digitalmars-d-learn wrote: > On Monday, 21 May 2018 at 11:38:12 UTC, SrMordred wrote: > > After all this time I saw this: > > > > writeln = iota = 5; > > > > what?? > > > > I never saw that before! > > > > This is interesting, there is something useful

Re: is ==

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 10:01:15 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 5/18/18 9:48 PM, Jonathan M Davis wrote: > > Of > > course, the most notable case where using == with null is a terrible > > idea is dynamic arrays, and that's the case where the compiler > > _doesn't_

Re: Splitting up large dirty file

2018-05-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 21, 2018 15:00:09 Dennis via Digitalmars-d-learn wrote: > On Thursday, 17 May 2018 at 21:10:35 UTC, Dennis wrote: > > It's unfortunate that Phobos tells you 'there's problems with > > the encoding' without providing any means to fix it or even > > diagnose it. > > I have to take

Re: auto & class members

2018-05-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 20, 2018 16:30:10 Robert M. Münch via Digitalmars-d-learn wrote: > I use the D RX lib [1] and can create a filtered stream using the auto > keyword: > > struct a { > SubjectObject!myType myStream; > ??? mySubStream; > } > > void myfunc(){ > a myA = new a(); > > auto

Re: is ==

2018-05-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 20, 2018 01:51:50 IntegratedDimensions via Digitalmars-d- learn wrote: > Simply require == null as is null and be done with it. That would be flat out wrong for dynamic arrays, because then auto result = arr == null and int[] nullArr; auto result = arr == nullArr; would have

Re: is ==

2018-05-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 19, 2018 17:13:36 Neia Neutuladh via Digitalmars-d-learn wrote: > I don't think I've ever wanted to distinguish a zero-length slice > of an array from a null array. It's safer if you don't, because it's so easy to end up with a dynamic array that is empty instead of null, and

Re: is ==

2018-05-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 19, 2018 17:50:50 IntegratedDimensions via Digitalmars-d- learn wrote: > So, ultimately what I feels like is that you are actually arguing > for == null to be interpreted as is null but you don't realize it > yet. Not really, no. Having foo == null be rewritten to foo is null

Re: is ==

2018-05-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 19, 2018 03:32:53 Neia Neutuladh via Digitalmars-d-learn wrote: > > Of course, the most notable case where using == with null is a > > terrible idea is dynamic arrays, and that's the case where the > > compiler _doesn't_ complain. Using == with null and arrays is > > always

Re: is ==

2018-05-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 19, 2018 01:27:59 Neia Neutuladh via Digitalmars-d-learn wrote: > On Friday, 18 May 2018 at 23:53:12 UTC, IntegratedDimensions > > wrote: > > Why does D complain when using == to compare with null? Is > > there really any technical reason? if one just defines == null > > to is

Re: is ==

2018-05-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 18, 2018 23:53:12 IntegratedDimensions via Digitalmars-d- learn wrote: > Why does D complain when using == to compare with null? Is there > really any technical reason? if one just defines == null to is > null then there should be no problem. It seems like a pedantic > move by who

Re: Splitting up large dirty file

2018-05-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 17, 2018 21:10:35 Dennis via Digitalmars-d-learn wrote: > On Wednesday, 16 May 2018 at 10:30:34 UTC, Jonathan M Davis wrote: > > For various reasons, that doesn't always hold true like it > > should, but pretty much all of Phobos is written with that > > assumption and will

Re: Splitting up large dirty file

2018-05-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 16, 2018 08:57:10 Dennis via Digitalmars-d-learn wrote: > I thought it wouldn't be hard to crudely split this file using > D's range functions and basic string manipulation, but the > combination of being to large for a string and having invalid > encoding seems to defeat most

Re: Splitting up large dirty file

2018-05-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 15, 2018 20:36:21 Dennis via Digitalmars-d-learn wrote: > I have a file with two problems: > - It's too big to fit in memory (apparently, I thought 1.5 Gb > would fit but I get an out of memory error when using > std.file.read) > - It is dirty (contains invalid Unicode characters,

Re: Why The D Style constants are written in camelCase?

2018-05-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 15, 2018 08:48:45 Martin Tschierschke via Digitalmars-d- learn wrote: > On Wednesday, 9 May 2018 at 11:52:11 UTC, Jonathan M Davis wrote: > > On Wednesday, May 09, 2018 09:38:14 BoQsc via > > > > Digitalmars-d-learn wrote: > >> [...] > > > > Every language makes its own choices

Re: getOpt with shared

2018-05-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 11, 2018 14:31:17 Steven Schveighoffer via Digitalmars-d- learn wrote: > On 5/11/18 1:25 PM, Danny Arends wrote: > > Hey all, > > > > I have been working on creating a multi-threaded application, so I have > > a shared configuration object which hold several command line parameters

Re: getOpt with shared

2018-05-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 11, 2018 18:01:18 Danny Arends via Digitalmars-d-learn wrote: > On Friday, 11 May 2018 at 17:49:17 UTC, Jonathan M Davis wrote: > > On Friday, May 11, 2018 17:25:44 Danny Arends via > > > > Digitalmars-d-learn wrote: > >> [...] > > > > getopt is designed to be single-threaded. The

Re: getOpt with shared

2018-05-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 11, 2018 17:25:44 Danny Arends via Digitalmars-d-learn wrote: > Hey all, > > I have been working on creating a multi-threaded application, so > I have a shared configuration object which hold several command > line parameters (which I fill using getopt). > > The problem is that I

Re: Why are deprecated aliases considered equal for resolution?

2018-05-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 11, 2018 14:02:22 Nicholas Wilson via Digitalmars-d-learn wrote: > - > module a; > > struct foo {} > > deprecated alias bar = foo; > > -- > module b; > struct bar {}; > > > --- > module c; > > import a; > import b; > > void baz(bar b) {} > > Error: `a.bar`

Re: property += operator

2018-05-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 10, 2018 18:43:40 SrMordred via Digitalmars-d-learn wrote: > struct T > { > int x; > @property ref X(){ return x; } > @property X(int v) > { > x = v; > } > } > > T t; > t.X += 10; > > The setter 'x = v' are not executed because i´m returning the >

Re: Package method is not virtual and cannot override - a bug or a feature?

2018-05-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 10, 2018 11:52:38 Piotr Mitana via Digitalmars-d-learn wrote: > Given this code: > > abstract class A > { > package @property void x(int x); > package @property int x(); > } > > class B : A > { > package @property override void x(int x) {} > package @property

Re: `this` and nested structs

2018-05-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 10, 2018 06:31:09 Mike Franklin via Digitalmars-d-learn wrote: > On Thursday, 10 May 2018 at 06:22:37 UTC, Jonathan M Davis wrote: > > Structs don't have that. > > Should they? Honestly, I don't think that classes should have it, but changing it now would break code (most

Re: `this` and nested structs

2018-05-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 10, 2018 03:23:50 Mike Franklin via Digitalmars-d-learn wrote: > My understanding is that nested structs have an implicit context > pointer to their containing scope. A non-static struct inside a function does, but I suspect that you're thinking about non-static nested classes

Re: dxml behavior after exception: continue parsing

2018-05-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 08, 2018 16:18:40 Jesse Phillips via Digitalmars-d-learn wrote: > On Monday, 7 May 2018 at 22:24:25 UTC, Jonathan M Davis wrote: > > I've been considering adding more configuration options where > > you say something like you don't care if any invalid characters > > are

Re: Why The D Style constants are written in camelCase?

2018-05-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 09, 2018 14:12:41 Dmitry Olshansky via Digitalmars-d-learn wrote: > On Wednesday, 9 May 2018 at 09:38:14 UTC, BoQsc wrote: > > The D Style suggest to camelCase constants, while Java naming > > conventions always promoted uppercase letter. > > > > Is there an explanation why D

Re: Why The D Style constants are written in camelCase?

2018-05-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 09, 2018 09:38:14 BoQsc via Digitalmars-d-learn wrote: > The D Style suggest to camelCase constants, while Java naming > conventions always promoted uppercase letter. > > Is there an explanation why D Style chose to use camelCase > instead of all UPPERCASE for constants, was

Re: dxml behavior after exception: continue parsing

2018-05-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 07, 2018 22:16:58 Jesse Phillips via Digitalmars-d-learn wrote: > On Monday, 7 May 2018 at 19:46:00 UTC, Jesse Phillips wrote: > > So I have an XML like document which fails to adhere completely > > to XML. One of these such events is that & is used without > > escaping. > > > > My

Re: dxml behavior after exception: continue parsing

2018-05-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 07, 2018 19:46:00 Jesse Phillips via Digitalmars-d-learn wrote: > So I have an XML like document which fails to adhere completely > to XML. One of these such events is that & is used without > escaping. > > My observation is that after the exception it is possible to move > to the

Re: Windows to Linux Porting - timeCreated and timeLastAccessed

2018-05-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 04, 2018 13:17:36 Vino via Digitalmars-d-learn wrote: > On Friday, 4 May 2018 at 12:38:07 UTC, Adam D. Ruppe wrote: > > What are you actually trying to do with it? These functions are > > probably the wholly wrong approach. > > Hi Adam, > > The existing program in Windows do few

Re: Windows to Linux Porting

2018-05-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 04, 2018 10:25:28 Russel Winder via Digitalmars-d-learn wrote: > On Fri, 2018-05-04 at 08:47 +, Vino via Digitalmars-d-learn wrote: > > […] > > > Was able to resolve the issue, the issue was the letter "L" in > > > > version (Linux) where is should be version (linux). > > It

Re: Finding the last executed line by checking dmd core

2018-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 03, 2018 19:45:54 kerdemdemir via Digitalmars-d-learn wrote: > After a big refactor my code crushes I have no idea where. > > I am only getting : > > Program exited with code -11 > > And a core file. > > I used to use gdb for c++ coredumps. With what program I > can check dmd

Re: cannot find -lcurl in Linux

2018-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 03, 2018 10:10:05 Vino via Digitalmars-d-learn wrote: > Hi All, > > Request your help , while compiling a d program in SUSE Linux i > am getting the below error, the executable curl is present under > the path /usr/bin/ > > ask:/DScript # dmd -m64 -O -release -inline test.d >

Re: Why does enumerate over range return dchar, when ranging without returns char?

2018-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 03, 2018 22:00:04 rikki cattermole via Digitalmars-d-learn wrote: > On 03/05/2018 9:50 PM, ag0aep6g wrote: > > On 05/03/2018 07:56 AM, rikki cattermole wrote: > >>> ``` > >>> import std.stdio; > >>> import std.range : enumerate; > >>> > >>> void main() > >>> { > >>> char[] s

Re: Is build a 64 bit version worth if I'm looking for better perfomance?

2018-05-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 01, 2018 22:48:08 Dr.No via Digitalmars-d-learn wrote: > Looking for make application run fast as possible, aside > optimization in the source code, is using 64 bit over 32 really > worth? That would heavily depend on the program. The big win for D code and 64-bit that doesn't

Re: Can I convert the Range returned by asUpperCase to ubyte[]?

2018-05-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 01, 2018 20:13:41 Dr.No via Digitalmars-d-learn wrote: > I'm trying to do an optimization here: a hash function which > expect a ubye[] array as argument, would just work if I cast > string to ubyte[] but I need to convert it to upper case, so I'd > like to do that lazily, so that

Re: D in SUSE Enterprise Linux

2018-05-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 01, 2018 15:51:14 Vino via Digitalmars-d-learn wrote: > On Tuesday, 1 May 2018 at 15:42:38 UTC, Jonathan M Davis wrote: > > On Tuesday, May 01, 2018 15:18:12 Vino via Digitalmars-d-learn > > > > wrote: > >> On Tuesday, 1 May 2018 at 15:04:43 UTC, rikki cattermole wrote: > >> > On

Re: Equivalent function of timeCreated for Linux

2018-05-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 01, 2018 15:41:07 Vino via Digitalmars-d-learn wrote: > Hi All, > > Request your help, what is the equivalent function of > timeCreated(Windows) for Linux. Or how do i get the file creation > date and time in Linux using D. AFAIK, no filesystems on Linux keep track of that

Re: D in SUSE Enterprise Linux

2018-05-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 01, 2018 15:18:12 Vino via Digitalmars-d-learn wrote: > On Tuesday, 1 May 2018 at 15:04:43 UTC, rikki cattermole wrote: > > On 02/05/2018 2:56 AM, Vino wrote: > >> Hi All, > >> > >> Request your help, trying to execute the below program in > >> > >> SUSE Linux but there is no

Re: readonly member (but assignable at constructor time)

2018-04-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 30, 2018 10:36:52 bauss via Digitalmars-d-learn wrote: > On Saturday, 28 April 2018 at 04:56:26 UTC, lempiji wrote: > > On Friday, 27 April 2018 at 02:59:16 UTC, Dr.No wrote: > >> In C# you can have a readonly member assignable either at > >> declaration or constructor time, like

Re: Passing to c++ std::string and vector

2018-04-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 30, 2018 01:07:35 NewUser via Digitalmars-d-learn wrote: > Hi, > > How do I pass a d string to a c++ std::string? The most straightforward way would be to create a C or C++ function which accepts const char* and size_t and then creates the std::string, in which case you pass it

Re: Create variable for RedBlackTree range

2018-04-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, April 28, 2018 16:36:41 Gerald via Digitalmars-d-learn wrote: > What is the appropriate way to create a variable for the range > returned by RedBlackTree lowerBound and upperBound. For example, > given this code: > > ``` > RedBlackTree!long promptPosition = redBlackTree!long(); > >

Re: Virtual table in class without overloading

2018-04-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, April 28, 2018 11:04:56 Andrey via Digitalmars-d-learn wrote: > Hello, > I have some questions about virtual table in classes. > Example 1: > > class Test > { > void someMethod() { ... } > int anotherMethod { ... } > } > > Will this class have a vtable? > > Example 2: >

Re: readonly member (but assignable at constructor time)

2018-04-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, April 27, 2018 02:59:16 Dr.No via Digitalmars-d-learn wrote: > In C# you can have a readonly member assignable either at > declaration or constructor time, like this: > > class C > { >readonly myClass mc; > >this() >{ > mc = new myClass(); >} > > >void

Re: Arguments of function as an array.

2018-04-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, April 26, 2018 21:28:27 Jonathan via Digitalmars-d-learn wrote: > Is there a way in D to take past arguments as an array? A like a > normal Variadic function. All the arguments should be of the > same type just as an array. > > Basically I want to allow a function like this to be

Re: Making an .exe that executes source file inside itself.

2018-04-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, April 25, 2018 19:19:58 BoQsc via Digitalmars-d-learn wrote: > So there has been idea I've got for around few months now: making > a software which executable would contain a source file. > A software that anyone could modify by opening an executable and > quickly change a few lines

Re: Get files from directory sorted by name

2018-04-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, April 25, 2018 17:34:41 Dr.No via Digitalmars-d-learn wrote: > Is there something implemented already to get the files from > directory by name using D or I'm on my own and I have to write it > myself? I didn't find how do that with dirEntries() There is nothing in the standard

Re: Warning on self assignment

2018-04-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, April 25, 2018 02:32:32 Per Nordlöw via Digitalmars-d-learn wrote: > On Wednesday, 25 April 2018 at 02:23:04 UTC, Mike Franklin wrote: > > Are people using self assignment of structs as a way of > > force-running the postblit? Is there a valid use case for that? > > > > Mike > > If

Re: Warning on self assignment

2018-04-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, April 25, 2018 02:23:04 Mike Franklin via Digitalmars-d-learn wrote: > On Wednesday, 25 April 2018 at 01:08:46 UTC, Arun Chandrasekaran > > wrote: > > So I was telling my colleague that D would warn on self > > assignment, but found that I was wrong. > > > >

Re: Warning on self assignment

2018-04-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, April 25, 2018 03:32:09 Meta via Digitalmars-d-learn wrote: > On Wednesday, 25 April 2018 at 02:32:32 UTC, Per Nordlöw wrote: > > On Wednesday, 25 April 2018 at 02:23:04 UTC, Mike Franklin > > > > wrote: > >> Are people using self assignment of structs as a way of > >> force-running

Re: Add property-like Function to Type ?

2018-04-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 24, 2018 21:36:19 Rubn via Digitalmars-d-learn wrote: > I was wondering if I could create my own property in a way that > can be used the same way as something like "T.sizeof". Right now > I have the following to replace length: > > uint length32(T)(T[] array) > { > return

Re: Doxygen newbie

2018-04-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 23, 2018 07:49:00 Chris Katko via Digitalmars-d-learn wrote: > I'm a complete doxygen newbie. But my first thought when writing > comments is... why not use Markdown? (Which has become almost > universal online these days.) > > So I google it and Moxygen comes up. Which seems

Re: dynamically allocating on the stack

2018-04-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, April 22, 2018 01:07:44 Giles Bathgate via Digitalmars-d-learn wrote: > On Saturday, 21 April 2018 at 19:06:52 UTC, Steven Schveighoffer > > wrote: > > alloca is an intrinsic, and part of the language technically -- > > it has to be. > > Why does: > > scope c = new C(); //

Re: How to use std.meta.Filter?

2018-04-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, April 21, 2018 17:46:05 Dr.No via Digitalmars-d-learn wrote: > On Saturday, 21 April 2018 at 17:15:47 UTC, Jonathan M Davis > > wrote: > > On Saturday, April 21, 2018 16:05:22 Dr.No via > > > > Digitalmars-d-learn wrote: > >> import std.meta : Filter; > >> enum

Re: How to use std.meta.Filter?

2018-04-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, April 21, 2018 16:05:22 Dr.No via Digitalmars-d-learn wrote: > import std.meta : Filter; > enum isNotReservedSymbol(string name) = name != "none" && name != > "lastToken"; > enum string[] members = staticMembers!Token; > static foreach(member; Filter!(isNotReservedSymbol, members)) >

Re: wstring double quotes to string double quotes

2018-04-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, April 20, 2018 07:45:14 Joel via Digitalmars-d-learn wrote: > On Friday, 20 April 2018 at 02:46:14 UTC, Jonathan M Davis wrote: > > On Thursday, April 19, 2018 23:24:05 Joel via > > > > Digitalmars-d-learn wrote: > >> On Thursday, 19 April 2018 at 21:57:28 UTC, Adam D. Ruppe > >> > >>

Re: wstring double quotes to string double quotes

2018-04-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, April 19, 2018 23:24:05 Joel via Digitalmars-d-learn wrote: > On Thursday, 19 April 2018 at 21:57:28 UTC, Adam D. Ruppe wrote: > > On Thursday, 19 April 2018 at 21:53:52 UTC, Joel wrote: > >> I have a program that uses string double quotes, but copies > >> from wstring double quotes.

Re: making a struct an inputRange with free functions

2018-04-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, April 18, 2018 20:39:46 jmh530 via Digitalmars-d-learn wrote: > On Monday, 16 April 2018 at 19:27:28 UTC, Jonathan M Davis wrote: > > [snip] > > It really would be nice if it worked with free functions... > > I was trying to get the example working with Atila's concepts > library

Re: The case of -debug -O and: is breaking pure/@nogc/nothrow/@safe UB under -debug?

2018-04-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, April 18, 2018 13:15:08 Guillaume Piolat via Digitalmars-d- learn wrote: > The D specification says: > > "A ConditionalStatement that has a DebugCondition is called a > DebugStatement. DebugStatements have relaxed semantic checks in > that pure, @nogc, nothrow and @safe checks are

Re: Assoc. Array and struct with immutable member

2018-04-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, April 15, 2018 17:59:01 Dgame via Digitalmars-d-learn wrote: > How am I supposed to insert a struct with immutable members into > an assoc. array? > > Reduced example: > > struct A { > immutable string name; > } > > A[string] as; > as["a"] = A("a"); // Does not work > I

Re: making a struct an inputRange with free functions

2018-04-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 16, 2018 21:10:03 Johannes Loher via Digitalmars-d-learn wrote: > Is there a way to do this? Here is a naive implementation: > https://run.dlang.io/is/JKvL80 . > > It does not pass `isInputRange` (I think, because the free functions are > not visible in the scope of

Re: How/where to hack DMD to generate docs for string mixed members.

2018-04-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 16, 2018 16:05:40 9il via Digitalmars-d-learn wrote: > On Sunday, 15 April 2018 at 08:17:21 UTC, Jonathan M Davis wrote: > > On Sunday, April 15, 2018 07:59:17 Stefan Koch via > > > > Digitalmars-d-learn wrote: > >> On Sunday, 15 April 2018 at 05:20:31 UTC, 9il wrote: > >> > Hey,

Re: How/where to hack DMD to generate docs for string mixed members.

2018-04-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, April 15, 2018 07:59:17 Stefan Koch via Digitalmars-d-learn wrote: > On Sunday, 15 April 2018 at 05:20:31 UTC, 9il wrote: > > Hey, > > > > How/where to hack DMD to generate docs for string mixed members? > > > > struct S > > { > > > > mixin(" > > > > /// > > auto bar() {}

Re: Escaping address of

2018-04-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, April 11, 2018 16:08:06 Nick Treleaven via Digitalmars-d-learn wrote: > Is this a known bug? With v2.079.0, with or without -dip1000: > > @safe unittest > { > struct S > { > int i; > } > auto p = ().i; > } > > The address of field `i` should not escape,

Re: Should "a is b" compile if a and b have unrelated classes?

2018-04-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 10, 2018 21:52:22 Michael Coulombe via Digitalmars-d-learn wrote: > I had a bug in my code that was messing me up for a while, and it > boiled down to an identity check between two Object references > with unrelated static types, like below: > > class A {} > class B {} > void

Re: Range length property

2018-04-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 10, 2018 22:07:40 Cym13 via Digitalmars-d-learn wrote: > On Tuesday, 10 April 2018 at 20:08:14 UTC, Jonathan M Davis wrote: > > On Tuesday, April 10, 2018 19:47:10 Nordlöw via > > > > Digitalmars-d-learn wrote: > >> On Tuesday, 10 April 2018 at 14:34:40 UTC, Adam D. Ruppe wrote:

Re: Range length property

2018-04-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 10, 2018 19:47:10 Nordlöw via Digitalmars-d-learn wrote: > On Tuesday, 10 April 2018 at 14:34:40 UTC, Adam D. Ruppe wrote: > > On Tuesday, 10 April 2018 at 14:25:52 UTC, Nordlöw wrote: > >> Should ranges always provide a length property? > > > > No. > > > >> If so, in which cases

Re: Destructor call

2018-04-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 10, 2018 18:52:19 kinke via Digitalmars-d-learn wrote: > On Tuesday, 10 April 2018 at 18:34:54 UTC, n0fun wrote: > > Why the destructor is called in the second case and why not in > > the first? > > The first case is RAII, where destruction isn't done for not > fully constructed

Re: Range length property

2018-04-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 10, 2018 14:25:52 Nordlöw via Digitalmars-d-learn wrote: > Should ranges always provide a length property? > > If so, in which cases is a length property an advantage or a > requirement? Whether a range has a length property or not is primarily dependent on how efficient it is

Re: Should the "front" range primitive be "const" ?

2018-04-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 09, 2018 23:58:02 Drone1h via Digitalmars-d-learn wrote: > On Monday, 19 March 2018 at 00:50:06 UTC, Jonathan M Davis wrote: > > [...] > > http://jmdavisprog.com/articles/why-const-sucks.html > > I have just read the reply and the article. > > I cannot believe you have written

Re: Source expression passed to a lazy parameter

2018-04-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 09, 2018 08:27:50 Per Nordlöw via Digitalmars-d-learn wrote: > Is it possible to get the source expression sent to a lazy > function? > > So that I can implement something like > > show(Arg)(lazy Arg arg) > { > writeln(arg.sourceof, arg); > } > > used as > >

Re: Checking if a function pointer is set or null

2018-04-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 09, 2018 00:25:08 solidstate1991 via Digitalmars-d-learn wrote: > Would the if(!(myFunctionPointer is null)){} work is I > intended? You can also do if(myFunctionPointer !is null) - Jonathan M Davis

Re: Proper way to fix core.exception.UnicodeException@src\rt\util\utf.d(292): invalid UTF-8 sequence by File.readln()

2018-04-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, April 06, 2018 16:10:56 Dr.No via Digitalmars-d-learn wrote: > I'm reading line by line the lines from a CSV file provided by > the user which is assumed to be UTF8. But an user has provided an > > ANSI file which resulted in the error: >

Re: Compile-time variables

2018-04-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, April 06, 2018 00:35:39 Kayomn via Digitalmars-d-learn wrote: > On Friday, 6 April 2018 at 00:21:54 UTC, H. S. Teoh wrote: > > On Thu, Apr 05, 2018 at 11:53:00PM +, Kayomn via > > Digitalmars-d-learn wrote: [...] > > > >> [...] > > > > [...] > > > >> [...] > > > > `lastID`, as

Re: Construct immutable member in derived class

2018-04-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, April 05, 2018 13:36:07 Alex via Digitalmars-d-learn wrote: > On Wednesday, 4 April 2018 at 21:49:08 UTC, Timoses wrote: > > "[...] the construction of the base class can be independent > > from the derived one." > > > > Hm, the points 7 and 8 don't clearly state what you wrote. > >

Re: Construct immutable member in derived class

2018-04-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, April 04, 2018 21:46:13 Timoses via Digitalmars-d-learn wrote: > On Wednesday, 4 April 2018 at 18:11:12 UTC, Jonathan M Davis > > That code doesn't compile - at least not with dmd master. It > > gives these two errors: > > > > q.d(5): Error: constructor `q.A.this` missing initializer

Re: Construct immutable member in derived class

2018-04-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, April 04, 2018 16:05:52 Timoses via Digitalmars-d-learn wrote: > On Wednesday, 4 April 2018 at 10:41:52 UTC, Simen Kjærås wrote: > > Because by the time B's constructor is called, A might already > > have initialized it, and rely on it never changing. > > What about: > > ``` > class

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