Spec for the ‘locality’ parameter to the LDC and GDC builtin magic functions for accessing special CPU prefetch instructions

2023-08-19 Thread Cecil Ward via Digitalmars-d-learn
I’m trying to write a cross-platform function that gives access to the CPU’s prefetch instructions such as x86 prefetch0/1/2/prefetchnta and AAarch64 too. I’ve found that the GDC and LDC compilers provide builtin magic functions for this, and are what I need. I am trying to put together a pl

Test post - please ignore

2023-08-13 Thread Cecil Ward via Digitalmars-d-learn
I have been getting error messages when I try to post to the forum. This is just a test, so please ignore.

Setting up a final switch from a list

2023-08-02 Thread Cecil Ward via Digitalmars-d-learn
Am I right in thinking that final switch can be used to check that all the elements in an enum are handled in cases? Thinking that this is a worthwhile safety check, I’d like to convert an existing list into an enum for use in a final switch. I have an existing list which I use elsewhere, e

Re: Anyone help me with a stack dump?

2023-07-31 Thread Cecil Ward via Digitalmars-d-learn
On Monday, 31 July 2023 at 14:38:52 UTC, ryuukk_ wrote: Your problem lies at line 1541 You can use `ddemangle` executable to make mangled names readable, i don't know if it comes with the compiler ``` _platform_memmove pure nothrow ref @trusted wchar[] core.internal.array.appending._d_arraya

Anyone help me with a stack dump?

2023-07-31 Thread Cecil Ward via Digitalmars-d-learn
The unitttests that I have just put in crash spectacularly with an access violation. I built the code with LDC for Aarch64 / OSX and I fired up lldb. I now have to learn lldb quick. (BTW Where can I get an x86 / linux build of lldb or similar ?) This is the stack dump, and I could do with some

Re: Unicode in strings

2023-07-27 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 27 July 2023 at 22:35:00 UTC, Adam D Ruppe wrote: On Thursday, 27 July 2023 at 22:15:47 UTC, Cecil Ward wrote: How do I get a wstring or dstring with a code point of 0xA0 in it ? note that you don't need wstring and dstring to express all unicode strings. I realised that I was

Re: What is a dchar ?

2023-07-27 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 26 July 2023 at 01:56:28 UTC, Richard (Rikki) Andrew Cattermole wrote: The spec says they are unsigned, so if ldc is using sign extension, that is probably a bug. My fault, I reread the code and the sign-extension applies to something else, coincidentally right where I was lookin

Re: Giant template - changing types everywhere

2023-07-14 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 14 July 2023 at 14:15:29 UTC, Steven Schveighoffer wrote: On 7/14/23 1:51 AM, Cecil Ward wrote: [...] So templates don't automatically instantiate, you have to specify them. And then if your function is inside the template, to access it, you will need to do: [...] I can give y

Re: Giant template - changing types everywhere

2023-07-13 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 14 July 2023 at 05:09:58 UTC, Cecil Ward wrote: On Friday, 14 July 2023 at 05:05:27 UTC, Cecil Ward wrote: On Friday, 14 July 2023 at 05:03:31 UTC, Cecil Ward wrote: On Friday, 14 July 2023 at 01:34:54 UTC, Steven Schveighoffer wrote: [...] The way I can see it going is a giant te

Re: Giant template - changing types everywhere

2023-07-13 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 14 July 2023 at 05:05:27 UTC, Cecil Ward wrote: On Friday, 14 July 2023 at 05:03:31 UTC, Cecil Ward wrote: On Friday, 14 July 2023 at 01:34:54 UTC, Steven Schveighoffer wrote: [...] The way I can see it going is a giant template encompassing pretty much the whole file. Does that m

Re: Giant template - changing types everywhere

2023-07-13 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 14 July 2023 at 05:03:31 UTC, Cecil Ward wrote: On Friday, 14 July 2023 at 01:34:54 UTC, Steven Schveighoffer wrote: [...] The way I can see it going is a giant template encompassing pretty much the whole file. Does that mean that the caller who calls my one public function does s

Re: Giant template - changing types everywhere

2023-07-13 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 14 July 2023 at 01:34:54 UTC, Steven Schveighoffer wrote: On 7/13/23 8:08 PM, Cecil Ward wrote: What I really want to do though is provide one single templated function with the kind of characters / strings as a parameter. I want to have something like T Transform( T )( T str) call

Giant template - changing types everywhere

2023-07-13 Thread Cecil Ward via Digitalmars-d-learn
Some advice on a couple of points. I have been working on a module that works on either dchar / dstrings or wchar / wstrings with just two changes of alias definitions and a recompile. What I really want to do though is provide one single templated function with the kind of characters / stri

Re: Installing GDC / Linux / x86-64 when apt-get doesn’t work

2023-07-10 Thread Cecil Ward via Digitalmars-d-learn
On Tuesday, 11 July 2023 at 05:49:36 UTC, Sergey wrote: On Tuesday, 11 July 2023 at 04:11:38 UTC, Cecil Ward wrote: I’m trying to install GDC on a new Linux box and I don’t know what I’m doing. Background: I have installed LDC successfully and have installed GDC on a Raspberry Pi using 32-bit A

Re: Installing GDC / Linux / x86-64 when apt-get doesn’t work

2023-07-10 Thread Cecil Ward via Digitalmars-d-learn
On Tuesday, 11 July 2023 at 04:11:38 UTC, Cecil Ward wrote: I’m trying to install GDC on a new Linux box and I don’t know what I’m doing. Background: I have installed LDC successfully and have installed GDC on a Raspberry Pi using 32-bit ARM. For some reason the apt-get command doesn’t work on

Installing GDC / Linux / x86-64 when apt-get doesn’t work

2023-07-10 Thread Cecil Ward via Digitalmars-d-learn
I’m trying to install GDC on a new Linux box and I don’t know what I’m doing. Background: I have installed LDC successfully and have installed GDC on a Raspberry Pi using 32-bit ARM. For some reason the apt-get command doesn’t work on this machine, don’t know why. The machine is a virtual serv

Pre-expanding alloc cell(s) / reserving space for an associative array

2023-07-09 Thread Cecil Ward via Digitalmars-d-learn
Before I posted a question about avoiding unnecessary allocs/reallocs when adding entries to an array like so uint[ dstring ] arr; when I build it up from nothing with successive insertions. The array is accessed by a key that is a dstring. I was told that I can’t use .reserve or the like

Re: Inlined functions and their original bodies - bloat

2023-07-09 Thread Cecil Ward via Digitalmars-d-learn
On Sunday, 9 July 2023 at 18:04:13 UTC, Cecil Ward wrote: I have a program where the various routines are all marked pragma( inline, true ). The compiler obeys this but the LDC and GDC compilers still compile the function bodies even though the bodies are not needed as they are supposed to be ‘

Re: Toolchain with ldc and AArch64 OSX

2023-07-09 Thread Cecil Ward via Digitalmars-d-learn
On Sunday, 9 July 2023 at 05:32:56 UTC, Danilo Krahn wrote: On Saturday, 24 June 2023 at 15:16:37 UTC, Cecil Ward wrote: I have LDC running on an ARM Mac. If anyone else out there is an LDC or GDC user, could you knock up a quick shell program to compile and link a .d file to produce an executa

Re: Dynamic array of strings and appending a zero length array

2023-07-09 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 8 July 2023 at 20:01:08 UTC, H. S. Teoh wrote: On Sat, Jul 08, 2023 at 05:15:26PM +, Cecil Ward via Digitalmars-d-learn wrote: I have a dynamic array of dstrings and I’m spending dstrings to it. At one point I need to append a zero-length string just to increase the length of

Re: Dynamic array of strings and appending a zero length array

2023-07-08 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 8 July 2023 at 17:15:26 UTC, Cecil Ward wrote: I have a dynamic array of dstrings and I’m spending dstrings to it. At one point I need to append a zero-length string just to increase the length of the array by one but I can’t have a slot containing garbage. I thought about ++arr.le

Dynamic array of strings and appending a zero length array

2023-07-08 Thread Cecil Ward via Digitalmars-d-learn
I have a dynamic array of dstrings and I’m spending dstrings to it. At one point I need to append a zero-length string just to increase the length of the array by one but I can’t have a slot containing garbage. I thought about ++arr.length - would that work, while giving me valid contents to th

Re: Public visible entities published by a module

2023-07-07 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 7 July 2023 at 19:49:06 UTC, Anonymouse wrote: On Friday, 7 July 2023 at 17:46:09 UTC, Cecil Ward wrote: [...] I did this. It's super ugly and even has `__traits(compiles)` in there, but as a quick and dirty solution it served well enough. ```d void printPublicMembersOfModule(st

Public visible entities published by a module

2023-07-07 Thread Cecil Ward via Digitalmars-d-learn
A bit of a weird question, and I’m not sure how to word it. Say I have a module, and I’d like to list / enumerate all the public visible things that the module exports / publishes ‘ makes visible. Is there a way of doing that ? Of getting that kind of listing? I’m wondering about information

Re: First module

2023-07-07 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 7 July 2023 at 14:18:35 UTC, Richard (Rikki) Andrew Cattermole wrote: 1. Compiler reads in source code provided on cli 2. It gets parsed 3. imports get looked up, if not already read in, looks in the directories provided by -I based upon the full module + package import statement 4.

Re: First module

2023-07-07 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 6 July 2023 at 21:10:39 UTC, Cecil Ward wrote: I’ve written my first non-trivial module in D. See other thread. https://forum.dlang.org/thread/pfjpqcywxrmxwsncy...@forum.dlang.org I’d like to set up something to call it from other modules, and specifically I’d like to see if inli

Re: Advice on debugging possible exception or crash

2023-07-06 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 6 July 2023 at 19:53:39 UTC, Chris Katko wrote: On Thursday, 6 July 2023 at 06:00:04 UTC, Cecil Ward wrote: My program is instrumented with a load of writeflns. At one point it looks as though it suddenly quits prematurely because the expected writeflns are not seen in the output.

First module

2023-07-06 Thread Cecil Ward via Digitalmars-d-learn
I’ve written my first non-trivial module in D. See other thread. https://forum.dlang.org/thread/pfjpqcywxrmxwsncy...@forum.dlang.org I’d like to set up something to call it from other modules, and specifically I’d like to see if inlining works across module boundaries - I have no idea whether

Re: Advice on debugging possible exception or crash

2023-07-06 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 6 July 2023 at 07:09:11 UTC, Richard (Rikki) Andrew Cattermole wrote: On 06/07/2023 7:07 PM, Cecil Ward wrote: On Thursday, 6 July 2023 at 06:17:34 UTC, Richard (Rikki) Andrew Cattermole wrote: 2 Recommendations: 1. Attach a debugger 2. Make sure to flush stdout whenever you writ

Re: Advice on debugging possible exception or crash

2023-07-06 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 6 July 2023 at 06:17:34 UTC, Richard (Rikki) Andrew Cattermole wrote: 2 Recommendations: 1. Attach a debugger 2. Make sure to flush stdout whenever you write I assumed that buffering was to blame. How do I flush stdout? I moved to an x86-64 box. I was using my ARM M2 Mac for whic

Advice on debugging possible exception or crash

2023-07-05 Thread Cecil Ward via Digitalmars-d-learn
My program is instrumented with a load of writeflns. At one point it looks as though it suddenly quits prematurely because the expected writeflns are not seen in the output. It could be that I am just reading the flow of control wrong as it goes ret, ret etc. I’m wondering if it is throwing an

Re: Zapping a dynamic string

2023-07-04 Thread Cecil Ward via Digitalmars-d-learn
On Tuesday, 4 July 2023 at 17:46:22 UTC, Steven Schveighoffer wrote: On 7/4/23 1:01 PM, Cecil Ward wrote: I have a mutable dynamic array of dchar, grown by successively appending more and more. When I wish to zap it and hand the contents to the GC to be cleaned up, what should I do? What happe

Inserting into zero-length dynamic array

2023-07-04 Thread Cecil Ward via Digitalmars-d-learn
I have a dynamic array of strings of length zero. When i write to the first element the program crashes, not surprisingly, but what should I be doing? dstring[] arr; arr[0] = "my string"d; // BANG !!

Re: Zapping a dynamic string

2023-07-04 Thread Cecil Ward via Digitalmars-d-learn
On Tuesday, 4 July 2023 at 17:01:42 UTC, Cecil Ward wrote: I have a mutable dynamic array of dchar, grown by successively appending more and more. When I wish to zap it and hand the contents to the GC to be cleaned up, what should I do? What happens if I set the .length to zero? I do want to

Re: Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 30 June 2023 at 19:05:23 UTC, Cecil Ward wrote: I have code roughly like the following: dstring str = "name"d; uint ordinal = (( str in Decls.ordinals ) !is null) ? Decls.ordinals[ str ] : -1; struct Decls { uint[ dstring] ordinals; } //and Decls.ordinals[

Re: Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 30 June 2023 at 21:25:23 UTC, H. S. Teoh wrote: On Fri, Jun 30, 2023 at 07:05:23PM +, Cecil Ward via Digitalmars-d-learn wrote: [...] It would help if you could post the complete code that reproduces the problem. Or, if you do not wish to reveal your code, reduce it to a

Re: Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 30 June 2023 at 19:58:39 UTC, FeepingCreature wrote: On Friday, 30 June 2023 at 19:05:23 UTC, Cecil Ward wrote: I have code roughly like the following: dstring str = "name"d; uint ordinal = (( str in Decls.ordinals ) !is null) ? Decls.ordinals[ str ] : -1; struct Decls

Re: Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 30 June 2023 at 20:12:08 UTC, Ali Çehreli wrote: On 6/30/23 12:05, Cecil Ward wrote: > I have code roughly like the following: > > dstring str = "name"d; Aside: One almost never needs dstring. > uint ordinal = (( str in Decls.ordinals ) !is null) ? > Decls.ordinals[ str ]

Bug in usage of associative array: dynamic array with string as a key

2023-06-30 Thread Cecil Ward via Digitalmars-d-learn
I have code roughly like the following: dstring str = "name"d; uint ordinal = (( str in Decls.ordinals ) !is null) ? Decls.ordinals[ str ] : -1; struct Decls { uint[ dstring] ordinals; } //and Decls.ordinals[ str ] = ordinal_counter++; The problem is that it always r

