Re: Splitting up large dirty file

2018-05-21 Thread Jon Degenhardt via Digitalmars-d-learn
On Monday, 21 May 2018 at 15:00:09 UTC, Dennis wrote: I want to be convinced that Range programming works like a charm, but the procedural approaches remain more flexible (and faster too) it seems. Thanks for the example. On Monday, 21 May 2018 at 22:11:42 UTC, Dennis wrote: In this case I

Re: C style callbacks fix for member callbacks

2018-05-21 Thread IntegratedDimensions via Digitalmars-d-learn
On Monday, 21 May 2018 at 02:23:27 UTC, ag0aep6g wrote: I tried this. Your code crashes in windows dmd x86 x64. Hm. Works for me in a virtual machine. But I'm not surprised that it's fragile. It might be completely wrong, and it just happens to look alright on my machine.

Re: Splitting up large dirty file

2018-05-21 Thread Dennis via Digitalmars-d-learn
On Monday, 21 May 2018 at 17:42:19 UTC, Jonathan M Davis wrote: On Monday, May 21, 2018 15:00:09 Dennis via Digitalmars-d-learn wrote: drop is range-based, so if you give it a string, it's going to decode because of the whole auto-decoding mess with std.range.primitives.front and popFront.

Re: scope guards & debugger breakpoints?

2018-05-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/21/18 1:50 PM, Robert M. Münch wrote: On 2018-05-21 17:24:12 +, Steven Schveighoffer said: I'm not 100% sure but I expect: scope(failure)     someCode(); putting a breakpoint on someCode should work. When calling a function an then setting the breakpoint there, like in someCode()

Re: Temporary file creation for unittests

2018-05-21 Thread Atila Neves via Digitalmars-d-learn
On Monday, 21 May 2018 at 15:20:14 UTC, Dr.No wrote: On Monday, 21 May 2018 at 15:16:11 UTC, Atila Neves wrote: On Friday, 18 May 2018 at 15:16:52 UTC, Russel Winder wrote: Hi, What's the current official position on how to create temporary files for use during a unittest. I found Not

Re: Temporary file creation for unittests

2018-05-21 Thread Atila Neves via Digitalmars-d-learn
On Monday, 21 May 2018 at 17:03:40 UTC, Russel Winder wrote: On Mon, 2018-05-21 at 15:16 +, Atila Neves via Digitalmars-d-learn wrote: On Friday, 18 May 2018 at 15:16:52 UTC, Russel Winder wrote: > Hi, > > What's the current official position on how to create > temporary files for use

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: auto & class members

2018-05-21 Thread Steven Schveighoffer via Digitalmars-d-learn
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 have __traits(isSame) to tell if lambdas are the same, but it looks like the compiler doesn't

Re: is ==

2018-05-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/21/18 3:20 PM, Jonathan M Davis wrote: On Monday, May 21, 2018 14:40:24 Steven Schveighoffer via Digitalmars-d- learn wrote: For me, the code smell is using arr is null (is it really necessary to check for a null pointer here?), for which I always have to look at more context to see if

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: auto & class members

2018-05-21 Thread Steven Schveighoffer via Digitalmars-d-learn
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 cast error when I try: class a { ... myStream; } class b { typeof(a.myStream.filter!(x

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 Steven Schveighoffer via Digitalmars-d-learn
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 == null with an array, and the vast majority of newbies are not going to have understood the

Re: Real Int24

2018-05-21 Thread IntegratedDimensions via Digitalmars-d-learn
On Monday, 21 May 2018 at 15:41:21 UTC, Simen Kjærås wrote: On Saturday, 19 May 2018 at 18:44:42 UTC, IntegratedDimensions wrote: On Saturday, 19 May 2018 at 18:19:35 UTC, IntegratedDimensions wrote: Is there any way to create an int24 type that behaves just like any other built in type

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

2018-05-21 Thread Dr.No via Digitalmars-d-learn
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,37): Error: reinterpreting cast from const(ubyte)* to const(uint)* is not supported in CTFE this is line 39

Re: auto & class members

2018-05-21 Thread Ali Çehreli via Digitalmars-d-learn
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 template arguments themselves. When you need to keep a single type like 'b' (i.e. b

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: scope guards & debugger breakpoints?

2018-05-21 Thread Robert M. Münch via Digitalmars-d-learn
On 2018-05-21 17:24:12 +, Steven Schveighoffer said: I'm not 100% sure but I expect: scope(failure) someCode(); putting a breakpoint on someCode should work. When calling a function an then setting the breakpoint there, like in someCode() yes, that should work. I used code like

VisualD / fatal error C1905: Front-End and Back-End are not compatible (have to use the same processor)

2018-05-21 Thread Robert M. Münch via Digitalmars-d-learn
A project I can compile via the command line and dub, gives an error in VisualD. I created the VisualD configuration through dub: fatal error C1905: Front-End und Back-End sind nicht kompatibel (müssen den gleichenProzessor verwenden). This translates to: "Front-End and Back-End are not

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: scope guards & debugger breakpoints?

2018-05-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/21/18 1:00 PM, Robert M. Münch wrote: If I use scope(failure) with code that should be run if an exception is thrown, how can I set a breakpoint for this code in the debugger? I'm not 100% sure but I expect: scope(failure) someCode(); putting a breakpoint on someCode should work.

scope guards & debugger breakpoints?

2018-05-21 Thread Robert M. Münch via Digitalmars-d-learn
If I use scope(failure) with code that should be run if an exception is thrown, how can I set a breakpoint for this code in the debugger? -- Robert M. Münch http://www.saphirion.com smarter | better | faster

Re: Temporary file creation for unittests

2018-05-21 Thread Russel Winder via Digitalmars-d-learn
On Mon, 2018-05-21 at 15:16 +, Atila Neves via Digitalmars-d-learn wrote: > On Friday, 18 May 2018 at 15:16:52 UTC, Russel Winder wrote: > > Hi, > > > > What's the current official position on how to create temporary > > files for use during a unittest. I found > > Not official, but... > >

Re: UFCS syntax I never saw before.

2018-05-21 Thread SrMordred via Digitalmars-d-learn
"%s %s".writefln = ("foo".tuple = "bar").expand; lol

How do I see the flags passed from dub to the compiler?

2018-05-21 Thread Dr.No via Digitalmars-d-learn
where's this stored?

Re: How do I see the flags passed from dub to the compiler?

2018-05-21 Thread rikki cattermole via Digitalmars-d-learn
On 22/05/2018 4:21 AM, Dr.No wrote: where's this stored? -v should do the trick

Re: Real Int24

2018-05-21 Thread Simen Kjærås via Digitalmars-d-learn
On Saturday, 19 May 2018 at 18:44:42 UTC, IntegratedDimensions wrote: On Saturday, 19 May 2018 at 18:19:35 UTC, IntegratedDimensions wrote: Is there any way to create an int24 type that behaves just like any other built in type without having to reimplement everything? In fact, what I'd like

Re: Temporary file creation for unittests

2018-05-21 Thread Dr.No via Digitalmars-d-learn
On Monday, 21 May 2018 at 15:16:11 UTC, Atila Neves wrote: On Friday, 18 May 2018 at 15:16:52 UTC, Russel Winder wrote: Hi, What's the current official position on how to create temporary files for use during a unittest. I found Not official, but... import unit_threaded;

Re: Mysql query result access by field name

2018-05-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/21/18 10:59 AM, kdevel wrote: On Monday, 21 May 2018 at 14:17:23 UTC, Steven Schveighoffer wrote:     Data f;     allrows[0].toStruct (f); I haven't checked this. This only works if your struct has exactly the same layout as the fields. So if, for instance, your rows are selected

Re: Temporary file creation for unittests

2018-05-21 Thread Atila Neves via Digitalmars-d-learn
On Friday, 18 May 2018 at 15:16:52 UTC, Russel Winder wrote: Hi, What's the current official position on how to create temporary files for use during a unittest. I found Not official, but... import unit_threaded; with(const Sandbox()) { writeFile("myfile.txt", "contents");

Re: Splitting up large dirty file

2018-05-21 Thread Dennis via Digitalmars-d-learn
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 that back since I found out about std.encoding which has functions like `sanitize`,

Re: Mysql query result access by field name

2018-05-21 Thread kdevel via Digitalmars-d-learn
On Monday, 21 May 2018 at 14:17:23 UTC, Steven Schveighoffer wrote:    Data f;    allrows[0].toStruct (f); I haven't checked this. This only works if your struct has exactly the same layout as the fields. So if, for instance, your rows are selected "title", "name", "surname", but your

Re: UFCS syntax I never saw before.

2018-05-21 Thread Dennis via Digitalmars-d-learn
On Monday, 21 May 2018 at 11:38:12 UTC, SrMordred wrote: what?? Here's another weird example: ``` void funWithUfcsAndPropertySyntax() { import std.typecons : tuple; "%s %s".writefln = ("foo".tuple = "bar").expand; } ``` source:

Re: UFCS syntax I never saw before.

2018-05-21 Thread Chris M. via Digitalmars-d-learn
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 that i can do with this kind of call? That's pretty cool, but at the same time this should be wiped

Re: Mysql query result access by field name

2018-05-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/21/18 9:39 AM, kdevel wrote: On Sunday, 20 May 2018 at 16:08:03 UTC, ipkwena wrote: How does one access the columns fields in a Mysql query results by the column name. [...] Data f; f.name = to!string(allrows[0][0]); f.surname = to!string(allrows[0][1]); f.title  =

Re: UFCS syntax I never saw before.

2018-05-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/21/18 8:15 AM, SrMordred wrote: Right, so this should´n be working I think. struct SomeStruct {     void foo(int); } SomeStruct s; s.foo = 10; I thought that only with @property this will work. That was the plan, but it got derailed. Whoever wrote that original line of code, they

Re: Mysql query result access by field name

2018-05-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/20/18 12:08 PM, ipkwena wrote: I have started learning D and I am enjoying it so far. How does one access the columns fields in a Mysql query results by the column name. Currently I have to use the method as shown in a couple of example by indexing array values (f being a struct

Re: is ==

2018-05-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/18/18 9:48 PM, Jonathan M Davis wrote: 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

Re: UFCS syntax I never saw before.

2018-05-21 Thread ANtlord via Digitalmars-d-learn
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 that i can do with this kind of call? What the hell is this? I don't figure out why are there so many

Re: Mysql query result access by field name

2018-05-21 Thread kdevel via Digitalmars-d-learn
On Sunday, 20 May 2018 at 16:08:03 UTC, ipkwena wrote: How does one access the columns fields in a Mysql query results by the column name. [...] Data f; f.name = to!string(allrows[0][0]); f.surname = to!string(allrows[0][1]); f.title = to!string(allrows[0][2]); I am using the mysql-native

assertNotThrown (and asserts in general)

2018-05-21 Thread Malte via Digitalmars-d-learn
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 simple cast with the help of assertions. https://godbolt.org/g/4uckWU If there

Re: UFCS syntax I never saw before.

2018-05-21 Thread SrMordred via Digitalmars-d-learn
Right, so this should´n be working I think. struct SomeStruct { void foo(int); } SomeStruct s; s.foo = 10; I thought that only with @property this will work.

Re: Copying an std.stdio.File into another one

2018-05-21 Thread rikki cattermole via Digitalmars-d-learn
On 21/05/2018 11:50 PM, 0xEAB wrote: What's the correct way to copy a `File` into another one in D? If `LockingTextReader` wasn't undocumented, I'd have gone for that approach: import std.algorithm.mutation : copy; import std.stdio : File, LockingTextReader; void main() {     auto a =

Copying an std.stdio.File into another one

2018-05-21 Thread 0xEAB via Digitalmars-d-learn
What's the correct way to copy a `File` into another one in D? If `LockingTextReader` wasn't undocumented, I'd have gone for that approach: import std.algorithm.mutation : copy; import std.stdio : File, LockingTextReader; void main() { auto a = File("a.txt", "r"); auto b =

Re: UFCS syntax I never saw before.

2018-05-21 Thread Rubn via Digitalmars-d-learn
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 that i can do with this kind of call? I probably wouldn't use that. That wasn't what it was intended

UFCS syntax I never saw before.

2018-05-21 Thread SrMordred via Digitalmars-d-learn
After all this time I saw this: writeln = iota = 5; what?? I never saw that before! This is interesting, there is something useful that i can do with this kind of call?