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

Potential for static verification? #4

Open
hcphoenix opened this issue Apr 29, 2018 · 2 comments
Open

Potential for static verification? #4

hcphoenix opened this issue Apr 29, 2018 · 2 comments

Comments

@hcphoenix
Copy link

I'm getting from the readme and skimming the source that all contracts are evaluated at runtime, right?

I'm very interested in the possibility of static verification--see the .NET Code Contracts library for one example of this. I ask because if this isn't currently suppported then it's something I'm interested in working on, and I suspect that Nim's AST manipulation features are robust enough to allow it.

@Udiknedormin
Copy link
Owner

Sorry to answer after such a long time.

Yes, I know about static verification tools for .NET, JVM and many others, but it's not currently supported by NimContracts. Nim's AST can, of course, give you much information about the code itself, but in itself, it doesn't have much static analysis power (even though compiler does has some). One of the problems is that Nim's macros are written for simplicity rather than providing the user with absolutely every bit of information available, so pretty much the whole engine would need to be written separately or as a serious plug-in to the compiler. In fact, it seems to me it should be an external program to be run on the code rather than just the compiler running checks before compiling... unless you write that program in Nim and provide a macro to run it during compilation.

As for now, I don't really have time to work on a Nim static analysis tool but feel free to use NimContracts for that if you see it fit. I hope to try my best on that one day too.

Anyway: thank you for asking. :) Good to see that there are people actually interested in that topic.

@Udiknedormin
Copy link
Owner

Update: I can see Nim version 1.2 added built-in support for pragmas with almost the same names as the ones used by NimContracts. I think it might be a good point to consider using those, as any external tools can be expected to operate on them.

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

2 participants