Open balacij opened 1 year ago
Can you also show how you tried to build that function? Some of these things work, as it is used in GlassBR.
The issue with Python is likely to be different.
Yes, that would be good to have :sweat_smile:
I tried to build that function by defining y_b
has an equational model: https://github.com/balacij/Drasil/blob/e0c230521b3b2f2f182799711c6e762df94c3b8e/code/drasil-example/bmbnd/lib/Drasil/BmBnd/InstanceModels.hs#L8-L26 . Afterwards, when I was trying to build it manually, similar to GlassBR, I came across #3321.
GlassBR does use function-typed things in code generation:
But it is mostly done manually: https://github.com/JacquesCarette/Drasil/blob/b73f49ff4a144322d1b1840d43a45b4ad64a074e/code/drasil-example/glassbr/lib/Drasil/GlassBR/ModuleDefs.hs#L164-L219
This seems like a bunch of different, non-trivial bugs. Do you want to have a stab at them, or do you want me to look first?
I'll try to have a look at it as soon as I can, but I want to focus a bit of energy on #2873 first.
While trying to build my Beam Bending project for CAS 741, I came across what @JacquesCarette previously mentioned: generating code for defined functions is largely broken. It looks like there is a clash somewhere in how 'functions' are understood, and it results in odd translation.
For example, I was trying to build a function
y_B (x)=e_B
[note that it ignores thex
variable], but the resultant code is largely confusing (ignoring the existing typing issues). The generated code is publicly available. For example,C++ has declarations missing type signatures: https://github.com/balacij/Drasil/blob/e0c230521b3b2f2f182799711c6e762df94c3b8e/code/stable/bmbnd/src/cpp/Calculations.hpp#L8-L12
C# adds extras: https://github.com/balacij/Drasil/blob/e0c230521b3b2f2f182799711c6e762df94c3b8e/code/stable/bmbnd/src/csharp/Calculations.cs#L7-L13
Java is similar to C++ in that it doesn't have a well-defined type signature (missing return type): https://github.com/balacij/Drasil/blob/e0c230521b3b2f2f182799711c6e762df94c3b8e/code/stable/bmbnd/src/java/BmBnd/Calculations.java#L9-L15
Swift code tries to generate curried higher-order functions: https://github.com/balacij/Drasil/blob/e0c230521b3b2f2f182799711c6e762df94c3b8e/code/stable/bmbnd/src/swift/Calculations.swift#L5-L11
Additionally, Drasil currently complains when generate Python code with function definitions: