Multiline functions
See original GitHub issueIt seems that only one way to implement multiline functions exists (fast and clear):
- Use includes instead of functions;
It’s works like simple text insertion in this place (several includes in different parts of the file are allowed)#include filename
- Use variable replaces with #include (include bonus)
file main.cpd:
file check_stress.cpd:τ_max=200MPa τ=150MPa #include check_stress: τ->σ; τ_max->σ_max
file main.cdp processed like this single file:#if σ ≤ σ_max '<font color="green">It is all OK ('σ' ≤ 'σ_max')</font> #else '<font color="red">It is problem ('σ' > 'σ_max')</font> #end if
τ_max=200MPa τ=150MPa #if τ ≤ τ_max '<font color="green">It is all OK ('τ' ≤ 'τ_max')</font> #else '<font color="red">It is problem ('τ' > 'τ_max')</font> #end if
- namespaces instead of local variables
It’s just an invisible prefixes for variables.
Bonus - block #namespace…#namespace end - to make it more automatic
a=10' shows a=10 b=20' shows b=20 ns1::a=11' shows a=11 a' shows a=10 ::a' shows a=10 ns1::a' shows a=11 b' shows b=20 ::b' shows b=20 #namespace ns1 a' shows a=11 b' shows b=20 - if b missing for this namespace search in top namespace b=21' when assigning - use current namespace b' shows b=21 ::b' shows b=20 ns1::a' shows a=11 ::a' shows a=10 #end namespace a' shows a=10 b' shows b=20 ns1::a' shows a=11 ns1::b' shows b=21 #namespace ns1 a' shows a=11 #end namespace
P.S. Includes is the most wanted feature here. Even if nothing else will be implemented. (it’s solves problems with big file navigation, very nice to extract generated svg images/methods into separate files, it’s partly solves problems with missing string values)
Issue Analytics
- State:
- Created 2 years ago
- Comments:35 (17 by maintainers)
Top Results From Across the Web
Notation for multiline function
Mathematical functions are often written as f(x)=x2 or similar, but I have never seen a notation for a function that is over multiple...
Read more >Multiline Functions - General
I am doing something wrong when I try to create a function. I enter. I want to enter "myfunc3 <- variable(a) {" and...
Read more >Arrow functions, the basics
Multiline arrow functions. The arrow functions that we've seen so far were very simple. They took arguments from the left of => ,...
Read more >Creating a multiline function with localized variables
I would like to create a function with several expressions in the code body. For example, I would like to write something like...
Read more >Multiline arrow functions and Javascript's syntactic baggage
So my buggy example function is actually creating a multiline arrow function containing a label named value. Since there's no return statement, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Great! I am glad that it works for you. Probably I can optimize the internal editor to work faster. There were plenty of new features added recently.
Next steps is to fully implement the deg/rad/grad units as discussed. Also, input values embedded in code {1.23}. We need to update the documentation and other resources.
I thhink that the next majour change should be vectors and matrices. They are needed very much to make Calcpad a fully functional math environment.
I will close this issue now as it was generally implemented. If you find anything, you can open a separate issue since this one became too long ad difficult to follow.
It is OK in my version. I will send it to you soon.