Skip to content

Preview typefunctions#12101

Closed
UplinkCoder wants to merge 97 commits intodlang:masterfrom
UplinkCoder:preview_typefunctions
Closed

Preview typefunctions#12101
UplinkCoder wants to merge 97 commits intodlang:masterfrom
UplinkCoder:preview_typefunctions

Conversation

@UplinkCoder
Copy link
Member

Preview switch for typefunction functionality.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @UplinkCoder!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#12101"

@UplinkCoder UplinkCoder force-pushed the preview_typefunctions branch 3 times, most recently from b82b7fc to 1a983d7 Compare January 5, 2021 17:35
Copy link
Member

@WalterBright WalterBright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair warning: I'm very predisposed in favor of the far simpler approach in #12029

That said, what this is missing is:

  1. document or DIP describing what type functions are, how to use them, grammar, etc.
  2. a description of how the implementation is designed. There's a thousand lines of code with very little in the way of any description. Like what's a Ttype?

Copy link
Contributor

@RazvanN7 RazvanN7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides Walter's comments, this needs a changelog entry, a spec PR and all lines of code that were added need to be covered by tests (currently there are a lot of lines that are not covered).

@RazvanN7 RazvanN7 added Review:Needs Changelog A changelog entry needs to be added to /changelog Review:Pending DIP Approval Review:Needs Spec PR A PR updating the language specification needs to be submitted to dlang.org Review:Needs Tests labels Jan 6, 2021
@UplinkCoder
Copy link
Member Author

UplinkCoder commented Jan 8, 2021

@WalterBright the performance characteristics and ease of use of #12029
are not the same as the ones in this PR.
You have gotten aliasAssign merged without a DIP.
On the basis that it is purely additive.
I don't see why the same reasoning shouldn't apply to this PR once I've done all the changed to astbase.d to make it pass CI.

This PR is also additive as it provides a syntax and semantic extension that was not available previously and is behind a preview flag.

Ttype is the type of types.
is(typeof(int) == __type__)
iff -preview=typefunctions is given

And that is incidentally the only change which might affect working code.
Though I have found only once place in Phobos,
the CommonType template where it actually does.
And CommonType can be easily fixed to behave the same regardless of whether typefunctions are enabled. (dlang/phobos#7663)

@UplinkCoder
Copy link
Member Author

Who put needs tests there?
it has tests.

@RazvanN7
Copy link
Contributor

I did because there are a lot of uncovered lines in this PR. Just from the top of my head you still need tests for:

  • nested type functions
  • aliases to type functions
  • overloaded type functions
  • introducing a type function into an overload set

@UplinkCoder
Copy link
Member Author

I did because there are a lot of uncovered lines in this PR. Just from the top of my head you still need tests for:

  • nested type functions
  • aliases to type functions
  • overloaded type functions
  • introducing a type function into an overload set

Ah yes.
Very good points!

I shall add them.

@nordlow
Copy link
Contributor

nordlow commented Jan 10, 2021

Would be interesting to find relevant benchmarks, using common patterns such as staticMap, that highlight drops in compilation time and memory usage when using type functions compared to traditional template-solutions including new alias-assign.

@UplinkCoder UplinkCoder force-pushed the preview_typefunctions branch 5 times, most recently from 34cd6a5 to 90fc39b Compare January 27, 2021 16:31
@maxhaton
Copy link
Member

Would be interesting to find relevant benchmarks, using common patterns such as staticMap, that highlight drops in compilation time and memory usage when using type functions compared to traditional template-solutions including new alias-assign.

@nordlow There should be a blog post soon-ish on what typefunctions are and aren't, some background on why they could be useful, and what their ethos implies for the rest of D

UplinkCoder and others added 18 commits January 30, 2021 18:45
this is a temporary meassure to pass phobos tests which are not expecting a type of types to exist
An is evaluated quite early in the process.
Therefore when resolving the type or what is within an is expression,
to determinte whether it has to deferred to CTFE for type function purposes
the information is not enough to know that you are working on a type varible
therefore we need to special case the type resolving process to treat type variables
(a TypeExpression with a VarExp in it) specially.
@UplinkCoder UplinkCoder force-pushed the preview_typefunctions branch from 673a96e to 2f87630 Compare January 30, 2021 17:49
@UplinkCoder UplinkCoder force-pushed the preview_typefunctions branch from 2f87630 to bab70b1 Compare January 30, 2021 18:04
@UplinkCoder
Copy link
Member Author

On Hold while more fundamental issues are being addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review:Needs Changelog A changelog entry needs to be added to /changelog Review:Needs Spec PR A PR updating the language specification needs to be submitted to dlang.org Review:Needs Tests Review:Pending DIP Approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

Comments