question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiline functions

See original GitHub issue

It seems that only one way to implement multiline functions exists (fast and clear):

  1. Use includes instead of functions;
    #include filename
    
    It’s works like simple text insertion in this place (several includes in different parts of the file are allowed)
  2. Use variable replaces with #include (include bonus) file main.cpd:
    τ_max=200MPa
    τ=150MPa
    #include check_stress: τ->σ; τ_max->σ_max
    
    file check_stress.cpd:
    #if σ ≤ σ_max
      '<font color="green">It is all OK ('σ' ≤ 'σ_max')</font>
    #else
      '<font color="red">It is problem ('σ' > 'σ_max')</font>
    #end if
    
    file main.cdp processed like this single file:
    τ_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
    
  3. 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:closed
  • Created 2 years ago
  • Comments:35 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
Proektsoftbgcommented, Aug 8, 2022

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.

1reaction
Proektsoftbgcommented, Aug 3, 2022

image It is OK in my version. I will send it to you soon.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found