Re: Is @disable obsolete?

2025-08-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, August 5, 2025 6:42:43 PM Mountain Daylight Time Brother Bill via Digitalmars-d-learn wrote: > It doesn't seem like modern D needs the @disable feature. > > If a struct has a user provided constructor, then the default > constructor is removed. D structs don't really have default cons

Re: struct parameterless constructor

2025-08-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 4, 2025 2:02:48 PM Mountain Daylight Time Brother Bill via Digitalmars-d-learn wrote: > I feel like I am going into the hornet's nest with this > discussion. > > I have created a struct with some members, and want to have a > parameterless constructor that sets the member values

Re: struct parameterless constructor

2025-08-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, August 4, 2025 5:21:53 PM Mountain Daylight Time H. S. Teoh via Digitalmars-d-learn wrote: > Fast forward 20 or so years, and things have changed a bit. People > started using structs for many other things, some beyond the original > design, and inevitably ran into cases where they rea

Re: Variables of struct and class types are called objects - discuss

2025-08-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 3, 2025 9:31:34 AM Mountain Daylight Time Paul Backus via Digitalmars-d-learn wrote: > I have never seen any D programmer use "object" to mean "struct > or class instance." That is always how I use the term. I see no reason to differentiate between what an instance of a struct i

Re: Variables of struct and class types are called objects - discuss

2025-08-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 3, 2025 5:29:46 AM Mountain Daylight Time Mike Parker via Digitalmars-d-learn wrote: > Classes and structs in C++ are both value types, and instances of > both are referred to as objects. This isn't unusual. > > An object is a concrete instance of a type described by a class > or

Re: Programming in D, page 155. shared static this() fails

2025-07-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, July 29, 2025 5:18:18 PM Mountain Daylight Time Brother Bill via Digitalmars-d-learn wrote: > Your changes do work, but at the cost of making i NOT deeply > immutable: no assignment, no changing any elements, no appending, > no setting length. This syntax permits appending and setting

Re: extern(C) on var decl is confusing

2025-07-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 27, 2025 5:23:40 PM Mountain Daylight Time user1234 via Digitalmars-d-learn wrote: > That is confusing, e.g > > ``` > extern(C) int r; > > int main() > { > return r; > } > ``` > > works. But what is likely more intended here is > > ``` > extern int r; > > int main() > { >

Re: Audio file metadata parser?

2025-07-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 18, 2025 4:47:04 PM Mountain Daylight Time Andy Valencia via Digitalmars-d-learn wrote: > Is anyone aware of a library like "tinytag" (a Python module)? > > https://github.com/devsnd/tinytag > > I guess I'll wrestle with porting it to dlang if there's nothing > available. > > tinyt

Re: Is there some kind of Blocking Queue for D?

2025-07-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 13, 2025 1:45:01 PM Mountain Daylight Time Ali Çehreli via Digitalmars-d-learn wrote: > On 7/12/25 5:35 PM, Jonathan M Davis wrote: > > On Saturday, July 12, 2025 5:55:39 PM Mountain Daylight Time Ali > Çehreli via Digitalmars-d-learn wrote: > Anything can be a part of the impleme

Re: Is there some kind of Blocking Queue for D?

2025-07-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 13, 2025 8:38:08 AM Mountain Daylight Time H. S. Teoh via Digitalmars-d-learn wrote: > On Sat, Jul 12, 2025 at 06:35:42PM -0600, Jonathan M Davis via > Digitalmars-d-learn wrote: > > On Saturday, July 12, 2025 5:55:39 PM Mountain Daylight Time Ali Çehreli > >

Re: Is there some kind of Blocking Queue for D?

2025-07-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, July 13, 2025 5:00:12 AM Mountain Daylight Time Bienlein via Digitalmars-d-learn wrote: > On Sunday, 13 July 2025 at 00:35:42 UTC, Jonathan M Davis wrote: > > > Whereas I think that using private makes perfect sense when you > > want something to be an implementation detail. Exposing it

Re: Is there some kind of Blocking Queue for D?

2025-07-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, July 12, 2025 5:55:39 PM Mountain Daylight Time Ali Çehreli via Digitalmars-d-learn wrote: > On 7/11/25 11:36 PM, Bienlein wrote: > > > Unhappily class MessageBox is private and therefore cannot be reused. > > Ah! :) That's one more data point against 'private', that little feature >

Re: Is there some kind of Blocking Queue for D?

2025-07-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 10, 2025 3:22:30 AM Mountain Daylight Time Bienlein via Digitalmars-d-learn wrote: > Hello, > > I'm looking for some kind of blocking queue for D, that is if the > queue is empty the thread doing a take on the queue is blocked > until an item has been added to the queue. Couldn't

Re: Why this doesn't produce an error or works as expected?

2025-07-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, July 5, 2025 2:19:11 AM Mountain Daylight Time partypooper via Digitalmars-d-learn wrote: > On Saturday, 5 July 2025 at 08:08:08 UTC, Jonathan M Davis wrote: > > On Friday, July 4, 2025 12:04:55 PM Mountain Daylight Time > > partypooper via Digitalmars-d-learn wrote: > >> [...] > > >

Re: Why this doesn't produce an error or works as expected?

2025-07-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 4, 2025 12:04:55 PM Mountain Daylight Time partypooper via Digitalmars-d-learn wrote: > On Friday, 4 July 2025 at 17:34:59 UTC, monkyyy wrote: > > On Friday, 4 July 2025 at 17:15:48 UTC, partypooper wrote: > > if you add ref to line 28 it works; there wont be a reasonable > > way t

Re: scope parameter has effect only on pointers?

2025-06-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 27, 2025 10:31:42 AM Mountain Daylight Time Quirin Schroll via Digitalmars-d-learn wrote: > On Tuesday, 24 June 2025 at 02:05:40 UTC, Jonathan M Davis wrote: > > There's also the issue of templated code. If an attribute is > > desirable in the cases where it works, and it's fine fo

Re: Is there a way to tell D to rearrange struct members or to not rearrange class members?

2025-06-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 27, 2025 1:55:30 PM Mountain Daylight Time WraithGlade via Digitalmars-d-learn wrote: > Thanks for responding to my question and for your time, etc. > > I was aware of `align` but as far as I am aware it is orthogonal > to what I'm asking about. The Andrei book says that D > automa

Re: Should I worry about this hashOf warning ?

2025-06-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, June 25, 2025 9:38:55 AM Mountain Daylight Time axricard via Digitalmars-d-learn wrote: > When trying to use Nullable with a struct containing an > overlapping pointer: > > ```D > import std; > > struct S > { > union > { > long foo; > int[] bar; > } > }

Re: Operator Overloading - Only for Classes and Structs?

2025-06-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 23, 2025 9:56:15 PM Mountain Daylight Time Andy Valencia via Digitalmars-d-learn wrote: > I was a little surprised the subclassing syntax didn't do > structural concatenation for struct's. That is, > > ```d > import std.stdio : writeln; > > struct A { > int a; > void printA()

Re: scope parameter has effect only on pointers?

2025-06-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 23, 2025 8:53:18 AM Mountain Daylight Time Dennis via Digitalmars-d-learn wrote: > On Monday, 23 June 2025 at 10:37:58 UTC, Dom DiSc wrote: > > I know, it would be needed to enable generic programming, but I > > find a function that can take both an int and an int* suspect > > anyw

Re: Operator Overloading - Only for Classes and Structs?

2025-06-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, June 22, 2025 9:04:27 AM Mountain Daylight Time matheus via Digitalmars-d-learn wrote: > Hi, could someone please tell me why operador overloading > (https://dlang.org/spec/operatoroverloading.html) is relegated > only to classes and structs? > > "1 Operator overloading is accomplished

Re: InputRange for data structure without order?

2025-06-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, June 3, 2025 9:39:35 PM Mountain Daylight Time Andy Valencia via Digitalmars-d-learn wrote: > On Wednesday, 4 June 2025 at 02:11:18 UTC, H. S. Teoh wrote: > > The correct way to do this is to create a method in the > > container that returns a range over its contents. Popping the > >

Re: What previews should I enable?

2025-05-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 29, 2025 6:31:56 PM Mountain Daylight Time luafyn via Digitalmars-d-learn wrote: > Hi everyone, so dmd includes several -preview flags and I was > wondering if there were any that are recommended to enable? > > I like using the most up to date stuff possible so I've actually > bee

Re: Passing variadic template parameters AND default call site __FILE__, __LINE__ template parameters.

2025-05-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 28, 2025 5:04:06 AM Mountain Daylight Time realhet via Digitalmars-d-learn wrote: > I've found a way to eliminate !() by using a function: Just FYI, you almost never want to instantiate a template with a file and line number anyway, because that means that every single template

Re: What the heck am i doing wrong? I'm just trying to create a 8 bit unsigned variable.

2025-05-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 16, 2025 1:19:41 PM Mountain Daylight Time H. S. Teoh via Digitalmars-d-learn wrote: > On Fri, May 16, 2025 at 07:04:24PM +, WhatMeWorry via Digitalmars-d-learn > wrote: > [...] > > void main() > > { > > ubyte a; > > a = a + 5; // onlineapp.d(11): Error: cannot implicit

Re: string from C function - to!string

2025-05-14 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 14, 2025 5:38:59 AM Mountain Daylight Time Nick Treleaven via Digitalmars-d-learn wrote: > On Wednesday, 14 May 2025 at 03:36:40 UTC, Jonathan M Davis wrote: > > to!string definitely deals with null-terminated strings, or it > > wouldn't work at all. It's not the kind of thing th

Re: string from C function

2025-05-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, May 7, 2025 10:51:27 PM Mountain Daylight Time Andy Valencia via Digitalmars-d-learn wrote: > On Thursday, 8 May 2025 at 00:53:20 UTC, Mike Parker wrote: > >> tst44.d(6): Error: cannot implicitly convert expression > >> `fromStringz(ctime(null))` of type `char[]` to `string` > > `fro

Re: const main args?

2025-05-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, May 12, 2025 1:01:49 AM Mountain Daylight Time Justin Allen Parrott via Digitalmars-d-learn wrote: > On Friday, 12 August 2011 at 22:51:34 UTC, Andrej Mitrovic wrote: > > That's pretty stupid, of course you want to modify the > > arguments. > > > > Classic example: > > > > void main(str

Re: std.algorithm.strip functionality

2025-05-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, May 6, 2025 3:19:29 PM Mountain Daylight Time Pete Padil via Digitalmars-d-learn wrote: > I compiled and ran the following test program: > ```d > import std.stdio, std.algorithm; > > void main() > { > long[] a = [1, 2, 3, 15, 4]; > auto b = a[].strip(15); > writeln(a); >

Re: D equivalent for LINQ Where

2025-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 3, 2025 12:08:45 PM Mountain Daylight Time Ali Çehreli via Digitalmars-d-learn wrote: > On 5/2/25 2:44 PM, Python wrote: > > On Friday, 2 May 2025 at 14:33:57 UTC, Richard (Rikki) Andrew Cattermole > > wrote: > >> Have you tried filter? > >> > >> https://dlang.org/phobos/std_

Re: Array operations

2025-05-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, May 3, 2025 8:23:00 AM Mountain Daylight Time Andy Valencia via Digitalmars-d-learn wrote: > At least on 1.40.1 of the ldc2 distro for x86-64, uses the > "illegal instruction" instruction. That sounds like an ldc bug then. With dmd, your program gives [2, 2, 2, 2, 1, 1, 1, 1] [2, 2,

Re: alias vs enum for lambdas?

2025-05-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, April 27, 2025 10:59:24 PM MDT Orion via Digitalmars-d-learn wrote: > In which programming scenarios should alias be used instead of > enum? > > So far I have only found a simplified notation of a generic > lambda: > alias id = (x) => x; x; , which does not work in the case of enum. > >

Re: Is there anyway to Deify the following code snippet?

2025-04-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, April 16, 2025 8:48:04 AM MDT H. S. Teoh via Digitalmars-d-learn wrote: > On Wed, Apr 16, 2025 at 04:23:43AM +, Andy Valencia via > Digitalmars-d-learn wrote: > > On Wednesday, 16 April 2025 at 01:44:33 UTC, Paul Backus wrote: > > > Nope, you're not missing anything. Using point

Re: Building docs when dependencies have ddoc warnings

2025-04-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, April 9, 2025 1:11:35 AM MDT Anonymouse via Digitalmars-d-learn wrote: > On Tuesday, 8 April 2025 at 14:27:24 UTC, Jonathan M Davis wrote: > > I would assume that you need to create a similar build config > > which doesn't use -w (though really, -w should be gotten rid > > of, becaus

Re: How to fake pure

2025-04-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 8, 2025 9:07:45 AM MDT Guillaume Piolat via Digitalmars-d-learn wrote: > On Tuesday, 8 April 2025 at 14:00:56 UTC, Jonathan M Davis wrote: > > Of course, I'm also increasingly of the opinion that pure was a > > mistake in general, because it does almost nothing in practice > > bu

Re: Building docs when dependencies have ddoc warnings

2025-04-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, April 6, 2025 9:30:31 AM MDT Anonymouse via Digitalmars-d-learn wrote: > I'm using `dub build -b docs` as a way to detect when I did ddoc > wrong, such as mismatching `Params` sections and actual parameter > names. > > Sadly one of the dependencies I (indirectly) use already *has* > inc

Re: How to fake pure

2025-04-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 8, 2025 5:28:57 AM MDT Dom DiSc via Digitalmars-d-learn wrote: > Hi. > > I want to create my own allocator, but using malloc is not pure > (it internally has to have some "global state"). But the GC also > has this "global state" and still is considered "pure". > So internally the

Re: Is there an elegant way to non-destructively step through a red black tree?

2025-04-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, March 20, 2025 6:32:03 PM MDT H. S. Teoh via Digitalmars-d-learn wrote: > On Thu, Mar 20, 2025 at 11:51:46PM +, WhatMeWorry via Digitalmars-d-learn > wrote: > > Is there an elegant way, like with foreach, to step through a red black > > tree non-destructively? This destructi

Re: alias to connect with superclass's constructor

2025-03-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, March 22, 2025 11:38:05 AM MDT Paul Backus via Digitalmars-d-learn wrote: > On Saturday, 22 March 2025 at 12:05:11 UTC, Ali Çehreli wrote: > > On 3/21/25 8:35 PM, Andy Valencia wrote: > > > > > tst39.d(21):add `alias this = tst39.A.this` to > > `tst39.B`'s body > > > to merge

Re: simple question about UFCS and templates...wasFound(i) works but not i.wasFound()

2025-03-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 19, 2025 5:48:37 PM MDT H. S. Teoh via Digitalmars-d-learn wrote: > On Wed, Mar 19, 2025 at 11:21:15PM +, monkyyy via Digitalmars-d-learn > wrote: > [...] > > ufcs on local functions is hit or miss; > [...] > > I thought it was always a miss. :-D At least, it's never work

Re: Subclass TcpSocket?

2025-03-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 18, 2025 1:19:49 PM MDT bauss via Digitalmars-d-learn wrote: > On Tuesday, 18 March 2025 at 18:04:12 UTC, Steven Schveighoffer > wrote: > > On Tuesday, 18 March 2025 at 07:42:37 UTC, Jonathan M Davis > > wrote: > >> The base class constructors are not nothrow, so WrappedTCP's > >>

Re: Subclass TcpSocket?

2025-03-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, March 17, 2025 4:14:21 PM MDT Andy Valencia via Digitalmars-d-learn wrote: > The presence of the "accepting" API in Socket seems to indicate > that subclassing Socket/TcpSocket is intended to be supported. > But I'm just not seeing my way through the twisty maze of pure > and @nothrow b

Re: Get parent function of nested delegate

2025-03-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, February 16, 2025 12:38:09 AM MDT Anonymouse via Digitalmars-d-learn wrote: > I want to get a reference to a parent function from inside a > nested function. I need it for `getUDAs!(parentFunction, > attribute)`. > > `__traits(parent, mixin(__FUNCTION__))` works inside the parent > func

Re: Get parent function of nested delegate

2025-03-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, March 17, 2025 6:28:19 PM MDT Jonathan M Davis via Digitalmars-d-learn wrote: > On Sunday, February 16, 2025 12:38:09 AM MDT Anonymouse via > Digitalmars-d-learn wrote: > > I want to get a reference to a parent function from inside a > > nested function. I ne

Re: Newbie style question about string constants

2025-03-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, March 16, 2025 9:22:04 AM MDT Ian via Digitalmars-d-learn wrote: > On Tuesday, 25 February 2025 at 00:34:45 UTC, Jonathan M Davis > wrote: > > For strings, the way that you normally do constants is with > > enum, e.g > > > > enum foo = "dlang"; > > > > An enum like this is called a m

Re: Can somebody give me an example of using an "open interval for the upper limit of a range"?

2025-03-13 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 12, 2025 12:07:04 PM MDT Manfred Nowak via Digitalmars-d-learn wrote: > On Tuesday, 11 March 2025 at 16:56:28 UTC, WhatMeWorry wrote: > [...] > > To include the upper bound value, use a square bracket "]" at > > the end of the range." > > [...] > > foreach( i, e; a[0..3] ) > >

Re: Newbie style question about string constants

2025-02-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, February 24, 2025 9:07:07 AM MST Ian via Digitalmars-d-learn wrote: > Hello, > > What's the recommended D way to declare a string constant? Say, > for example, for a path used inside a class constructor? I've > seen const string, immutable, enum etc... > > Is this the place for these kin

Re: Newbie style question about string constants

2025-02-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, February 24, 2025 11:19:48 AM MST Elias Batek (0xEAB) via Digitalmars-d-learn wrote: > For string constants you’ll usually want to mark them as `static > immutable`. Strings with this combination will usually be put > into read-only sections (ROM) of the resulting binaries. > > Unlike `

