[Cuis-dev] Bag>>#sum:ifEmpty:
Juan Vuletich
juan at cuis.st
Thu Nov 3 07:59:26 PDT 2022
On 11/3/2022 11:21 AM, Luciano Notarfrancesco via Cuis-dev wrote:
> Yes, the idea of functional blocks could be very interesting. But the
> most straight forward idea of blocks that don’t modify state at all
> wouldn’t work, it would be more complicated than that.
> For example, the block [:x | x / 2] is a function for integers and
> fractions in the sense I was using before, e.g. evaluating it multiple
> times at 3 returns always 3/2. But it modifies object memory and
> creates new instances of 3/2 each time (they are equal but not identical).
> So I think perhaps the notion of “functional blocks” should be used
> differently in Smalltalk, not strongly as in functional languages, but
> dynamically and in terms of behavior, similarly as how we deal with
> types (for example in methods that assume their arguments implement
> certain protocols, but without enforcing types explicitly like other
> languages).
Instead of "without modifying any existing object at all" I'd have said
"without modifying any previously existing object at all". The idea is
to disable modifying older objects, but to allow creating / modifying
new objects, created during the execution of the block. That would be
pretty close to what functional languages do, that is to allow
modification only during creation.
> Later I’ll write some comments for the methods that assume the blocks
> are functions. I should have documented that more clearly.
>
> On Thu, 3 Nov 2022 at 20:28 Juan Vuletich <juan at cuis.st
> <mailto:juan at cuis.st>> wrote:
>
> A feature that would be nice to have is functional blocks. Some
> way to be certain that some block will evaluate without modifying
> any existing object at all. Then, Smalltalk would be better as a
> functional language, and many operations taking a block would be
> more natural.
>
> Just rambling out loud.
>
> BTW, comments at these methods could be enhanced, possibly with
> links to this email thread.
>
> Cheers,
>
>
--
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20221103/e0efdfd7/attachment.htm>
More information about the Cuis-dev
mailing list