|
Now that's funny, I don't care who you are. Larry the cable guy
"Ten men in the country could buy the world and ten million can’t buy enough to eat." Will Rogers
PartsBin an Electronics Part Organizer - Release Version 1.3.1 JaxCoder.com
Latest Article: EventAggregator
|
|
|
|
|
Message Removed
modified 5-Mar-24 13:12pm.
|
|
|
|
|
I mentioned to @jmaida I'd give another example of closures in the language that shall not be named (rhymes with GuavaScript). Closures can not only be used to fake OOP, as it were. They can also be applied to functional concepts. In functional programming, there's a concept called currying. And like anything in tech, it sounds way more complicated than it is.
const fooBar = function(foo) {
return function(bar) {
return foo + bar;
};
};
Let's get fancy now with some modern syntax.
const fooBar = foo => bar => `${foo} and ${bar} sitting in a tree`;
console.log(fooBar, fooBar());
console.log(fooBar('sup')('dawg'));
So you're probably thinking, ok but that's whack. What the fudge do people use currying for? Two reasons actually.
Let's say you got a function to call with the same parameters over and over again, and it just looks nasty. And nasty code is... well nasty. You can clean it up with a curry.
const supDawg = fooBar('sup')('dawg');
console.log(supDawg);
Ok, so that's cool. But let's be real, it's not practical. A practical application of currying would be analogous to an abstract base class in OOP-land and how that helps with reuse. Also, kinda like how an abstract class is never supposed to be directly instantiated, the "abstract" logic should never be directly called outside the scope of the outer function. But, being functional, you get another benefit too.
const doTheHardStuff = function(x) {
const z = doSomethingComputationallyExpensive(x);
return function (y) {
z + y;
}
}
const finishTheJob = doTheHardStuff(10)
finishTheJob(20)
finishTheJob(30)
Now, as you might imagine, that gets hard core what the fudge. But when you need currying, it's super cool. It's also useful in distributed programming when you want to cut down on network requests without polluting a global/module namespace and not relying on static variables, etc. So, yay currying and closures.
Jeremy Falcon
modified 5-Mar-24 13:15pm.
|
|
|
|
|
Message Closed
modified 5-Mar-24 13:11pm.
|
|
|
|
|
I realize this is a joke, but talking about CPU registers and protected memory may seem like a lot to a newbie. As a point of reference.
Jeremy Falcon
|
|
|
|
|
DNFTT.
Spam and Abuse Watch[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hey, honestly asking.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
I have a ZX Spectrum somewhere in my closet.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
|
That's cool though, pulling it off in C#. Major nerd points awarded.
Jeremy Falcon
|
|
|
|
|
Thank you. Much appreciated. A lot to chew on.
BTW contrary to Richard's Demming's jab DNFTT. Smile |
I am not trolling.
I am honestly trying to learn concepts new to me.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
jmaida wrote: contrary to Richard's Demming's jab DNFTT
You seem to be labouring under the misapprehension that I was referring to you. I was not.
Follow the link in my message: there was a troll with the highly amusing username of "poopoopeepee0", whose since-deleted message Jeremy was replying to.
When I posted my comment, you hadn't even replied to the thread. So unless that troll was a sock puppet account you had created, I don't understand your confusion.
Edit: Unless you thought I was referring back to your comments in Marc's thread from yesterday[^]? Which I wasn't.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
no sweat. My error.
I'm finding some issues with my postings.
found this earlier post
"I have a ZX Spectrum somewhere in my closet."
in a totally unrelated thread.
probably user error.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
You’re totally welcome. Btw, Richard was referring to some posts that were deleted. Was a different dude he was talking about, promise.
Jeremy Falcon
|
|
|
|
|
Also there a ton of functional concepts worth chatting about. Maybe it’s my C background but I love the functional paradigm more than OOP. It’s like the cool kid that nobody talks about.
Jeremy Falcon
|
|
|
|
|
I will be getting back after I digest the material you provided.
Like going back to school.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Still working, javascript/React app - not impressed with either javascript OR react.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
#realJSOP wrote: not impressed
I think we'd all be shocked if you were! We might even have asked you to hand in your "Curmudgeons Anonymous" card.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Could you provide a few bullet points?
|
|
|
|
|
New job?
I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.
I’m begging you for the benefit of everyone, don’t be STUPID.
|
|
|
|
|
Yeah, starting in 2022...
The hardest part of the new job is to get the other devs to comment their code...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
#realJSOP wrote: The hardest part of the new job is to get the other devs to comment their code...
If that's seriously the hardest part of the new job...you're doing better than most. Wise are those who avoid incurring the wrath of JSOP.
And - good to hear from you.
|
|
|
|
|
So am I. I’m still writing code for my game with GDI based graphics. No intent to hijack Original Poster’s thread. I think there are plenty of other silent CP users following the daily CP activity.
modified 5-Mar-24 12:04pm.
|
|
|
|
|
Quote: Why did the React class component feel relieved?
A: Because it was now off the hook.
|
|
|
|
|
Damn john, good to hear from you!
Charlie Gilley
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
Has never been more appropriate.
|
|
|
|