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

getType now works with tyInferred (arising from concepts); refs #18220 #18241

Merged
merged 3 commits into from
Jun 12, 2021

Conversation

timotheecour
Copy link
Member

@timotheecour timotheecour commented Jun 11, 2021

future work

in future work I'm considering using concept syntax for symbol aliasing/forwarding (templates, iterators, generics, overloaded symchoices, etc; any symbol), ie allowing constraining alias params (from #11992) with concepts, to address #11992 (comment) ;
I'm not committing to this idea, but it's worth exploring at least, eg:

# pass by alias: 1 instantiation per symbol
proc call[T](a: T, fn: alias Callable[R, T]): R =
  fn(a)
template bar(a: SomeFloat): auto = a * 2.0
proc bar[T: SomeInteger](a: T): auto = a * 3
assert call(1.0, alias bar) == 2.0
assert call(3, alias bar) == 2 * 3

# pass by unique type: 1 instantiation per type (only accepts proc|func|closure iterator)
# not sure if this form can also accept symChoices and generics, TBD
# there's also a question regarding optional params, see the
# `1.map1(fn3) == """(1, "zoo", "fn3")"""` caveat mentioned in this PR's tests
proc call2[T](a: T, fn: Callable[R, T]): R =
  fn(a)
proc bar2(a: int): auto = a * 4
assert call2(3, bar2) == 3 * 4

@timotheecour timotheecour changed the title getType now works with tyInferred (concepts); refs #18220 getType now works with tyInferred (from concepts); refs #18220 Jun 11, 2021
@timotheecour timotheecour changed the title getType now works with tyInferred (from concepts); refs #18220 getType now works with tyInferred (arising from concepts); refs #18220 Jun 11, 2021
@timotheecour timotheecour added the Ready For Review (please take another look): ready for next review round label Jun 11, 2021
@Araq Araq merged commit 897e50d into nim-lang:devel Jun 12, 2021
@timotheecour timotheecour deleted the pr_fix_mapTypeToAstX_tyInferred branch June 12, 2021 20:05
PMunch pushed a commit to PMunch/Nim that referenced this pull request Mar 28, 2022
…ang#18220 (nim-lang#18241)

* getType now works with tyInferred (concepts); refs nim-lang#18220

* avoid cast

* add more docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review (please take another look): ready for next review round
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants