🔄 DevLog: Seamless Pascal + C++ Mixing - Write Both Languages in One Statement #10
jarroddavis68
started this conversation in
DevLog
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Version: JetPascal 0.2.0+
🎉 What's New
JetPascal now lets you mix Pascal and C++ code freely in the same program, the same statement, even the same expression. No mode switches. No declarations. No wrapper code.
Just write both languages together.
💡 What This Means
You can now:
✅ Call C++ standard library functions from Pascal
✅ Call Pascal runtime functions from C++ code
✅ Mix both languages in a single expression
✅ Use C++ math, string, and I/O functions directly
✅ Debug with accurate line numbers pointing to your Pascal source
And it all happens automatically.
📝 Example: Mixing Pascal and C++
Here's what you can write now:
This just works. No special setup. No mode switches. No declarations.
🔬 Real Examples We Tested
We verified this with 8 different mixing scenarios:
1. Pure Pascal
Standard Pascal code works as always.
2. Pure C++
Write C++ directly in your Pascal program.
3. Pascal Calling C++
Use C++ standard library functions inside Pascal statements.
4. C++ Calling Pascal
Call Pascal runtime functions from C++ code - they automatically get the
jp::namespace.5. Pascal Calling Pascal
Normal Pascal code continues to work perfectly.
6. Mixed Expressions
C++ I/O with Pascal functions and C++ math operators.
7. Complex Nesting
Nested function calls work correctly with proper parenthesis matching.
8. Multiple Arguments
Mix Pascal functions, literals, and expressions in one call.
🎯 What Makes This Special
No Mode Switches
You don't need to enable "C++ mode" or switch between languages. Just write what you need.
No Declarations
You don't need to declare C++ functions. Just use them. The C++ compiler handles everything.
No Namespace Confusion
Pascal functions automatically get the right namespace when called from C++ code.
No Mental Overhead
Write Pascal where Pascal makes sense. Write C++ where C++ makes sense. Mix them where mixing makes sense.
💻 Generated C++ Output
When you write:
JetPascal generates:
Notice:
writelnbecomesjp::writelnstd::sqrtstays as-isParamCount()becomesjp::ParamCount()in C++ context#linedirectives map back to your Pascal sourceAll automatic. All correct.
🔧 What This Opens Up
Access to C++ Standard Library
Use C/C++ Functions Directly
Mix in Complex Expressions
🎓 How to Use It
Step 1: Write Pascal code as normal
Step 2: When you need C++ functionality, just use it:
std::coutfor outputstd::sqrt,std::absfor mathprintf,sprintffor C functionsStep 3: Compile and run - it just works
Quick Start Example
Create
test.pas:Build and run:
Output:
🚀 Why This Matters
For Pascal Developers:
You get instant access to the entire C++ ecosystem. Need string formatting? Use
std::format. Need file I/O? Usestd::filesystem. Need math? Use<cmath>. All available directly.For C++ Developers:
You can write clean Pascal syntax where it makes sense, and drop into familiar C++ when needed. Best of both worlds.
For Everyone:
No more writing wrapper code. No more FFI declarations. No more "glue" between languages. Just write code.
📊 What Changed from Before
Before:
After:
From declaration hell to just writing code.
🎯 Current Status
What Works Now:
🎬 Try It Yourself
Create this test program:
Build, run, and see both languages working together seamlessly!
💭 Final Thoughts
This feature represents a fundamental shift in how Pascal interoperates with C++. We're not "calling into" C++. We're not "wrapping" C++.
We're just using both languages naturally.
Write Pascal where Pascal is elegant. Use C++ where C++ is powerful. Mix them where mixing makes sense.
That's the JetPascal way.
JetPascal™ - Accelerate Your Code!
Beta Was this translation helpful? Give feedback.
All reactions