4 days ago

On Saturday, 9 November 2024 at 04:34:20 UTC, Adam Wilson wrote:

>

The first thing I'd like to consider is renaming to phobos.sys.types. It is difficult to name std.typecons because it is a grab-bag of type-related tools. [...]

Second, JMD proposed that we re-organize this module into a package due to it's grab-bag nature. [...]
My proposal is to break this module up by the categories in the document with the exception of Nullable which will get it's own file module due to it's size.

It's difficult to name because the most accurate name for std.typecons is std.miscellaneous. :)

Ideally, Phobos 3 should not have a "miscellaneous" package at all. Instead, each individual part of std.typecons should get its own module, and we should decide on a case-by-case basis how (or whether) to fit them into the overall structure of Phobos 3.

>

Speaking of Nullable, after a rather embarrassing situation with a Phobos 2 PR on Nullable JMD and I agreed that it should be renamed as it does not actually behave like a nullable but instead behaves as an "Optional" type. We considered Optional, Maybe, and settled on Option as that appears to the more popular naming choice in other languages and is almost as short as Maybe. If you disagree I'd love to hear your case.

Personally, Option would be my last choice, because the word "option" can also refer to things like command-line flags and configuration values. The Dub package darg, for example, has an Option UDA that would conflict with this usage.

Between Optional and Maybe, I'm indifferent.

>

The last question is how we want to deal with existing bugs in V2 as we port the code to V3. My view is that it would be prudent to fix any bugs that have been opened as we go in both V2 and V3. Currently I've found a number of bugs against Nullable and Tuple, the two types I'd like to start with.

Do we want to just port the existing versions, or are breaking API changes and reimplementation on the table? For example, there's been talk about removing the range interface from Nullable, and Andrei's comments in issue 18462 suggests that splitting Tuple into separate implementations with and without field names might be desirable.

To me this seems like a good opportunity to give a critical eye to the current designs, and potentially let go of some of Phobos 2's baggage.

4 days ago
On Saturday, November 16, 2024 4:17:33 PM MST Paul Backus via Digitalmars-d wrote:
> Personally, `Option` would be my last choice, because the word "option" can also refer to things like command-line flags and configuration values. The Dub package [`darg`][1], for example, has an `Option` UDA that would conflict with this usage.
>
> Between `Optional` and `Maybe`, I'm indifferent.

Personally, I prefer Maybe, which several languages have, but Option and Optional are more common IIRC. Either way, I'd much prefer to avoid Optional, because it's needlessly long, and this is going routinely used explicitly to wrap types, making having the name be longer particularly annoying. Adam didn't seem to particularly like Maybe.

> Do we want to just port the existing versions, or are breaking API changes and reimplementation on the table? For example, there's been talk about removing the range interface from `Nullable`, and Andrei's comments in [issue 18462][2] suggests that splitting `Tuple` into separate implementations with and without field names might be desirable.
>
> To me this seems like a good opportunity to give a critical eye to the current designs, and potentially let go of some of Phobos 2's baggage.
>
> [2]: https://issues.dlang.org/show_bug.cgi?id=18426

IMHO, we definitely should be looking at reworking these types as appropriate, since we don't need to maintain backwards compatibility with these. There is no reason to stick to the current API just because it's what we have when we can do better. And there are some obvious changes that I think we should be making - e.g. in the case of Nullable, getting rid of the range API (or at minimum making it so that it has to be sliced explictly to get a range), adding the ability to cast to bool in addition to using hasValue (or whatever we call the replacement for isNull), and adding the ability to dereference it (that way, it can be used in if conditions just like a pointer, and templated code could work with either pointers or Option/Maybe/Whatever ). I'd have to sit down and study the types more to say much more than that off the top of my head though. And in general, I think that we should lean towards not porting some of these types if we're not sure that they're generally useful, particularly since what's there is a bit of a hodgepodge.

Personally, it's on my todo list to sit down and look through how Rebindable and friends need to be reworked, since that's kind of a mess, and some of it is potentially going to affect how we deal with ranges.

