Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement RFC-402 #18618

Closed
wants to merge 5 commits into from
Closed

implement RFC-402 #18618

wants to merge 5 commits into from

Conversation

slangmgh
Copy link
Contributor

@slangmgh slangmgh commented Jul 30, 2021

@slangmgh
Copy link
Contributor Author

slangmgh commented Jul 30, 2021

The error msg is not matched with the previous behaviour.
So the tsigmatch.nim check failed.

@timotheecour
Copy link
Member

can the last param be checked specially so that we allow optional params with an untyped body:

when defined case6:
  template fn(a = 1, b = 2, body) = discard

  fn(1, 2):
    foo1
    foo2

  fn(1): # bug: doesn't work
    foo1
    foo2

# Check if the argument count match with the parameter count,
# if doesn't match, fail fast
# See https://github.com/nim-lang/RFCs/issues/402

Copy link
Member

@timotheecour timotheecour Jul 31, 2021

Choose a reason for hiding this comment

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

please add tests to ensure this works and at least doesnt' introduce regressions

things to consider:

  • varags[int]
  • varags[untyped]
  • optional params
    etc

@slangmgh
Copy link
Contributor Author

can the last param be checked specially so that we allow optional params with an untyped body:

when defined case6:
  template fn(a = 1, b = 2, body) = discard

  fn(1, 2):
    foo1
    foo2

  fn(1): # bug: doesn't work
    foo1
    foo2

You can define another overloaded template or using macro with varargs[untyped].

@solo989
Copy link
Contributor

solo989 commented Jul 31, 2021

Making default arguments work with untyped bodies sounds like it should be part of a completely seperate RFC.

Possibly combined with named only arguments support as a pragma or a new postfix operator so it doesn't break existing code.

@metagn
Copy link
Collaborator

metagn commented Feb 23, 2022

Is there anything to do here besides test for varargs[untyped]?

@stale
Copy link

stale bot commented Mar 14, 2023

This pull request has been automatically marked as stale because it has not had recent activity. If you think it is still a valid PR, please rebase it on the latest devel; otherwise it will be closed. Thank you for your contributions.

@stale stale bot added the stale Staled PR/issues; remove the label after fixing them label Mar 14, 2023
@stale stale bot closed this Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Staled PR/issues; remove the label after fixing them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants