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

RFC change semantics for parens-less 0 argument templates #183

Open
timotheecour opened this issue May 13, 2020 · 0 comments
Open

RFC change semantics for parens-less 0 argument templates #183

timotheecour opened this issue May 13, 2020 · 0 comments

Comments

@timotheecour
Copy link
Owner

timotheecour commented May 13, 2020

current implementation implicitly resolves 0-arg templates as a call; IMO it's a design mistake that should be fixed, and it should require a pragma {.implicitcall.} eg:

template fun(): string = "foo"
doAssert fun() == "foo" # ok
doAssert fun == "foo" # should CT error
template fun2(): string {.implicitcall.} = "foo"
doAssert fun2() == "foo" # should CT error
doAssert fun2 == "foo" # ok

alternative proposal (just different syntax, same idea)

instead of {.implicitcall.}, use template fun2 without parens:

template fun(): string = "foo"
doAssert fun() == "foo" # ok
doAssert fun == "foo" # should CT error
template fun2: string = "foo"
doAssert fun2() == "foo" # should CT error
doAssert fun2 == "foo" # ok

links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant