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 echo() and assert() #1587
Add echo() and assert() #1587
Conversation
{ | ||
inst->scope.apply(c); | ||
std::vector<AbstractNode *> instantiatednodes = inst->instantiateChildren(&c); | ||
node->children.insert(node->children.end(), instantiatednodes.begin(), instantiatednodes.end()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since applyChildren() is always called on a fresh node, it's not necessary to copy, we can just do like the GroupNode: node->children = inst->instantiateChildren(&c);
This is mainly for debugging expressions or functions as the existing echo() is only usable on statement level. The echo() expression works like let(), including the sequential assignment with the additional side effect of printing all the arguments and if there is an expression following the echo(), this expression is evaluated and printed last.
This means the assignment is handled sequentially and a new scope is created. Children are able to use variables from the new scope and are otherwise just passed on to the parent without change.
a6fb034
to
cb256d7
Compare
cb256d7
to
d5faa73
Compare
Updated |
LGTM, will test soon |
Is there anything I can do to help with getting this PR accepted and merged? I'd love to have this feature. |
@greyltc The sequential assignment issue needs to be resolved, which I guess needs some discussion. Apart from that, help with documentation/cheat sheet and an example would be cool. |
@kintel said "The sequential assignment issue needs to be resolved" My view is that echo() should not have sequential assignment semantics.
|
It would simply behave like |
As the pull request is pretty much dead due to the massive conflicts, I've extracted the I'll wait with |
Since echo in functions is for debugging, it seems wrong to me that it can On 22 October 2016 at 23:42, Torsten Paul notifications@github.com wrote:
|
@nophead has a good point. Are there any obvious uses for this feature? |
What @nophead said. You should be able to comment out an echo(...) without it changing the meaning of the program, but that's not safe if |
-1 let() style. |
There's nothing to get in, so far it's only listing what is not wanted (actually we may want to move the discussion to some new issue as that pull request is dead regarding the code attached). There's no need that As for the side effect, that's certainly a point that makes sense. To get forward, maybe we should leave |
Why can't echo in a function work just the same as the statement version? People have been desperate for this for ages. Several times I have On 25 October 2016 at 22:27, Torsten Paul notifications@github.com wrote:
|
Using the |
See #1830 for updated |
Could assert be made to handle multiple expressions, comma separated? This code passes without any error, is that intended? |
This can be handled with Does OpenSCAD have an |
@krichter722 It's still experimental and must be enabled from Preferences. See here for the TODO list for next step: #1860 |
As the wiki mentions: "[Note: Requires version 2017.01 Experimental Build]" |
Fixes #381
TODO:
toHtmlEscaped
which is only available in Qt5. SeeQt::escape(src)
message=
proposal -> Consider rewriting assert() -> assert(condition=, message=) (i.e. single condition). Might need more discussion--enable=echo
.This adds
assert()
as expression and statement andecho()
as expression. In addition theecho()
statement is aligned with the new behavior of using sequential assignment and return child modules.echo expression:
assert expression:
assert statement: