-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add assert statements #26
Comments
Since we have |
Yes and no. I am a fan of clarity here. And it is more complicated to insert an operator and brackets in the right place than to write false explicitly. It costs very little to add once you have assert_true so why not support it too? |
The big caveat here is that everything we add right now must be chained through each layer of the compiler, from the parser to the code generation. We're not extending some library, but the compiler itself. The more convenience functionality we add right now, the more we will need to maintain at a later stage. When we have module support, we can do some things through libraries instead. What we could do is to have a single Assert node in the AST and let the parser figure out what its parameters should be (i.e., if we're expecting true or false). |
Let’s move this discussion to email. |
You could add an abort statement to the AST. The rest can be done via a transformation. We probably need to start thinking if a standard lib/prelude with such definitions, even if it is naked into the compiler for now. Sent from my iPhone On 08/08/2014, at 10:18, EliasC notifications@github.com wrote:
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm |
@supercooldave An abort command is a good idea. I'm going to add a de-sugaring pass to the compiler to try to make additions of functionality a bit more light weight. |
Maybe there could be a file of "standard definitions" that could be scooped up by the compiler. This would avoid the need for a lot of standard things being baked into the compiler, especially with embedded C. Sent from my iPhone On 08/08/2014, at 10:56, EliasC notifications@github.com wrote:
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm |
I've added a desugaring pass to the compiler (see So far it generates terrible error messages since the typechecker works with the desugared AST, but I guess we can live with that for now. One possible way around it is to let desugared nodes have a reference to the thing it was desugared from, and somehow letting the error message refer to this instead of the actual AST. @TobiasWrigstad, I'm assigning you to try the desugarer out by adding the cases for formated error printing (please close this issue when you're done). |
:) |
All of the above supported as of now. |
Please add two assert statements:
I prefer that
msg
be optional.I also prefer that if possible,
msg
can be a printf-style string with {} interpolation markers so that I can writePreferably even without having to explicate the
\n
at the end, too!(Yes, I realise that by allowing expressions which may fail in asserts the asserts may not print fine etc.)
The text was updated successfully, but these errors were encountered: