Re: mmap file performance

2024-04-24 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 15 April 2024 at 16:13:41 UTC, Andy Valencia wrote: On Monday, 15 April 2024 at 08:05:25 UTC, Patrick Schluter wrote: The setup of a memory mapped file is relatively costly. For smaller files it is a net loss and read/write beats it hands down. Interestingly, this performance defic

Re: mmap file performance

2024-04-15 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 11 April 2024 at 00:24:44 UTC, Andy Valencia wrote: I wrote a "count newlines" based on mapped files. It used about twice the CPU of the version which just read 1 meg at a time. I thought something was amiss (needless slice indirection or something), so I wrote the code in C. It

Re: Idiomatic D using GC as a library writer

2022-12-05 Thread Patrick Schluter via Digitalmars-d-learn
On Sunday, 4 December 2022 at 23:37:39 UTC, Ali Çehreli wrote: On 12/4/22 15:25, Adam D Ruppe wrote: > which would trigger the write barrier. The thread isn't > allowed to complete this operation until the GC is done. According to my limited understanding of write barriers, the thread moving t

Re: Float rounding (in JSON)

2022-10-14 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 13 October 2022 at 19:27:22 UTC, Steven Schveighoffer wrote: On 10/13/22 3:00 PM, Sergey wrote: [...] It doesn't look really that far off. You can't expect floating point parsing to be exact, as floating point does not perfectly represent decimal numbers, especially when you get

Re: Replacing tango.text.Ascii.isearch

2022-10-13 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 13 October 2022 at 08:27:17 UTC, bauss wrote: On Wednesday, 5 October 2022 at 17:29:25 UTC, Steven Schveighoffer wrote: On 10/5/22 12:59 PM, torhu wrote: I need a case-insensitive check to see if a string contains another string for a "quick filter" feature. It should preferrably

Re: Programs in D are huge

2022-08-18 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 18 August 2022 at 17:15:12 UTC, rikki cattermole wrote: On 19/08/2022 4:56 AM, IGotD- wrote: BetterC means no arrays or strings library and usually in terminal tools you need to process text. Full D is wonderful for such task but betterC would be limited unless you want to write

Re: A look inside "filter" function defintion

2022-08-09 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 2 August 2022 at 12:39:41 UTC, pascal111 wrote: On Tuesday, 2 August 2022 at 04:06:30 UTC, frame wrote: On Monday, 1 August 2022 at 23:35:13 UTC, pascal111 wrote: This is the definition of "filter" function, and I think it called itself within its definition. I'm guessing how it wo

Re: Make shared static this() encoding table compilable

2022-03-17 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 17 March 2022 at 12:19:36 UTC, Patrick Schluter wrote: On Thursday, 17 March 2022 at 12:11:19 UTC, Patrick Schluter wrote: On Thursday, 17 March 2022 at 11:36:40 UTC, Patrick Schluter wrote: [...] Something akin to ```d auto lookup(ushort key) { return cp949[key-0x8141]; } [.

Re: Make shared static this() encoding table compilable

2022-03-17 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 17 March 2022 at 12:11:19 UTC, Patrick Schluter wrote: On Thursday, 17 March 2022 at 11:36:40 UTC, Patrick Schluter wrote: [...] Something akin to ```d auto lookup(ushort key) { return cp949[key-0x8141]; } [...] Takes 165 ms to compile with dmd 2.094.2 -O on [godbolt] with t

Re: Make shared static this() encoding table compilable

2022-03-17 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 17 March 2022 at 11:36:40 UTC, Patrick Schluter wrote: On Monday, 14 March 2022 at 09:40:00 UTC, zhad3 wrote: Hey everyone, I am in need of some help. I have written this Windows CP949 encoding table https://github.com/zhad3/zencoding/blob/main/windows949/source/zencoding/windows94

Re: Make shared static this() encoding table compilable

2022-03-17 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 14 March 2022 at 09:40:00 UTC, zhad3 wrote: Hey everyone, I am in need of some help. I have written this Windows CP949 encoding table https://github.com/zhad3/zencoding/blob/main/windows949/source/zencoding/windows949/table.d which is used to convert CP949 to UTF-16. After some rese

Re: ldc executable crashes with this code

2022-02-04 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 3 February 2022 at 02:01:34 UTC, forkit wrote: On Thursday, 3 February 2022 at 01:57:12 UTC, H. S. Teoh wrote: would be nice if the compiler told me something though :-( i.e. "hey, dude, you really wanna to that?" would be nice if programmers (C or D) learnt that a typecast m

Re: gdc or ldc for faster programs?

2022-01-31 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 22:41:35 UTC, Elronnd wrote: On Tuesday, 25 January 2022 at 22:33:37 UTC, H. S. Teoh wrote: interesting because idivl is known to be one of the slower instructions, but gdc nevertheless considered it not worthwhile to replace it, whereas ldc seems obsessed about

Re: How to print unicode characters (no library)?

2021-12-28 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 27 December 2021 at 07:12:24 UTC, rempas wrote: I don't understand that. Based on your calculations, the results should have been different. Also how are the numbers fixed? Like you said the amount of bytes of each encoding is not always standard for every character. Even if they w

Re: Wrong result with enum

2021-11-11 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 11 November 2021 at 05:37:05 UTC, Salih Dincer wrote: is this a issue, do you need to case? ```d enum tLimit = 10_000; // (1) true result enum wLimit = 100_000; // (2) wrong result void main() { size_t subTest1 = tLimit; assert(subTest1 == tLimit);/* no error */ siz

Re: Wrong result with enum

2021-11-11 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 11 November 2021 at 12:05:19 UTC, Tejas wrote: On Thursday, 11 November 2021 at 09:11:37 UTC, Salih Dincer wrote: On Thursday, 11 November 2021 at 06:34:16 UTC, Stanislav Blinov wrote: On Thursday, 11 November 2021 at 05:37:05 UTC, Salih Dincer wrote: is this a issue, do you need

Re: writef, compile-checked format, pointer

2021-08-09 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 9 August 2021 at 19:38:28 UTC, novice2 wrote: format!"fmt"() and writef!"fmt"() templates with compile-time checked format string not accept %X for pointers, but format() and writef() accept it https://run.dlang.io/is/aQ05Ux ``` void main() { import std.stdio: writefln; int x

Re: Is returning void functions inside void functions a feature or an artifact?

2021-08-03 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 2 August 2021 at 14:46:36 UTC, jfondren wrote: On Monday, 2 August 2021 at 14:31:45 UTC, Rekel wrote: [...] I don't know where you can find this in the docs, but what doesn't seem trivial about it? The type of the expression `print()` is void. That's the type that `doSomething` re

Re: issue with static foreach

2021-07-22 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 22 July 2021 at 03:43:44 UTC, someone wrote: ``` Now, if uncomment those two innocuous commented lines for the if (true == true) block: ```d labelSwitch: switch (lstrExchangeID) { static foreach (sstrExchangeID; gstrExchangeIDs) { mixin(r"case r"d, `"`, sstrExchangeID, `"`,

Re: wanting to try a GUI toolkit: needing some advice on which one to choose

2021-06-03 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 1 June 2021 at 20:56:05 UTC, someone wrote: On Tuesday, 1 June 2021 at 16:20:19 UTC, Ola Fosheim Grøstad wrote: [...] I wasn't considering/referring to content in the browser, this is an entirely different arena. [...] Thank you! I can only agree.

Re: Recommendations on avoiding range pipeline type hell

2021-05-16 Thread Patrick Schluter via Digitalmars-d-learn
On Sunday, 16 May 2021 at 09:55:31 UTC, Chris Piker wrote: On Sunday, 16 May 2021 at 09:17:47 UTC, Jordan Wilson wrote: Another example: ```d auto r = [iota(1,10).map!(a => a.to!int),iota(1,10).map!(a => a.to!int)]; # compile error ``` Hi Jordan Nice succinct example. Thanks for looking at

Re: Shutdown signals

2021-05-11 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 11 May 2021 at 06:44:57 UTC, Tim wrote: On Monday, 10 May 2021 at 23:55:18 UTC, Adam D. Ruppe wrote: [...] I don't know why I didn't find that. I was searching for the full name, maybe too specific? Thanks anyways, this is super helpful. I wish it was documented better though :(

Re: How to delete dynamic array ?

2021-03-18 Thread Patrick Schluter via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 16:20:06 UTC, Steven Schveighoffer wrote: It's important to understand that [] is just a practical syntax for a fat pointer. Thinking of [] just as a fancy pointer helps imho to clarify that the pointed to memory nature is independant of the pointer itself.

Re: Endianness - How to test code for portability

2021-03-13 Thread Patrick Schluter via Digitalmars-d-learn
On Friday, 12 March 2021 at 05:53:40 UTC, Preetpal wrote: In the portability section of the language spec, they talk about endianness (https://dlang.org/spec/portability.html#endianness) which refers "to the order in which multibyte types are stored." IMO if you wanted to actually be sure you

Re: where is the memory corruption?

2020-12-10 Thread Patrick Schluter via Digitalmars-d-learn
On Wednesday, 9 December 2020 at 21:28:04 UTC, Paul Backus wrote: On Wednesday, 9 December 2020 at 21:21:58 UTC, ag0aep6g wrote: D's wchar is not C's wchar_t. D's wchar is 16 bits wide. The width of C's wchar_t is implementation-defined. In your case it's probably 32 bits. In D, C's wchar_t

Re: Return values from auto function

2020-11-07 Thread Patrick Schluter via Digitalmars-d-learn
On Saturday, 7 November 2020 at 15:49:13 UTC, James Blachly wrote: ``` retval = i > 0 ? Success!int(i) : Failure("Sorry"); ``` casting each to `Result` compiles, but is verbose: ``` return i > 0 ? cast(Result) Success!int(i) : cast(Result) Failure("Sorry"); ``` ** Could someone more kno

Re: why `top` report is not consistent with the memory freed by core.stdc.stdlib : free?

2020-11-06 Thread Patrick Schluter via Digitalmars-d-learn
On Friday, 6 November 2020 at 06:17:42 UTC, mw wrote: Hi, I'm trying this: https://wiki.dlang.org/Memory_Management#Explicit_Class_Instance_Allocation using core.stdc.stdlib : malloc and free to manually manage memory, I tested two scenarios: -- malloc & free -- malloc only and I use Linux

Re: Getting Qte5 to work

2020-10-28 Thread Patrick Schluter via Digitalmars-d-learn
On Wednesday, 28 October 2020 at 06:52:35 UTC, evilrat wrote: Just an advice, Qte5 isn't well maintained, the other alternatives such as 'dlangui' also seems abandoned, so basically the only maintained UI library here is gtk-d, but there was recently a nice tutorial series written about it.

Re: Why was new(size_t s) { } deprecated in favor of an external allocator?

2020-10-14 Thread Patrick Schluter via Digitalmars-d-learn
On Wednesday, 14 October 2020 at 20:32:51 UTC, Max Haughton wrote: On Wednesday, 14 October 2020 at 20:27:10 UTC, Jack wrote: What was the reasoning behind this decision? Andrei's std::allocator talk from a few years ago at cppcon covers this (amongst other things) Yes, and what did he say?

Re: Why is BOM required to use unicode in tokens?

2020-09-18 Thread Patrick Schluter via Digitalmars-d-learn
On Wednesday, 16 September 2020 at 00:22:15 UTC, Steven Schveighoffer wrote: On 9/15/20 8:10 PM, James Blachly wrote: On 9/15/20 10:59 AM, Steven Schveighoffer wrote: [...] Steve: It sounds as if the spec is correct but the glyph (codepoint?) range is outdated. If this is the case, it would

Re: Generating struct .init at run time?

2020-07-02 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 2 July 2020 at 07:51:29 UTC, Ali Çehreli wrote: Normally, struct .init values are known at compile time. Unfortunately, they add to binary size: [...] memset() is the function you want. The initializer is an element generated in the data segment (or in a read only segment) that w

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

2020-06-18 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 18 June 2020 at 13:58:33 UTC, Dukc wrote: On Thursday, 18 June 2020 at 13:57:39 UTC, Dukc wrote: if (not!(abra && cadabra)) ... if (not(abra && cadabra)) ... Which is a quite a complicated way to write if (!(abra && cadabra)) ...

String interpolation

2020-05-21 Thread Patrick Schluter via Digitalmars-d-learn
https://forum.dlang.org/post/prlulfqvxrgrdzxot...@forum.dlang.org On Tuesday, 10 November 2015 at 11:22:56 UTC, wobbles wrote: int a = 1; int b = 4; writefln("The number %s is less than %s", a, b); writeln("The number ",a, " is less than ",b);

Re: Compilation memory use

2020-05-05 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 4 May 2020 at 17:00:21 UTC, Anonymouse wrote: TL;DR: Is there a way to tell what module or other section of a codebase is eating memory when compiling? [...] maybe with the massif tool of valgrind?

Re: How does one read file line by line / upto a specific delimeter of an MmFile?

2020-03-16 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 16 March 2020 at 13:09:08 UTC, Adnan wrote: On Sunday, 15 March 2020 at 00:37:35 UTC, H. S. Teoh wrote: On Sat, Mar 14, 2020 at 10:37:37PM +, Adnan via Digitalmars-d-learn wrote: [...] That's because a memory-mapped file appears directly in your program's memory address space

Re: CT regex in AA at compile time

2020-01-07 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 7 January 2020 at 15:40:58 UTC, Taylor Hillegeist wrote: I'm trying to trick the following code snippet into compilation. enum TokenType{ //Terminal Plus, Minus, LPer, RPer, Number, } static auto Regexes =[ TokenType.Plus: ctRegex!

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-30 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 30 December 2019 at 14:59:22 UTC, bachmeier wrote: On Monday, 30 December 2019 at 06:43:03 UTC, H. S. Teoh wrote: [...] Another way in which the IDE is "heavy" is the amount of overhead for beginning/occasional users. I like that I can get someone started using D like this: 1.

Re: What kind of Editor, IDE you are using and which one do you like for D language?

2019-12-30 Thread Patrick Schluter via Digitalmars-d-learn
On Sunday, 29 December 2019 at 14:41:46 UTC, Russel Winder wrote: On Sat, 2019-12-28 at 22:01 +, p.shkadzko via Digitalmars-d-learn wrote: […] p.s. I found it quite satisfying that D does not really need an IDE, you will be fine even with nano. The fundamental issue with these all batte

Re: Template specialized functions creating runtime instructions?

2019-08-21 Thread Patrick Schluter via Digitalmars-d-learn
On Wednesday, 21 August 2019 at 00:11:23 UTC, ads wrote: On Wednesday, 21 August 2019 at 00:04:37 UTC, H. S. Teoh wrote: On Tue, Aug 20, 2019 at 11:48:04PM +, ads via Digitalmars-d-learn wrote: [...] 2) Deducing the string as you describe would require CTFE (compile-time function evaluation

Re: How should I sort a doubly linked list the D way?

2019-08-14 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 13 August 2019 at 18:28:35 UTC, Ali Çehreli wrote: On 08/13/2019 10:33 AM, Mirjam Akkersdijk wrote: > On Tuesday, 13 August 2019 at 14:04:45 UTC, Sebastiaan Koppe wrote: >> Convert the nodes into an D array, sort the array with nodes.sort!"a.x >> < b.x" and then iterate the array and

Re: Question about ubyte x overflow, any safe way?

2019-08-05 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 5 August 2019 at 18:21:36 UTC, matheus wrote: On Monday, 5 August 2019 at 01:41:06 UTC, Ali Çehreli wrote: ... Two examples with foreach and ranges. The 'ubyte.max + 1' expression is int. The compiler casts to ubyte (because we typed ubyte) in the foreach and we cast to ubyte in the

Re: Is there a way to slice non-array type in @safe?

2019-07-12 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 11 July 2019 at 19:35:50 UTC, Stefanos Baziotis wrote: On Thursday, 11 July 2019 at 18:46:57 UTC, Paul Backus wrote: Casting from one type of pointer to another and slicing a pointer are both @system, by design. Yes, I'm aware, there are no pointers in the code. The pointer was

Re: Why are immutable array literals heap allocated?

2019-07-07 Thread Patrick Schluter via Digitalmars-d-learn
On Saturday, 6 July 2019 at 09:56:57 UTC, ag0aep6g wrote: On 06.07.19 01:12, Patrick Schluter wrote: On Friday, 5 July 2019 at 23:08:04 UTC, Patrick Schluter wrote: On Thursday, 4 July 2019 at 10:56:50 UTC, Nick Treleaven wrote: immutable(int[]) f() @nogc {     return [1,2]; } [...] and it

Re: Why are immutable array literals heap allocated?

2019-07-05 Thread Patrick Schluter via Digitalmars-d-learn
On Friday, 5 July 2019 at 23:08:04 UTC, Patrick Schluter wrote: On Thursday, 4 July 2019 at 10:56:50 UTC, Nick Treleaven wrote: immutable(int[]) f() @nogc { return [1,2]; } onlineapp.d(2): Error: array literal in `@nogc` function `onlineapp.f` may cause a GC allocation This makes dynamic

Re: Why are immutable array literals heap allocated?

2019-07-05 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 4 July 2019 at 10:56:50 UTC, Nick Treleaven wrote: immutable(int[]) f() @nogc { return [1,2]; } onlineapp.d(2): Error: array literal in `@nogc` function `onlineapp.f` may cause a GC allocation This makes dynamic array literals unusable with @nogc, and adds to GC pressure for

Re: [OT] Re: 1 - 17 ms, 553 ╬╝s, and 1 hnsec

2019-05-27 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 21 May 2019 at 02:12:10 UTC, Les De Ridder wrote: On Sunday, 19 May 2019 at 12:24:28 UTC, Patrick Schluter wrote: On Saturday, 18 May 2019 at 21:05:13 UTC, Les De Ridder wrote: On Saturday, 18 May 2019 at 20:34:33 UTC, Patrick Schluter wrote: * hurrah for French keyboard which has a

[OT] Re: 1 - 17 ms, 553 ╬╝s, and 1 hnsec

2019-05-19 Thread Patrick Schluter via Digitalmars-d-learn
On Saturday, 18 May 2019 at 21:05:13 UTC, Les De Ridder wrote: On Saturday, 18 May 2019 at 20:34:33 UTC, Patrick Schluter wrote: * hurrah for French keyboard which has a rarely used µ key, but none for Ç a frequent character of the language. That's the lowercase ç. The uppercase Ç is not di

Re: 1 - 17 ms, 553 ╬╝s, and 1 hnsec

2019-05-18 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 16 May 2019 at 15:19:03 UTC, Alex wrote: 1 - 17 ms, 553 ╬╝s, and 1 hnsec That's µs* for micro-seconds. * hurrah for French keyboard which has a rarely used µ key, but none for Ç a frequent character of the language. WTH!! is there any way to just get a normal u rather than so

Re: Compile time mapping

2019-05-12 Thread Patrick Schluter via Digitalmars-d-learn
On Saturday, 11 May 2019 at 15:48:44 UTC, Bogdan wrote: What would be the most straight-forward way of mapping the members of an enum to the members of another enum (one-to-one mapping) at compile time? An example of a Initial enum that creates a derived enum using the same element names but

Re: DMD different compiler behaviour on Linux and Windows

2019-04-25 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 25 April 2019 at 20:18:28 UTC, Zans wrote: import std.stdio; void main() { char[] mychars; mychars ~= 'a'; long index = 0L; writeln(mychars[index]); } Why would the code above compile perfectly on Linux (Ubuntu 16.04), however it would produce the following error o

Re: How to debug long-lived D program memory usage?

2019-04-21 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 18 April 2019 at 12:00:10 UTC, ikod wrote: On Wednesday, 17 April 2019 at 16:27:02 UTC, Adam D. Ruppe wrote: D programs are a vital part of my home computer infrastructure. I run some 60 D processes at almost any time and have recently been running out of memory. I usually ru

Re: Any easy way to extract files to memory buffer?

2019-03-19 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 18 March 2019 at 23:40:02 UTC, Michelle Long wrote: On Monday, 18 March 2019 at 23:01:27 UTC, H. S. Teoh wrote: On Mon, Mar 18, 2019 at 10:38:17PM +, Michelle Long via Digitalmars-d-learn wrote: On Monday, 18 March 2019 at 21:14:05 UTC, Vladimir Panteleev wrote: > On Monday, 18 M

Re: Should D file end with newline?

2019-02-15 Thread Patrick Schluter via Digitalmars-d-learn
On Wednesday, 13 February 2019 at 05:13:12 UTC, sarn wrote: On Tuesday, 12 February 2019 at 20:03:09 UTC, Jonathan M Davis wrote: So, I'd say that it's safe to say that dmd The whole thing just seems like a weird requirement that really shouldn't be there, Like I said in the first reply, FWIW

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

2019-01-20 Thread Patrick Schluter via Digitalmars-d-learn
On Sunday, 20 January 2019 at 09:27:33 UTC, Jonathan M Davis wrote: 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: > [...] At least 68030 (or 68020+68851) would be necess

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

2019-01-19 Thread Patrick Schluter via Digitalmars-d-learn
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 think DMD would be able for this on the other hand I think GDC can, am I right? If yes would be any restriction of

Re: Bitwise rotate of integral

2019-01-08 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 8 January 2019 at 12:35:16 UTC, H. S. Teoh wrote: On Tue, Jan 08, 2019 at 09:15:09AM +, Patrick Schluter via Digitalmars-d-learn wrote: On Monday, 7 January 2019 at 23:20:57 UTC, H. S. Teoh wrote: [...] > [...] Are you sure it's dmd looking for the pattern. Playing w

Re: signed nibble

2019-01-08 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 8 January 2019 at 10:32:25 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 8 January 2019 at 09:30:14 UTC, Patrick Schluter wrote: [...] Heh, I remember they had a friday-night trivia contest at the mid-90s students pub (for natural sciences) where one of the questions was the opcode

Re: signed nibble

2019-01-08 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 7 January 2019 at 21:46:21 UTC, H. S. Teoh wrote: On Mon, Jan 07, 2019 at 08:41:32PM +, Patrick Schluter via Digitalmars-d-learn wrote: On Monday, 7 January 2019 at 20:28:21 UTC, H. S. Teoh wrote: > On Mon, Jan 07, 2019 at 08:06:17PM +0000, Patrick Schluter > via Digital

Re: Bitwise rotate of integral

2019-01-08 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 7 January 2019 at 23:20:57 UTC, H. S. Teoh wrote: On Mon, Jan 07, 2019 at 11:13:37PM +, Guillaume Piolat via Digitalmars-d-learn wrote: On Monday, 7 January 2019 at 14:39:07 UTC, Per Nordlöw wrote: > What's the preferred way of doing bitwise rotate of an > integral value in D? >

Re: signed nibble

2019-01-07 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 7 January 2019 at 20:28:21 UTC, H. S. Teoh wrote: On Mon, Jan 07, 2019 at 08:06:17PM +, Patrick Schluter via Digitalmars-d-learn wrote: On Monday, 7 January 2019 at 18:56:17 UTC, H. S. Teoh wrote: > On Mon, Jan 07, 2019 at 06:42:13PM +0000, Patrick Schluter > via Digital

Re: signed nibble

2019-01-07 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 7 January 2019 at 18:56:17 UTC, H. S. Teoh wrote: On Mon, Jan 07, 2019 at 06:42:13PM +, Patrick Schluter via Digitalmars-d-learn wrote: On Monday, 7 January 2019 at 17:23:19 UTC, Michelle Long wrote: > Is there any direct way to convert a signed nibble in to a > signed byt

Re: signed nibble

2019-01-07 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 7 January 2019 at 18:47:04 UTC, Adam D. Ruppe wrote: On Monday, 7 January 2019 at 18:42:13 UTC, Patrick Schluter wrote: byte b = nibble | ((nibble & 0x40)?0xF0:0); don't you mean & 0x80 ? He asked for signed nybble. So mine is wrong and yours also :-) It's obviously 0x08 for the

Re: signed nibble

2019-01-07 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 7 January 2019 at 17:23:19 UTC, Michelle Long wrote: Is there any direct way to convert a signed nibble in to a signed byte with the same absolute value? Obviously I can do some bit comparisons but just curious if there is a very quick way. byte b = nibble | ((nibble & 0x40)?0xF0:0

Re: Bug in shifting

2018-12-19 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 18 December 2018 at 20:33:43 UTC, Rainer Schuetze wrote: On 14/12/2018 02:56, Steven Schveighoffer wrote: On 12/13/18 7:16 PM, Michelle Long wrote: byte x = 0xF; ulong y = x >> 60; Surely you meant x << 60? As x >> 60 is going to be 0, even with a ulong. It doesn't work as in

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

2018-11-21 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 20 November 2018 at 23:14:27 UTC, Johan Engelen wrote: On Tuesday, 20 November 2018 at 19:11:46 UTC, Steven Schveighoffer wrote: On 11/20/18 1:04 PM, Johan Engelen wrote: D does not make dereferencing on class objects explicit, which makes it harder to see where the dereference is

Re: Why is stdio ... stdio?

2018-11-10 Thread Patrick Schluter via Digitalmars-d-learn
On Saturday, 10 November 2018 at 18:47:19 UTC, Chris Katko wrote: On Saturday, 10 November 2018 at 13:53:14 UTC, Kagamin wrote: [...] There is another possibility. Have the website run (fallible) heuristics to detect a snippet of code and automatically generate it. That would leave the maili

Re: Converting a character to upper case in string

2018-09-22 Thread Patrick Schluter via Digitalmars-d-learn
On Saturday, 22 September 2018 at 06:01:20 UTC, Vladimir Panteleev wrote: On Friday, 21 September 2018 at 12:15:52 UTC, NX wrote: How can I properly convert a character, say, first one to upper case in a unicode correct manner? That would depend on how you'd define correctness. If your applic

Re: First run after build on Windows is slow

2018-06-26 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 26 June 2018 at 12:58:29 UTC, Adam D. Ruppe wrote: On Tuesday, 26 June 2018 at 12:40:05 UTC, phs wrote: Although, it's a little bit strange because I have never had this issue with my C++ development. The c++ compiler and runtime libraries are common enough that the antivirus real

Re: OT: Parsing object files for fun and profit

2018-05-31 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 31 May 2018 at 18:33:37 UTC, Ali Çehreli wrote: On 05/31/2018 09:49 AM, Adam D. Ruppe wrote: > Should be fairly simple to follow, just realize that the image is a 2d > block for each char and that's why there's all those multiplies and > divides. I remember doing similar things wit

Re: Compile time initialization of AA

2018-03-24 Thread Patrick Schluter via Digitalmars-d-learn
On Friday, 23 March 2018 at 22:43:47 UTC, Xavier Bigand wrote: I am trying to initialize an global immutable associative array of structs, but it doesn't compile. I am getting the following error message : "Error: not an associative array initializer". As I really need to store my data for a c

Re: sys_write in betterC doesn't write anything

2018-02-03 Thread Patrick Schluter via Digitalmars-d-learn
On Saturday, 3 February 2018 at 15:38:19 UTC, Basile B. wrote: On Saturday, 3 February 2018 at 15:30:10 UTC, Basile B. wrote: [...] okay solved: module runnable; __gshared static msg = "betterC\n"; __gshared static len = 8; extern(C) int main(int argc, char** args) { asm {

Re: How to proceed with learning to code Windows desktop applications?

2018-01-29 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 30 January 2018 at 06:25:52 UTC, rikki cattermole wrote: On 30/01/2018 5:47 AM, thedeemon wrote: On Tuesday, 30 January 2018 at 03:07:38 UTC, rikki cattermole wrote: But since Windows is the only platform mentioned or desired for, everything you need is in WinAPI! It's like sayi

Re: String Type Usage. String vs DString vs WString

2018-01-15 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 15 January 2018 at 04:27:15 UTC, Jonathan M Davis wrote: On Monday, January 15, 2018 03:14:02 Tony via Digitalmars-d-learn wrote: On Monday, 15 January 2018 at 02:09:25 UTC, rikki cattermole wrote: > Unicode has three main variants, UTF-8, UTF-16 and UTF-32. > The size of a code poi

Re: Consequences of casting away immutable from pointers

2018-01-05 Thread Patrick Schluter via Digitalmars-d-learn
On Friday, 5 January 2018 at 18:13:11 UTC, H. S. Teoh wrote: On Fri, Jan 05, 2018 at 05:50:34PM +, jmh530 via Digitalmars-d-learn wrote: Be careful with that: class C { int x; } immutable C c = new C(5); auto i = c.x; C y = cast(C) c; y.x = 10;

Re: Efficient way to pass struct as parameter

2018-01-03 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 2 January 2018 at 23:27:22 UTC, H. S. Teoh wrote: When it comes to optimization, there are 3 rules: profile, profile, profile. I used to heavily hand-"optimize" my code a lot (I come from a strong C/C++ background -- premature optimization seems to be a common malady among us in

Re: std.file and non-English filename in Windows

2018-01-01 Thread Patrick Schluter via Digitalmars-d-learn
On Sunday, 31 December 2017 at 18:21:29 UTC, Domain wrote: In Windows, exists, rename, copy will report file not exists when you input non-English filename, such as Chinese 中文.txt It's unclear what your problem is but here a wild guess. Windows API's for Unicode use UTF-16 as far as I know. St

Re: why ushort alias casted to int?

2017-12-22 Thread Patrick Schluter via Digitalmars-d-learn
On Friday, 22 December 2017 at 10:14:48 UTC, crimaniak wrote: My code: alias MemSize = ushort; struct MemRegion { MemSize start; MemSize length; @property MemSize end() const { return start+length; } } Error: cannot implicitly convert expression `cast(int)this.start +

Re: Sort characters in string

2017-12-07 Thread Patrick Schluter via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 15:12:22 UTC, Steven Schveighoffer wrote: On 12/6/17 4:34 AM, Ola Fosheim Grøstad wrote: On Wednesday, 6 December 2017 at 09:24:33 UTC, Jonathan M Davis wrote: UTF-32 on the other hand is guaranteed to have a code unit be a full code point. I don't think the s

Re: Sort characters in string

2017-12-07 Thread Patrick Schluter via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 09:34:48 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 6 December 2017 at 09:24:33 UTC, Jonathan M Davis wrote: UTF-32 on the other hand is guaranteed to have a code unit be a full code point. I don't think the standard says that? Isn't this only because the c

Re: Sort characters in string

2017-12-07 Thread Patrick Schluter via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 09:24:33 UTC, Jonathan M Davis wrote: a full code point (IIRC, 1 - 6 code units for UTF-8 and 1 - 2 for UTF-16), YDNRC, 1 - 4 code units for UTF-8. Unicode is defined only up to U+10. Everything above is illegal.

Re: git workflow for D

2017-12-04 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 4 December 2017 at 11:51:42 UTC, Nick Sabalausky (Abscissa) wrote: On 12/03/2017 03:05 PM, bitwise wrote: One thing to keep in mind: Any time you're talking about moving anything from one repo to another, there's exactly two basic primitives there: push and pull. Both of them are ba

Re: git workflow for D

2017-12-03 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 4 December 2017 at 01:54:57 UTC, ketmar wrote: Basile B. wrote: On Sunday, 3 December 2017 at 22:22:47 UTC, Arun Chandrasekaran wrote: Git CLI is arcane and esoteric. I've lost my commits before (yeah, my mistake). Who hasn't ;) me. Happened to me last time because i tried a com

Re: scope(exit) and Ctrl-C

2017-12-02 Thread Patrick Schluter via Digitalmars-d-learn
On Saturday, 2 December 2017 at 04:49:26 UTC, H. S. Teoh wrote: On Sat, Dec 02, 2017 at 04:38:29AM +, Adam D. Ruppe via Digitalmars-d-learn wrote: [...] Signal handlers can potentially be invoked while inside a non-reentrant libc or OS function, so trying to do anything that (indirectly

Re: Private imports and Objects

2017-11-30 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 30 November 2017 at 06:44:43 UTC, Jonathan M Davis wrote: Object exists primarily because D didn't originally have templates, and when you don't have templates, having a single base class is the only way to have a function accept any class, and for something like a container, you'd

Re: ESR on post-C landscape

2017-11-16 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 16:38:58 UTC, Ola Fosheim Grostad wrote: On Tuesday, 14 November 2017 at 11:55:17 UTC, codephantom wrote: [...] Well, in another thread he talked about the Tango split, so not sure where he is coming from. [...] No, the starting point for C++ was that Simu

Re: ESR on post-C landscape

2017-11-16 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 14 November 2017 at 09:43:07 UTC, Ola Fosheim Grøstad wrote: On Tuesday, 14 November 2017 at 06:32:55 UTC, lobo wrote: "[snip]...Then came the day we discovered that a person we incautiously gave commit privileges to had fucked up the games’s AI core. It became apparent that I was t

Re: What the hell is wrong with D?

2017-09-23 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 18:34:13 UTC, Brad Anderson wrote: On Tuesday, 19 September 2017 at 18:17:47 UTC, jmh530 wrote: On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta wrote: Thanks for wasting some of my life... Just curious about who will justify the behavior and wha

Re: What the hell is wrong with D?

2017-09-22 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 18:34:13 UTC, Brad Anderson wrote: On Tuesday, 19 September 2017 at 18:17:47 UTC, jmh530 wrote: On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta wrote: Thanks for wasting some of my life... Just curious about who will justify the behavior and wha

Re: 24-bit int

2017-09-03 Thread Patrick Schluter via Digitalmars-d-learn
On Friday, 1 September 2017 at 22:10:43 UTC, Biotronic wrote: On Friday, 1 September 2017 at 19:39:14 UTC, EntangledQuanta wrote: Is there a way to create a 24-bit int? One that for all practical purposes acts as such? This is for 24-bit stuff like audio. It would respect endianness, allow for

Re: If structures places data to stack why we do not getting stackoverflow on array of structures?

2017-08-16 Thread Patrick Schluter via Digitalmars-d-learn
On Wednesday, 16 August 2017 at 07:39:01 UTC, Suliman wrote: On the heap, unless you are allocating it via e.g. alloca. If struct MyStruct { int x; int y; } MyStruct mystruct; is located on stack, why: MyStruct [] mystructs; should located on heap? because in D MyStruct [] mystructs;

Re: Why structs and classes instanciations are made differently ?

2017-07-26 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 24 July 2017 at 17:42:30 UTC, Steven Schveighoffer wrote: On 7/24/17 11:45 AM, Houdini wrote: On Monday, 24 July 2017 at 15:41:33 UTC, Steven Schveighoffer wrote: Because types with inheritance generally don't work right if you pass by value (i.e. the slicing problem). structs do

Re: Funny issue with casting double to ulong

2017-07-04 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 4 July 2017 at 00:35:10 UTC, H. S. Teoh wrote: On Mon, Jul 03, 2017 at 07:13:45AM +, Era Scarecrow via Digitalmars-d-learn wrote: On Monday, 3 July 2017 at 06:20:22 UTC, H. S. Teoh wrote: [...] > I don't think there's a way to change how the FPU works -- > the hardware is coded

Re: Funny issue with casting double to ulong

2017-07-03 Thread Patrick Schluter via Digitalmars-d-learn
On Monday, 3 July 2017 at 05:38:56 UTC, Era Scarecrow wrote: On Monday, 3 July 2017 at 03:57:25 UTC, Basile B wrote: 6.251 has no perfect double representation. It's real value is: I almost wonder if a BCD, fixed length or alternative for floating point should be an option... Either library,

Re: How to implement opCmp?

2017-06-13 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 13 June 2017 at 16:49:14 UTC, H. S. Teoh wrote: On Tue, Jun 13, 2017 at 10:51:40AM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote: [...] I think Andrei has a nice way to do opCmp for integers that's a simple subtraction and negation or something like that. [...] In theor

Re: Use template functions within mixin

2017-06-06 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 6 June 2017 at 15:00:50 UTC, Timoses wrote: Hey there, I'm wondering how I can use a template function within my mixin: ``` ubyte[] value = x[33, 3a,3f, d4]; foreach (type; TypeTuple!("int", "unsigned int", "byte")) {

Re: std.path.buildPath

2017-06-04 Thread Patrick Schluter via Digitalmars-d-learn
On Sunday, 4 June 2017 at 15:56:58 UTC, Jacob Carlborg wrote: On 2017-06-04 07:44, Jesse Phillips wrote: What is your expected behavior? Throw an exception? You can't really append an absolute path to another. Of course you can. I expect buildPath("/foo", "/bar") to result in "/foo/bar". Th

Re: Creating and loading D plugins in D app

2017-06-03 Thread Patrick Schluter via Digitalmars-d-learn
On Saturday, 3 June 2017 at 09:41:58 UTC, aberba wrote: On Friday, 2 June 2017 at 16:36:34 UTC, H. S. Teoh wrote: On Fri, Jun 02, 2017 at 12:19:48PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: On Friday, 2 June 2017 at 11:09:05 UTC, aberba wrote: > 1. Get shared libs to work in D (the b

Re: howto count lines - fast

2017-05-31 Thread Patrick Schluter via Digitalmars-d-learn
On Thursday, 1 June 2017 at 04:39:17 UTC, Jonathan M Davis wrote: On Wednesday, May 31, 2017 16:03:54 H. S. Teoh via Digitalmars-d-learn wrote: [...] Digitalmars-d-learn wrote: [...] If you're really trying to make it fast, there may be something that you can do with SIMD. IIRC, Brian Schot

Re: howto count lines - fast

2017-05-31 Thread Patrick Schluter via Digitalmars-d-learn
On Wednesday, 31 May 2017 at 23:03:54 UTC, H. S. Teoh wrote: On Wed, May 31, 2017 at 03:46:17PM -0700, Jonathan M Davis via Digitalmars-d-learn wrote: On Wednesday, May 31, 2017 12:13:04 H. S. Teoh via Digitalmars-d-learn wrote: > I did some digging around, and it seems that wc is using > glibc

Re: howto count lines - fast

2017-05-31 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 30 May 2017 at 23:41:01 UTC, H. S. Teoh wrote: On Tue, May 30, 2017 at 08:02:38PM +, Nitram via Digitalmars-d-learn wrote: After reading https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/ , i was wondering how fast one can do a simple "wc -l" in D. size_t lineCo

  1   2   >