Re: What does a cast really do?

2025-02-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, February 20, 2025 6:02:26 PM MST Quirin Schroll via Digitalmars-d-learn wrote: > It seems a cast does more than change the static type and VRP. > ```d > void foo(uint) { } > > int x = -1; > foo(x); // compiles (debatable) > foo(long(x)); // compiles(!) > foo(cast(long)x); // compiles(

Re: TLS variable for only one thread

2025-02-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, February 19, 2025 11:24:36 PM MST IchorDev via Digitalmars-d-learn wrote: > On Saturday, 15 February 2025 at 10:09:39 UTC, Jonathan M Davis > wrote: > > I think that you need to be clearer about what you're trying to > > do. If a module-level variable is not shared, __gshared, or > >

Re: How to pass an InputRange of dchars to a function that wants an Input range of chars?

2025-02-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, February 19, 2025 7:48:48 PM MST Jonathan M Davis via Digitalmars-d-learn wrote: > So you should probably either just make your code operate on ranges of > dchar, or you'll need to wrap your ranges using byChar or byCodeUnit in > order to get ranges of char. A

Re: How to pass an InputRange of dchars to a function that wants an Input range of chars?

2025-02-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, February 19, 2025 11:13:24 AM MST realhet via Digitalmars-d-learn wrote: > Hello, > > The problematic line is at the very bottom. > > I only managed to make it run by precedding the .byChar with > .text, but that is unwanted because it would convert the whole > InputRange. > > How ca

Re: Why is DList insertion log n?

2025-02-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, February 16, 2025 1:57:58 PM MST rkompass via Digitalmars-d-learn wrote: > From the source code at > [https://github.com/dlang/phobos/blob/master/std/container/dlist.d#L784](https://github.com/dlang/phobos/blob/master/std/container/dlist.d#L784) > I would say it is O(1), as you expecte

Re: implicit cast and overload priority

2025-02-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, February 16, 2025 4:54:46 AM MST ShadoLight via Digitalmars-d-learn wrote: > On Sunday, 16 February 2025 at 05:39:07 UTC, Jonathan M Davis > wrote: > > _especially_ when VRP comes into play, because then you get > > nonsense like foo(1) calling the bool overload. > > > > I have often se

Re: implicit cast and overload priority

2025-02-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, February 15, 2025 1:12:43 PM MST Paul Backus via Digitalmars-d-learn wrote: > On Saturday, 15 February 2025 at 15:40:51 UTC, Dom DiSc wrote: > > On Friday, 14 February 2025 at 15:58:26 UTC, Paul Backus wrote: > >> Oops--it turns out both overloads are equally specialized! > > > > This

Re: Simple string membership test

2025-02-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, February 15, 2025 9:33:06 PM MST Andy Valencia via Digitalmars-d-learn wrote: > On Saturday, 15 February 2025 at 19:27:19 UTC, Ian wrote: > > canFind is Perfect. Thank you. > > If performance is an issue, putting them as keys in an > Associative Array and simply using "in" should scal

Re: TLS variable for only one thread

2025-02-15 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, February 15, 2025 12:53:17 AM MST IchorDev via Digitalmars-d-learn wrote: > If I have a module-level variable, each thread sees a different > value for it. But how would I create a module-level variable that > can only be accessed by one thread? Do I have to give it its own > module?

Re: Vibe.d Password Verification

2025-02-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, February 5, 2025 8:16:10 AM MST seany via Digitalmars-d-learn wrote: > Is there any built in passowrd verification for Vibe.d? Such as > bcrypt.verifypassword(password , hash)? > > I looked at this library: https://code.dlang.org/packages/passwd > This is causing linking error ( ld:

Re: interface inference with delegates/functions

2025-02-04 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 4, 2025 5:53:02 AM MST axricard via Digitalmars-d-learn wrote: > Basically the same question than > https://forum.dlang.org/post/aoltazzfmnztsyatf...@forum.dlang.org > but with functions/delegates and inferred return types: > > ``` D > interface I { > bool check(); >

Re: std.conv:to that does not throw?

2025-02-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 31, 2025 3:45:55 PM MST Kyle Ingraham via Digitalmars-d-learn wrote: > On Thursday, 30 January 2025 at 04:44:02 UTC, Jonathan M Davis > wrote: > > What we really need is something like tryTo that returns a > > Nullable which has no value when the conversion fails, and then > > p

Re: std.conv:to that does not throw?

2025-01-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 29, 2025 8:00:43 PM MST H. S. Teoh via Digitalmars-d-learn wrote: > > Unfortunately, there isn't currently a function like std.conv.to which > > does not throw. > > I thought std.conv.parse* is supposed to fill that role? Or am I > remembering wrong? They don't quite have t

Re: std.conv:to that does not throw?

2025-01-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 29, 2025 6:38:07 PM MST Kyle Ingraham via Digitalmars-d-learn wrote: > Does D have a 'try' `std.conv:to` that does not throw if it > fails? Something like: > ```D > string input = "9"; > int output; > auto parsed = input.tryTo!int(output); > ``` > > `std.conv:to` is super fle

Re: Documentation re -betterC compatibility with standard library functions

2025-01-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 28, 2025 10:41:31 AM MST DLearner via Digitalmars-d-learn wrote: > On Tuesday, 28 January 2025 at 15:00:13 UTC, Jonathan M Davis > wrote: > [...] > > > > > -betterC was originally intended to be a tool for making it > > easier to port C code to D code (after which, the idea was

Re: Documentation re -betterC compatibility with standard library functions

2025-01-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 28, 2025 8:04:36 AM MST Dennis via Digitalmars-d-learn wrote: > On Tuesday, 28 January 2025 at 15:00:13 UTC, Jonathan M Davis > wrote: > > but we provide no guarantees that any code that works with > > -betterC right now will continue to do so, and we do not intend > > to add -

Re: Documentation re -betterC compatibility with standard library functions

2025-01-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 28, 2025 6:01:56 AM MST DLearner via Digitalmars-d-learn wrote: > Is there a definitive list somewhere of standard library > functions that work with -betterC? > > For example, the following code fragment (taken from the library > docs) does not work with -betterC. > ``` > exte

Re: Obtaining an address given a (run time) variable name

2025-01-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, January 26, 2025 4:41:53 PM MST DLearner via Digitalmars-d-learn wrote: > On Monday, 20 January 2025 at 19:54:19 UTC, Jonathan M Davis > wrote: > [...] > > Also, there's really no reason to be doing anything with char[] > > instead of string unless you're specifically planning on > > mu

Re: identify literals

2025-01-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 24, 2025 3:50:15 AM MST Dom DiSc via Digitalmars-d-learn wrote: > Is it possible in D to find out if the parameter given to a > function is a literal or a compile time constant? Not when calling the function, no. It should be possible to test whether a particular argument is a

Re: Copying file to /dev/null

2025-01-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, January 24, 2025 2:57:05 AM MST axricard via Digitalmars-d-learn wrote: > ``` D > import std; > > void main() > { > auto sourceName = deleteme ~ "source"; > auto source = File(sourceName, "w"); > source.write("source"); > > copy(sourceName, "/dev/null"); > } > ``` >

Re: Obtaining an address given a (run time) variable name

2025-01-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 20, 2025 12:03:09 PM MST DLearner via Digitalmars-d-learn wrote: > // In the code below, what fn needs to go in the commented-out > line, > // to make the program print 7, 11 rather than 7, 7? > > ``` > void main() { > > import std.stdio; > > int IntVar1 = 5; > int I

Re: How to collect "some" items of a range in an array?

2025-01-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, January 6, 2025 1:15:23 PM MST Renato via Digitalmars-d-learn wrote: > On Monday, 6 January 2025 at 19:58:12 UTC, H. S. Teoh wrote: > > On Mon, Jan 06, 2025 at 07:30:27PM +, Renato via > > Digitalmars-d-learn wrote: > >> Is there any Phobos function that collects "some" items of a >

Re: How to do conditional scope(exit) ?

2024-12-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, December 18, 2024 3:16:45 PM MST John Dougan via Digitalmars-d-learn wrote: > As the subject. The obvious way: > > ```D > import std; > > int test(int val) > { > writeln("A"); > if (val % 2 == 0) > { > writeln("b"); > scope (exit) > write

Re: unittest behaviour

2024-12-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 17, 2024 2:31:13 PM MST DLearner via Digitalmars-d-learn wrote: > On Tuesday, 17 December 2024 at 19:56:32 UTC, H. S. Teoh wrote: > [...] > > > > That means the compiler will have to rerun your program once > > per unittest. That means your OS has to create a new process > >

Re: what's the use of empty structs in C-style languages ?

2024-12-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, December 2, 2024 10:03:22 AM MST Basile B. via Digitalmars-d-learn wrote: > I've noticed that empty struct are always at least a size of 1, > see [D explorer](https://godbolt.org/z/sGYcex4cf). There you can > see `%example.S = type { [1 x i8] }` > > So te compiler inserts a dummy member

Re: only parameters or stack-based variables can be `inout`

2024-11-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, November 25, 2024 8:09:46 AM MST Paul Backus via Digitalmars-d- learn wrote: > On Monday, 25 November 2024 at 14:24:44 UTC, Bastiaan Veelo wrote: > > I suspect a bug in conv.to, am I right? > > Yes, this is a bug. Because of the weird restrictions on `inout`, > it's very easy to write te

Re: std.mmfile + std.bitmanip.peek, void[] is not a forward range?

2024-11-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 21, 2024 2:51:33 PM MST Ben Jones via Digitalmars-d- learn wrote: > I'm trying to read integers out of a mmap'd file using > std.bitmanip.peek and it's failing because > > `isForwardRange!(void[])` is false > > That seems unexpected, am I missing something or is that a bug? >

Re: Avoid subtracting form .length

2024-11-08 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, November 8, 2024 4:27:40 PM MST Dom DiSc via Digitalmars-d-learn wrote: > I _very_ often use this pattern: > > ``` > fun(ref int[] a) > { > assert(a.length && a.length<=100); > int[100] b; > b[0 .. a.length-1] = a[]; > b[a.length .. 100] = 5; > } > ``` > > I consider thi

Re: Rhyme and reason for function annotations?

2024-11-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, November 3, 2024 5:01:20 PM MST Andy Valencia via Digitalmars-d- learn wrote: > A function can be described as, say, private, or pure, or @nogc. > When does an annotation have an '@'? Also, a function can be > annotated > > int myfunc(char *arg) pure { > } > > Although I find: > > pure

Re: std.algorithm.countUntil and alias

2024-10-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, October 23, 2024 11:18:47 AM MDT Anton Pastukhov via Digitalmars-d-learn wrote: > On Wednesday, 23 October 2024 at 14:50:44 UTC, Paul Backus wrote: > > On Wednesday, 23 October 2024 at 12:46:24 UTC, Paul Backus > > wrote: > > > > You can't use an `alias` to refer to a member variable

Re: std.algorithm.countUntil and alias

2024-10-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, October 23, 2024 9:06:46 AM MDT Salih Dincer via Digitalmars-d- learn wrote: > The code also compiles like this. In this case, can we say that > there are 3 solutions or are static and enum actually the same > thing? static and enum are not the same thing. An enum has no memory loca

Re: Splitting a project into different executable files

2024-10-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, October 11, 2024 7:09:56 PM MDT Alexander Zhirov via Digitalmars-d- learn wrote: > Is it possible to organize a project that will consist of several > main files. I want to write several simple programs in one > project, but for them to be divided into different files. So that > it would

Re: Integer precision of function return types

2024-09-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 27, 2024 2:13:45 PM MDT thinkunix via Digitalmars-d-learn wrote: > monkyyy via Digitalmars-d-learn wrote: > > On Friday, 27 September 2024 at 04:23:32 UTC, thinkunix wrote: > >> What about using 'auto' as the return type? > >> I tried it and it seemed to work OK. > >> > >> Won

Re: Integer precision of function return types

2024-09-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, September 26, 2024 12:53:12 AM MDT Per Nordlöw via Digitalmars-d- learn wrote: > Should a function like > > ```d > uint parseHex(in char ch) pure nothrow @safe @nogc { > switch (ch) { > case '0': .. case '9': > return ch - '0'; > case 'a': .. case 'f': > return 10 + c

Re: mod of negative number

2024-09-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 23, 2024 1:52:02 PM MDT Craig Dillabaugh via Digitalmars- d-learn wrote: > Why does the following program: > > \ > import std.stdio; > > int main(string[] args) { > uint Q = 7681; > writeln("Val = ", -1 % Q); > retur

Re: assert

2024-09-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 10, 2024 10:01:53 PM MDT f via Digitalmars-d-learn wrote: > i mean , is this a bug? No, it's not a bug. Assertions with an expression that is known to be false at compile time are treated as special. They are always left in the generated code so that they will kill your prog

Re: Problem with assertThrown

2024-09-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 9, 2024 6:40:07 PM MDT kookman via Digitalmars-d-learn wrote: > On Tuesday, 10 September 2024 at 00:27:43 UTC, Jonathan M Davis > > wrote: > > On Monday, September 9, 2024 5:46:18 PM MDT kookman via > > > > Digitalmars-d-learn wrote: > >> It seems like assertThrown works as ex

Re: Problem with assertThrown

2024-09-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, September 9, 2024 5:46:18 PM MDT kookman via Digitalmars-d-learn wrote: > It seems like assertThrown works as expected for case 4, but > mysteriously not working for case 5 - despite the code under test > raising the same exception. Am I missing something stupid here? At a glance, it l

Re: Understanding the Behavior of i + ++i in D Language

2024-08-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, August 28, 2024 3:44:59 PM MDT Johann Lermer via Digitalmars-d- learn wrote: > On Friday, 23 August 2024 at 08:58:16 UTC, Me'vâ wrote: > > writeln("Result: ", i + ++i); > > I would definitely expect 11 as result (but I still have K&R on > my book shelf, maybe I'm a bit biased). So

Re: create fixed length string of characters

2024-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 16, 2024 10:37:45 AM MDT Nick Treleaven via Digitalmars-d- learn wrote: > On Friday, 16 August 2024 at 16:30:09 UTC, Jonathan M Davis wrote: > > Whether the result of dup is then able to be implicitly > > converted to immutable based on whether the operation is pure > > depends on

Re: create fixed length string of characters

2024-08-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, August 16, 2024 9:58:31 AM MDT Nick Treleaven via Digitalmars-d- learn wrote: > On Friday, 16 August 2024 at 13:30:53 UTC, IchorDev wrote: > > On Friday, 16 August 2024 at 11:37:08 UTC, Nick Treleaven wrote: > >> On Friday, 16 August 2024 at 06:15:18 UTC, Bruce wrote: > >> ```d > >> stri

Re: copy must be const?!?

2024-07-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 26, 2024 2:17:21 AM MDT Dom DiSc via Digitalmars-d-learn wrote: > On Thursday, 25 July 2024 at 13:07:03 UTC, Jonathan M Davis wrote: > > On Thursday, July 25, 2024 6:00:58 AM MDT Dom DiSc via > > > >> But a parameter given by value is ALWAYS a copy. > > > > It has to be a _full_, i

Re: What is an rvalue constructor?

2024-07-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 25, 2024 4:48:06 PM MDT Quirin Schroll via Digitalmars-d- learn wrote: > It seems one can’t have one in a struct together with a copy > constructor, but what is it? When is it called? What is it for? An rvalue constructor is a constructor that takes the same type as the struct th

Re: Prevent self-comparison without taking the address

2024-07-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 25, 2024 4:50:04 AM MDT Dom DiSc via Digitalmars-d-learn wrote: > I have copied some source from C++, where the following pattern > is common (operator== already renamed): > > ```d > @safe: > struct S > { > bool opEquals(const ref S x) const > { >if(&x==&this) ret

Re: copy must be const?!?

2024-07-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 25, 2024 6:00:58 AM MDT Dom DiSc via Digitalmars-d-learn wrote: > > And no, in general, you don't want to be casting away const or > > immutable. There are cases where it can work (e.g. if the cast > > does a copy, which it would with an integer type) > > But a parameter given by

Re: copy must be const?!?

2024-07-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 25, 2024 12:50:04 AM MDT Dom DiSc via Digitalmars-d-learn wrote: > On Wednesday, 24 July 2024 at 15:40:28 UTC, Dennis wrote: > >> Is there a way to tell the compiler that it should discard > >> "const" and "immutable" if it needs to create a copy? > >> Unqual!T doesn't work :-( >

Re: Unexpected range assignment behaviour

2024-07-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 19, 2024 12:02:55 PM MDT H. S. Teoh via Digitalmars-d-learn wrote: > On Fri, Jul 19, 2024 at 05:48:37PM +, Dennis via Digitalmars-d-learn wrote: > > On Friday, 19 July 2024 at 17:20:22 UTC, matheus wrote: > > > couldn't this case for example be caught during the compiling time

Re: Why does this mixin fail to compile?

2024-07-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, July 2, 2024 1:23:42 AM MDT ryuukk_ via Digitalmars-d-learn wrote: > I said it 2 times already, i don't want string concatenation, > i'll benchmark later, but not right now, right now i'm looking > for a functioning code without string concatenation D has two options for mixins, and bo

Re: importC Error: undefined identifier `__atomic_thread_fence`

2024-06-23 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, June 21, 2024 12:39:44 PM MDT mw via Digitalmars-d-learn wrote: > Looks like `__atomic_thread_fence` is a GCC built-in function, so > how to make importC recognize it? dmd cannot handle it. gcc or ldc might, but dmd generally needs standard C code. Stuff like gcc built-ins basically has

Re: Pointer to dlang spec for this alias construct?

2024-06-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, June 16, 2024 10:32:50 PM MDT Andy Valencia via Digitalmars-d-learn wrote: > In the alias: > > alias Unshared(T) = T; > alias Unshared(T: shared U, U) = U; > > as used in: > > cast(Unshared!mytype)value > > turns a mytype with shared attribute into one without shared. > >

Re: Socket and spawn()

2024-05-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 31, 2024 6:28:27 PM MDT Andy Valencia via Digitalmars-d-learn wrote: > On Friday, 31 May 2024 at 16:59:08 UTC, Jonathan M Davis wrote: > > Speaking as an old kernel engineer for the Sequent multiprocessor > product line, this is all very comfortable to me. I'm very glad > that D ha

Re: Socket and spawn()

2024-05-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, May 31, 2024 10:07:23 AM MDT Andy Valencia via Digitalmars-d-learn wrote: > I'm coding a server which takes TCP connections. I end up in the > main thread with .accept() which hands me a Socket. I'd like to > hand this off to a spawn()'ed thread to do the actual work. > > Aliases

  1   2   3   4   5   6   7   8   9   10   >