- Jonathan M Davis



4 days ago

On Saturday, 16 November 2024 at 23:17:33 UTC, Paul Backus wrote:

>

On Saturday, 9 November 2024 at 04:34:20 UTC, Adam Wilson wrote:

It's difficult to name because the most accurate name for std.typecons is std.miscellaneous. :)

Ideally, Phobos 3 should not have a "miscellaneous" package at all. Instead, each individual part of std.typecons should get its own module, and we should decide on a case-by-case basis how (or whether) to fit them into the overall structure of Phobos 3.

Yea ... miscellaneous is never happening on my watch. That is pure ugly. :D

It wasn't something I thought of, but flattening out the modules a bit could be on the table.

>

Personally, Option would be my last choice, because the word "option" can also refer to things like command-line flags and configuration values. The Dub package darg, for example, has an Option UDA that would conflict with this usage.

Between Optional and Maybe, I'm indifferent.

I'm with JMD on the length of Option vs. Optional, and that's what the majority of other langs are going with.

>

Do we want to just port the existing versions, or are breaking API changes and reimplementation on the table? For example, there's been talk about removing the range interface from Nullable, and Andrei's comments in issue 18462 suggests that splitting Tuple into separate implementations with and without field names might be desirable.

To me this seems like a good opportunity to give a critical eye to the current designs, and potentially let go of some of Phobos 2's baggage.

One of the cool things about Phobos 3 is that backwards compatibility is not a primary goal although there will be some work to make of the transition easier. So if we think it would be prudent to re-open the design of something based on prior experience that is well within our scope. We do have to be mindful of time as there are a ton of modules/types to get through and very limited labor pool but beyond that we're here to build the best version of Phobos we can. If that means redesigning then that's what we do. JMD has already done a ton of redesign work on Traits.

As far as Tuple is concerned, Timon is working on building them into the language so that we don't need to worry about it. Apparently the implementation is done, he just needs to do the PR and DIP for it. We've been discussing on Discord whether or not to port the Phobos tuples at all.

4 days ago
On Sunday, 17 November 2024 at 03:13:20 UTC, Jonathan M Davis wrote:
> e.g. in the case of Nullable [...] adding the ability to cast to bool in addition to using hasValue (or whatever we call the replacement for isNull)

https://github.com/dlang/phobos/pull/9039

> and adding the ability to dereference it (that way, it can be used in if conditions just like a pointer, and templated code could work with either pointers or Option/Maybe/Whatever ).

I don't think this is a great idea. Option!T has value semantics (w.r.t. the T value), but T* has reference semantics, so generic code that tries to work with both will likely fall into the same pitfalls that code using input ranges currently does.

> Personally, it's on my todo list to sit down and look through how Rebindable and friends need to be reworked, since that's kind of a mess, and some of it is potentially going to affect how we deal with ranges.

Mathis Beer/FeepingCreature did a bunch of work on this, including a DConf talk [1]. Might be worth getting in touch with him.

[1] https://www.youtube.com/watch?v=eGX_fxlig8I
3 days ago

On Sunday, 17 November 2024 at 10:51:27 UTC, Adam Wilson wrote:

>

We do have to be mindful of time as there are a ton of modules/types to get through and very limited labor pool but beyond that we're here to build the best version of Phobos we can. If that means redesigning then that's what we do. JMD has already done a ton of redesign work on Traits.

Is there any place where interested parties can check on the current state of Phobos 3 development, and find out which modules/types are in-progress vs. up for grabs? If not, it might be a good idea to create one--maybe a Github projects page, like the one in this recent announcement.

>

As far as Tuple is concerned, Timon is working on building them into the language so that we don't need to worry about it. Apparently the implementation is done, he just needs to do the PR and DIP for it. We've been discussing on Discord whether or not to port the Phobos tuples at all.

Built-in tuples for Phobos 3 would be awesome! If they support named fields, then there's definitely no reason to keep Phobos Tuple around IMO. If not, there might be room in Phobos 3 for a NamedTuple type (a la Python).

3 days ago

On Sunday, 17 November 2024 at 12:51:44 UTC, Paul Backus wrote:

>

Is there any place where interested parties can check on the current state of Phobos 3 development,

I believe everyone new eventually left the planning forums and the actual code consists of 4(ish) copy and pasted files from phoboes v2; feel free to guess my opinion on the the forum posts about highly theoretical range api bug fixes.

3 days ago
On Sunday, November 17, 2024 5:08:14 AM MST Paul Backus via Digitalmars-d wrote:
> On Sunday, 17 November 2024 at 03:13:20 UTC, Jonathan M Davis
>
> wrote:
> > e.g. in the case of Nullable [...] adding the ability to cast to bool in addition to using hasValue (or whatever we call the replacement for isNull)
>
> https://github.com/dlang/phobos/pull/9039
>
> > and adding the ability to dereference it (that way, it can be used in if conditions just like a pointer, and templated code could work with either pointers or Option/Maybe/Whatever ).
>
> I don't think this is a great idea. Option!T has value semantics (w.r.t. the T value), but T* has reference semantics, so generic code that tries to work with both will likely fall into the same pitfalls that code using input ranges currently does.

Hmm. You may be right about that. There are definitely cases where you want that kind of behavior, but it may be better to do that with a type specifically for that.

> > Personally, it's on my todo list to sit down and look through how Rebindable and friends need to be reworked, since that's kind of a mess, and some of it is potentially going to affect how we deal with ranges.
>
> Mathis Beer/FeepingCreature did a bunch of work on this, including a DConf talk [1]. Might be worth getting in touch with him.
>
> [1] https://www.youtube.com/watch?v=eGX_fxlig8I

Yeah. I actually had to fix some bugs introduced by some of his improvements to Phobos v2 for Rebindable-related stuff recently, since it has to play some fun games with the type system to work, and there was a corner case that was missed, which unfortunately, happens too often with some of this kind of stuff. So, I need to look at the improvements which have been made and figure out how to make it all more cohesive. In particular, I think that we need distinct types for specific use cases rather trying to make the same wrapper type work with everything (e.g. the use case of having a mutable reference to a const class is fundamentally different from trying to reuse memory on the stack for different const structs, and having a thread-local reference to a shared class reference needs to be its own thing). And unfortunately, move constructors are probably going to make the situation more complicated. So, I need to sit down and work through all of that, and I'm sure that Mathis will want to give feedback on it.

A key question in all of it is how best to handle ranges which hold their elements (or even just front) directly on the stack, since some of what Mathis has done has been geared towards being able to "rebind" immutable values so that ranges which hold their values on the stack can work with them, and I'm not sure if we want to have the ranges themselves worrying about that or whether we're going to be better to have the user wrap them instead. Trying to have ranges handle that case for us potentially means having ranges in general having to use wrapper types internally, which isn't great, but holding data on the stack tends to be an implementation detail of ranges, so I'm going to have to take the time to work through that and propose what makes the most sense. Mathis has already expressed interest in seeing how the new range stuff deals with all of that, since it directly affects how they use ranges where he works.

In any case, thanks for the reminder and the link.

- Jonathan M Davis



3 days ago

On Saturday, 9 November 2024 at 04:34:20 UTC, Adam Wilson wrote:

>

Porting std.typecons to Phobos 3

where is PhobosV3?

3 days ago

On Monday, 18 November 2024 at 01:05:36 UTC, zjh wrote:

>

On Saturday, 9 November 2024 at 04:34:20 UTC, Adam Wilson wrote:

>

Porting std.typecons to Phobos 3

where is PhobosV3?

https://github.com/dlang/phobos/tree/master/phobos

3 days ago

On Monday, 18 November 2024 at 02:24:48 UTC, Nicholas Wilson wrote:

>

https://github.com/dlang/phobos/tree/master/phobos

Thank you.