-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
runnableExamples now run at module level #11732
runnableExamples now run at module level #11732
Conversation
But we don't support a combination of default values and |
f0667f8
to
52adcde
Compare
I pushed commits to make it opt-out, so the default is now
We still need a way to opt out (ie allow
true, that's what I was seeking in optional params before |
I don't understand the problem this fixes. |
I second the request to implement the support for optional params before untyped body. Actually, I've implemented quite an elaborate hack to simulate it in our eth-p2p library here: |
@zah I agree that optional parameters before a code block are neat. But that should be done in a proper RFC. We can't continue to patch in everything in the language that we think is useful at that moment without properly checking that it won't cause conflicts with other features of the language. |
yes, you can add a scope, but you can't remove the one the compiler automatically adds to each runnnableExamples, making it impossible to create runnableExamples for anything that requires moduel scope, see tests/magics/trunnableexamples.nim for some such examples; so i can update the PR to just make |
Just to clarify it further: "fixing" runnableExample so that it supports more features is fine if the patch it not unreasonably large to accomplish this, but don't add yet-another optional parameter to it. You never get a reliable product out of a mess of configuration options, the combinatorial explosion always wins. |
b380a56
to
af22bb4
Compare
done, PTAL, runnableExamples now just has semantics of topLevel=true, without option; if user needs he can just simply nest under a block |
this PR allows
runnableExamples
to generate code at module scope, which is needed in some cases where code inside a block would not work. The option is opt-in so no existing code is affected.See
tests/magics/trunnableexamples.nim
for unittests, it also shows some examples where module scope is needed