[Cuis-dev] curried blocks

Jon Raiford raiford at labware.com
Sat Aug 3 09:44:40 PDT 2024


Especially as a new user to Smalltalk, I would suggest leaning into Smalltalk concepts rather than trying to bring functional programming into Smalltalk.  Although I can’t think of any, there may be a real world benefit to curried blocks in Smalltalk. I think this may be a better subject to breach after a bit more mastery.

A natural reaction to this would be “how would you do it differently?”. That may seem like a fair question, but I think it requires a use case that you are trying to solve.

Jon

From: Cuis-dev <cuis-dev-bounces at lists.cuis.st> on behalf of Mark Volkmann via Cuis-dev <cuis-dev at lists.cuis.st>
Date: Friday, August 2, 2024 at 7:54 PM
To: Discussion of Cuis Smalltalk <cuis-dev at lists.cuis.st>
Cc: Mark Volkmann <r.mark.volkmann at gmail.com>
Subject: [Cuis-dev] curried blocks
I wanted to see if it was possible to define a class that supports partial application with blocks. The goal is to be able to pass fewer arguments than a block requires and get back a new "block" that requires the remaining arguments. Perhaps this has already been done and I just didn't find it.

Here are examples of using my solution:

cb := CurriedBlock block: [:a :b | a + b].
cb valueWithArguments: #(2 3). "5"

cb2 := cb valueWithArguments: #(5). "a new CurriedBlock"
cb2 valueWithArguments: #(7). "12"

I attached my solution as a fileOut. I'd love to get some feedback in terms of style and better ways to implement it. What would you do differently?

--
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240803/2667d166/attachment-0001.htm>


More information about the Cuis-dev mailing list