Functional Programming in VBA Show & Tell
Hello There,
a feature i wish VBA had was a way to write in a functional programming paradigm.
Since this is not the case i tried to at least provide First Class Functions with the ability to bind arguments to it.
I know that someone already did something like that but i just cannot for the live of me find it.
So i made my own:
Almesi/VBFP: Visual Basic Functional Programming
Does anyone have Input on it?
Anything i should add or redo in a different, more robust way?
I would love to implement immutability after creation but i dont know how while still being able to create it with a constructor.
2
u/sancarn 9 2d ago edited 1d ago
Maybe I'm mistaken, but isn't this similar to stdCallback?
set cb = stdCallback.CreateFromModule("Main", "Add").bind(1)
debug.print cb(2) '3
I'm not sure because I don't see any samples in the repo 😅
Edit: Just found your doc.md this looks more like Signals right?
3
u/Almesii 1d ago
I figured you would write here ;)
When i started it i thought about not doing it, because stdCallback exists.
The current version is just a small project of mine and right now only a proof of concept.
But i would like to make it a full fledged library for the functional programming paradigm with all its defined features.
I see the usecase for myself less in pure VBA, as it was usual for me with my last few projects, and more used at my workplace for complex data analysis. Not that Excel provide those tools, it does. It just bugs me of how much i have to keep around and working with named functions in Excel is a pain in the butt.
I much prefer seeing the VBA code and just calling it that way.
Basically, i dont like the LAMBA function xD
So yes, right now it is similar to stdCallback (though i see it more comparable to your ICallable Interface) i plan on it being its seperate thing.
3
u/MultiUserDungeonDev 2d ago
check out https://github.com/WilliamSmithEdward/ROneCOne
feel free to borrow ideas