Re: Debugging by old fashioned trace log printfs / writefln

2023-06-30 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 29 June 2023 at 23:54:45 UTC, Chris Katko wrote: On Thursday, 29 June 2023 at 18:27:22 UTC, Cecil Ward wrote: I’m trying to debug my D program with old-fashioned printfs stuck in various strategic places, actually using writefln(). My problem is that the addition of printf fights w

Debugging by old fashioned trace log printfs / writefln

2023-06-29 Thread Cecil Ward via Digitalmars-d-learn
I’m trying to debug my D program with old-fashioned printfs stuck in various strategic places, actually using writefln(). My problem is that the addition of printf fights with the existing declarations for pure nothrow @nogc @safe and I have to adjust them, then put them back correctly when the

Re: Counting an initialised array, and segments

2023-06-26 Thread Cecil Ward via Digitalmars-d-learn
On Monday, 26 June 2023 at 22:19:25 UTC, Jonathan M Davis wrote: On Monday, June 26, 2023 1:09:24 PM MDT Cecil Ward via Digitalmars-d-learn wrote: [...] [...] I completely agree with everything you said. I merely used aliases to give me the freedom to switch between having text in either

Re: Counting an initialised array, and segments

2023-06-26 Thread Cecil Ward via Digitalmars-d-learn
On Monday, 26 June 2023 at 12:28:15 UTC, Jonathan M Davis wrote: On Monday, June 26, 2023 5:08:06 AM MDT Cecil Ward via Digitalmars-d-learn wrote: On Monday, 26 June 2023 at 08:26:31 UTC, Jonathan M Davis wrote: > On Sunday, June 25, 2023 4:08:19 PM MDT Cecil Ward via > > Digitalmar

Re: Scope guards

2023-06-26 Thread Cecil Ward via Digitalmars-d-learn
On Monday, 26 June 2023 at 17:41:16 UTC, Paul Backus wrote: On Saturday, 24 June 2023 at 17:00:36 UTC, Cecil Ward wrote: I would like to use scope guards but in the guard I need to get access to some local variables at the end of the routine. This doesn’t really seem to make sense as to how it

Re: Counting an initialised array, and segments

2023-06-26 Thread Cecil Ward via Digitalmars-d-learn
On Monday, 26 June 2023 at 08:26:31 UTC, Jonathan M Davis wrote: On Sunday, June 25, 2023 4:08:19 PM MDT Cecil Ward via Digitalmars-d-learn wrote: I recently had some problems dchar[] arr = [ ‘ ‘, TAB, CR, LF … ]; and I got errors from the compiler which led to me having to count the elements

Counting an initialised array, and segments

2023-06-25 Thread Cecil Ward via Digitalmars-d-learn
I recently had some problems dchar[] arr = [ ‘ ‘, TAB, CR, LF … ]; and I got errors from the compiler which led to me having to count the elements in the initialiser and declare the array with an explicit size. I don’t want the array to be mutable so I later added immutable to it, but that di

Re: Large statics

2023-06-25 Thread Cecil Ward via Digitalmars-d-learn
On Sunday, 25 June 2023 at 21:08:13 UTC, Ali Çehreli wrote: On 6/25/23 13:41, Cecil Ward wrote: > The docs say that there is a limit on the size of large statics Customers (at least Weka) did request larger statics in the past. Since they use LDC, the limit was removed for LDC. I did not try

Large statics

2023-06-25 Thread Cecil Ward via Digitalmars-d-learn
The docs say that there is a limit on the size of large statics of 16 MB. Is it desirable to remove this limit ? I realise that with new code there is the option to alloc the space instead where the static is uninitialised. There are other possibilities, such as an object filled with compile-ti

Re: Mixin and compile-time functions for code generation

2023-06-24 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 24 June 2023 at 17:43:52 UTC, Adam D Ruppe wrote: On Saturday, 24 June 2023 at 17:31:31 UTC, Cecil Ward wrote: Can I get mixin whatever to do this for me? Mixin with a function that runs at compile-time and creates the required source ? have you tried it? No, not so far. Adam,

Mixin and compile-time functions for code generation

2023-06-24 Thread Cecil Ward via Digitalmars-d-learn
I have a function that can be run at compile-time and which will be able to output code to be injected into the D source code stream. Can I get mixin whatever to do this for me? Mixin with a function that runs at compile-time and creates the required source ? Like D’s solution for a replacement

Re: How does D’s ‘import’ work?

2023-06-24 Thread Cecil Ward via Digitalmars-d-learn
On Tuesday, 20 June 2023 at 17:56:27 UTC, Ali Çehreli wrote: On 6/20/23 08:09, Cecil Ward wrote: > I’m used to slow compilers on fast machines and compiling > gives me an excuse for more coffee and possibly fruity buns. Yes, all of us in past projects accepted C++'s slowness. We did get coffee

Compiling the runtime library

2023-06-24 Thread Cecil Ward via Digitalmars-d-learn
Is it possible to recompile the LDC and GDC runtimes yourself so you can do so with the switches you desire? (eg regarding optimisation, release vs debug build modes.) I think I saw a mention of something to help with this in the LDC docs, GDC would be a different story though. I’d have to g

Unused routines and inlining

2023-06-24 Thread Cecil Ward via Digitalmars-d-learn
(Apologies if I have talked about this before, but my memory is shot because of strong pain drugs that I’m on, and it never was any good before either, so I may be repeating myself.) I’m using GDC and LDC, comparing the two, and in a medium sized routine that I have written pretty much every r

Re: Unused routines and inlining

2023-06-24 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 24 June 2023 at 16:55:05 UTC, Cecil Ward wrote: (Apologies if I have talked about this before, but my memory is shot because of strong pain drugs that I’m on, and it never was any good before either, so I may be repeating myself.) [...] s/medium sized routine/medium-sized module

Re: A couple of questions about arrays and slices

2023-06-24 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 24 June 2023 at 16:42:45 UTC, Cecil Ward wrote: On Saturday, 24 June 2023 at 15:12:14 UTC, Jonathan M Davis wrote: [...] Yeah, it would take me forever to get my head around that, and I only want a crude toy partial parser for certain portions of the grammar, and the parsing cod

Re: A couple of questions about arrays and slices

2023-06-24 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 24 June 2023 at 15:12:14 UTC, Jonathan M Davis wrote: On Saturday, June 24, 2023 8:43:00 AM MDT Cecil Ward via Digitalmars-d-learn wrote: I started out looking into a number of runtime library routines, but in the end it seemed quicker to roll my own code for a crude recursive

Toolchain with ldc and AArch64 OSX

2023-06-24 Thread Cecil Ward via Digitalmars-d-learn
I have LDC running on an ARM Mac. If anyone else out there is an LDC or GDC user, could you knock up a quick shell program to compile and link a .d file to produce an executable ? found the linker but these tools are all new to me and a bit of help would save me a lot of trial and error and fru

Re: A couple of questions about arrays and slices

2023-06-24 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 24 June 2023 at 12:05:26 UTC, Jonathan M Davis wrote: On Saturday, June 24, 2023 1:43:53 AM MDT Cecil Ward via Digitalmars-d-learn wrote: On Saturday, 24 June 2023 at 07:36:26 UTC, Cecil Ward wrote: > [...] I just realised something, your point about altering the table and hav

Re: A couple of questions about arrays and slices

2023-06-24 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 24 June 2023 at 07:36:26 UTC, Cecil Ward wrote: Jonathan, is it possible that I wanted one thing and got another? My description in the earlier post was of the _aim_ of the program. What I ended up with might be something else? I wanted an array of uints whose values are the result

Re: A couple of questions about arrays and slices

2023-06-24 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 24 June 2023 at 01:28:03 UTC, Jonathan M Davis wrote: On Friday, June 23, 2023 7:02:12 PM MDT Cecil Ward via Digitalmars-d-learn wrote: I just had a fight with LDC over the following code when I tried out reserve. I have an associative array that maps strings to ‘ordinals’ ie

Re: A couple of questions about arrays and slices

2023-06-23 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 22 June 2023 at 05:21:52 UTC, Cecil Ward wrote: On Thursday, 22 June 2023 at 01:44:22 UTC, Jonathan M Davis wrote: On Wednesday, June 21, 2023 7:05:28 PM MDT Paul Backus via Digitalmars-d-learn wrote: [...] To add to that, it _has_ to know the element type, because aside from an

Re: A couple of questions about arrays and slices

2023-06-21 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 22 June 2023 at 01:44:22 UTC, Jonathan M Davis wrote: On Wednesday, June 21, 2023 7:05:28 PM MDT Paul Backus via Digitalmars-d-learn wrote: [...] To add to that, it _has_ to know the element type, because aside from anything related to a type's size, it bit-blits the type's init

Re: A couple of questions about arrays and slices

2023-06-21 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 22 June 2023 at 01:05:28 UTC, Paul Backus wrote: On Thursday, 22 June 2023 at 00:10:19 UTC, Cecil Ward wrote: Is .reserve()’s argument scaled by the entry size after it is supplied, that is it is quoted in elements or is it in bytes? I’m not sure whether the runtime has a knowledge

Re: A couple of questions about arrays and slices

2023-06-21 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 21 June 2023 at 15:48:56 UTC, H. S. Teoh wrote: On Wed, Jun 21, 2023 at 02:09:26AM +, Cecil Ward via Digitalmars-d-learn wrote: First is an easy one: 1.) I have a large array and a sub-slice which I want to set up to be pointing into a sub-range of it. What do I write if I

Re: A couple of questions about arrays and slices

2023-06-21 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 21 June 2023 at 04:52:06 UTC, Jonathan M Davis wrote: On Tuesday, June 20, 2023 8:09:26 PM MDT Cecil Ward via Digitalmars-d-learn wrote: [...] When slicing, the end index is exclusive. e.g. [...] Actually concerning the garbage, I was rather hoping that it _would_ be garbage

Re: A couple of questions about arrays and slices

2023-06-21 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 21 June 2023 at 04:52:06 UTC, Jonathan M Davis wrote: On Tuesday, June 20, 2023 8:09:26 PM MDT Cecil Ward via Digitalmars-d-learn wrote: [...] When slicing, the end index is exclusive. e.g. [...] Thankyou to both posters for your exceptionally helpful and generous replies

A couple of questions about arrays and slices

2023-06-20 Thread Cecil Ward via Digitalmars-d-learn
First is an easy one: 1.) I have a large array and a sub-slice which I want to set up to be pointing into a sub-range of it. What do I write if I know the start and end indices ? Concerned about an off-by-one error, I have start_index and past_end_index (exclusive). 2.) I have a dynamic arra

Re: How does D’s ‘import’ work?

2023-06-20 Thread Cecil Ward via Digitalmars-d-learn
On Monday, 19 June 2023 at 16:24:03 UTC, rempas wrote: On Monday, 19 June 2023 at 12:48:26 UTC, Cecil Ward wrote: If I have sources to all the library routines, not libraries or .obj files. I am simply completely ignorant about the D tools including DUB, so off to do some reading. I’ve just b

Re: How does D’s ‘import’ work?

2023-06-20 Thread Cecil Ward via Digitalmars-d-learn
On Sunday, 18 June 2023 at 21:51:14 UTC, Jonathan M Davis wrote: On Sunday, June 18, 2023 2:24:10 PM MDT Cecil Ward via Digitalmars-d-learn wrote: I wasn’t intending to use DMD, rather ldc if possible or GDC because of their excellent optimisation, in which DMD seems lacking, is that fair

Re: How does D’s ‘import’ work?

2023-06-19 Thread Cecil Ward via Digitalmars-d-learn
On Monday, 19 June 2023 at 08:46:31 UTC, rempas wrote: On Sunday, 18 June 2023 at 20:17:50 UTC, Cecil Ward wrote: target.obj: target.c include1.h include2.h cc.exe cc target.c and you either have to pray that you have kept the list of .h files that are mentioned inside target.c and other

Re: How does D’s ‘import’ work?

2023-06-18 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 8 June 2023 at 05:11:04 UTC, Ali Çehreli wrote: On 6/7/23 21:17, Cecil Ward wrote: > I was thinking about the situation in C where I have a rule in a make > file that lists the .h files as well as the .c all as dependencies in > creating an object file. dmd's -makedeps command line

Re: How does D’s ‘import’ work?

2023-06-18 Thread Cecil Ward via Digitalmars-d-learn
On Sunday, 18 June 2023 at 17:34:51 UTC, rempas wrote: On Thursday, 8 June 2023 at 04:17:20 UTC, Cecil Ward wrote: I was thinking about the situation in C where I have a rule in a make file that lists the .h files as well as the .c all as dependencies in creating an object file. I don't think

Re: SIMD c = a op b

2023-06-17 Thread Cecil Ward via Digitalmars-d-learn
On Sunday, 18 June 2023 at 04:54:08 UTC, Cecil Ward wrote: Is it true that this doesn’t work (in either branch)? float4 a,b; static if (__traits(compiles, a/b)) c = a / b; else c[] = a[] / b[]; I tried it with 4 x 64-bit ulongs in a 256-bit vector instead. Hoping I have done things corr

Re: Como puedo hacer funciones asincronas?

2023-06-17 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 17 June 2023 at 22:05:37 UTC, Danico wrote: hola gente, quisiera saber como es que puedo hacer funciones asincronas. ` #!/usr/bin/env dmd import std; import std.stdio; import std.concurrency; //import archivo2; alias print = writeln; void main () { auto tarea1 = spawn(&sa

Parser

2023-06-14 Thread Cecil Ward via Digitalmars-d-learn
I’m thinking that I might had to end up writing a partial, rather rough parser for parts of the D language. Could I get some suggestions for help that I might find in the way of software components? D has a very powerful regex module, I believe. I have been writing inline asm library routines

Re: byte and short data types use cases

2023-06-10 Thread Cecil Ward via Digitalmars-d-learn
On Sunday, 11 June 2023 at 00:05:52 UTC, H. S. Teoh wrote: On Sat, Jun 10, 2023 at 09:58:12PM +, Cecil Ward via Digitalmars-d-learn wrote: On Friday, 9 June 2023 at 15:07:54 UTC, [...] On contemporary machines, the CPU is so fast that memory access is a much bigger bottleneck than

Re: byte and short data types use cases

2023-06-10 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 10 June 2023 at 21:58:12 UTC, Cecil Ward wrote: On Friday, 9 June 2023 at 15:07:54 UTC, Murloc wrote: On Friday, 9 June 2023 at 12:56:20 UTC, Cecil Ward wrote: [...] Is this some kind of property? Where can I read more about this? My last example is comms. Protocol headers nee

Re: byte and short data types use cases

2023-06-10 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 9 June 2023 at 15:07:54 UTC, Murloc wrote: On Friday, 9 June 2023 at 12:56:20 UTC, Cecil Ward wrote: On Friday, 9 June 2023 at 11:24:38 UTC, Murloc wrote: If you have four ubyte variables in a struct and then an array of them, then you are getting optimal memory usage. Is this some

Re: byte and short data types use cases

2023-06-09 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 9 June 2023 at 15:07:54 UTC, Murloc wrote: On Friday, 9 June 2023 at 12:56:20 UTC, Cecil Ward wrote: On Friday, 9 June 2023 at 11:24:38 UTC, Murloc wrote: If you have four ubyte variables in a struct and then an array of them, then you are getting optimal memory usage. Is this some

Re: byte and short data types use cases

2023-06-09 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 9 June 2023 at 11:24:38 UTC, Murloc wrote: Hi, I was interested why, for example, `byte` and `short` literals do not have their own unique suffixes (like `L` for `long` or `u` for `unsigned int` literals) and found the following explanation: - "I guess short literal is not supporte

Re: How does D’s ‘import’ work?

2023-06-07 Thread Cecil Ward via Digitalmars-d-learn
On Friday, 2 June 2023 at 12:07:09 UTC, rempas wrote: On Thursday, 1 June 2023 at 03:47:00 UTC, Cecil Ward wrote: I have another question if I may, what do we do about getting makefiles right given that we have imports ? What do you mean with that? Give some more info please! I was thinkin

Re: Indenting standards religions K&R, whitesmiths etc

2023-06-01 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 1 June 2023 at 09:37:43 UTC, Dukc wrote: On Wednesday, 31 May 2023 at 16:24:38 UTC, Cecil Ward wrote: I wanted to ask how some of the leaders of our group feel about D indentation standards. `i realise that this causes some religious fervour in C. I could be in trouble here becaus

Re: Indenting standards religions K&R, whitesmiths etc

2023-06-01 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 1 June 2023 at 09:37:43 UTC, Dukc wrote: On Wednesday, 31 May 2023 at 16:24:38 UTC, Cecil Ward wrote: I wanted to ask how some of the leaders of our group feel about D indentation standards. `i realise that this causes some religious fervour in C. I could be in trouble here becaus

Re: How does D’s ‘import’ work?

2023-05-31 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 31 May 2023 at 18:43:52 UTC, Cecil Ward wrote: Is there an explanation of how D’s ‘import’ works somewhere? I’m trying to understand the comparison with the inclusion of .h files, similarities if any and differences with the process. I have another question if I may, what do we d

Re: How does D’s ‘import’ work?

2023-05-31 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 31 May 2023 at 18:56:02 UTC, H. S. Teoh wrote: On Wed, May 31, 2023 at 06:43:52PM +, Cecil Ward via Digitalmars-d-learn wrote: Is there an explanation of how D’s ‘import’ works somewhere? I’m trying to understand the comparison with the inclusion of .h files, similarities if

Re: Indenting standards religions K&R, whitesmiths etc

2023-05-31 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 31 May 2023 at 22:06:50 UTC, Ernesto Castellotti wrote: On Wednesday, 31 May 2023 at 16:24:38 UTC, Cecil Ward wrote: I wanted to ask how some of the leaders of our group feel about D indentation standards. `i realise that this causes some religious fervour in C. I could be in trou

How does D’s ‘import’ work?

2023-05-31 Thread Cecil Ward via Digitalmars-d-learn
Is there an explanation of how D’s ‘import’ works somewhere? I’m trying to understand the comparison with the inclusion of .h files, similarities if any and differences with the process.

Indenting standards religions K&R, whitesmiths etc

2023-05-31 Thread Cecil Ward via Digitalmars-d-learn
I wanted to ask how some of the leaders of our group feel about D indentation standards. `i realise that this causes some religious fervour in C. I could be in trouble here because in all my years at work, we never used K & R ‘one true brace style’ indenting, with the house style I’m used to be

Re: Code duplication where you wish to have a routine called with either immutable or mutable arguments

2023-05-31 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 31 May 2023 at 09:14:49 UTC, Dom DiSc wrote: On Wednesday, 31 May 2023 at 03:29:33 UTC, Cecil Ward wrote: I have to admit that I don’t really understand immutable. I have an idea that it could mean that an object has an address in ROM, so its value will never change. Maybe const d

Re: Code duplication where you wish to have a routine called with either immutable or mutable arguments

2023-05-30 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 31 May 2023 at 03:23:01 UTC, Cecil Ward wrote: On Tuesday, 30 May 2023 at 04:15:22 UTC, Ali Çehreli wrote: On 5/29/23 19:57, Cecil Ward wrote: > I wish to have one routine > that can be called with either immutable or (possibly) mutable argument > values. 'const' should take both

Re: Code duplication where you wish to have a routine called with either immutable or mutable arguments

2023-05-30 Thread Cecil Ward via Digitalmars-d-learn
On Tuesday, 30 May 2023 at 04:15:22 UTC, Ali Çehreli wrote: On 5/29/23 19:57, Cecil Ward wrote: > I wish to have one routine > that can be called with either immutable or (possibly) mutable argument > values. 'const' should take both immutable and mutable. Can you show your case with a short e

Code duplication where you wish to have a routine called with either immutable or mutable arguments

2023-05-29 Thread Cecil Ward via Digitalmars-d-learn
I have often come into difficulties where I wish to have one routine that can be called with either immutable or (possibly) mutable argument values. The argument(s) in question are in, readonly, passed by value or passed by const reference. Anyway, no one is trying to write to the items passed

Re: quick question, probably of little importance...

2023-04-30 Thread Cecil Ward via Digitalmars-d-learn
On Monday, 1 May 2023 at 03:53:24 UTC, Cecil Ward wrote: On Wednesday, 26 April 2023 at 23:07:39 UTC, WhatMeWorry wrote: [...] Correction: I can’t count. There are only two instructions in parallel with another pair running alongside, not three. The first reg, reg move counts as zero cycle

Re: quick question, probably of little importance...

2023-04-30 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 26 April 2023 at 23:07:39 UTC, WhatMeWorry wrote: On Wednesday, 26 April 2023 at 23:02:07 UTC, Richard (Rikki) Andrew Cattermole wrote: Don't forget ``num % 2 == 0``. None should matter, pretty much all production compilers within the last 30 years should recognize all forms of t

Re: std.socket tutorials? examples?

2023-04-30 Thread Cecil Ward via Digitalmars-d-learn
On Sunday, 30 April 2023 at 22:37:48 UTC, Adam D Ruppe wrote: On Sunday, 30 April 2023 at 22:10:31 UTC, Cecil Ward wrote: How do we wait for an ‘or’ of multiple asynchronous events in this kind of code? You can set a timeout value for Socket.select, but Phobos isn't going to help you with any

Re: std.socket tutorials? examples?

2023-04-30 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 29 April 2023 at 11:26:20 UTC, Adam D Ruppe wrote: On Saturday, 29 April 2023 at 10:56:46 UTC, Jan Allersma wrote: auto clientResult = Socket.select(clientSet, null, null); There's probably nothing in clientSet, so it is waiting for nothing you almost always want to have jus

Writing a dejargoniser - producing read ke analysis output in English that explains GDC / LDC asm code’s parameters and clobbers

2023-04-05 Thread Cecil Ward via Digitalmars-d-learn
How much code do you thing I would need to write for this? I’m still thinking about its feasibility. I don’t want to invent the wheel and write a custom parser by hand, so’d rather steal the code using sim eg called ‘a library’. :-) The idea would be that the user could run this to sanity-chec

Re: enum and const or immutable ‘variable’ whose value is known at compile time

2020-10-01 Thread Cecil Ward via Digitalmars-d-learn
On Thursday, 17 September 2020 at 01:57:39 UTC, Mike Parker wrote: On Thursday, 17 September 2020 at 00:32:40 UTC, Cecil Ward So can the result of declaring certain things with enum ever have an _address_ then? (According to legit D code that is, never mind the underlying implementation detai

Re: enum and const or immutable ‘variable’ whose value is known at compile time

2020-09-16 Thread Cecil Ward via Digitalmars-d-learn
On Wednesday, 16 September 2020 at 17:19:13 UTC, Adam D. Ruppe wrote: On Wednesday, 16 September 2020 at 17:12:47 UTC, Cecil Ward wrote: then is there any downside to just using enum all the time? For a non-string array, enum may give runtime allocations that static immutable won't. General

enum and const or immutable ‘variable’ whose value is known at compile time

2020-09-16 Thread Cecil Ward via Digitalmars-d-learn
A really stupid question, I fear. If I have some kind of declaration of some ‘variable’ whose value is strictly known at compile time and I do one of the following (rough syntax) either enum foo = bar; or const foo = bar; or immutable foo = bar; then is there any downside to just us

  1   2   >