[Pharo-users] Re: Porting from VW to Pharo

2023-04-13 Thread Steffen Märcker
Hi Christian, I am working slowly through the required changes. Thanks for your comprehensive answer. When I have made some more progress, I think having a call would be nice. I'll try loading the package again from store later today. One quick question: As far as I understand, to extend clas

[Pharo-users] Re: Collection>>reduce naming

2023-04-13 Thread Sebastian Jordan Montano
Hello Steffen, Let's take Kotlin documentation (https://kotlinlang.org/docs/collection-aggregate.html#fold-and-reduce) > The difference between the two functions is that fold() takes an initial > value and uses it as the accumulated value on the first step, whereas the > first step of reduce()

[Pharo-users] Re: Comparison of blocks

2023-04-13 Thread Richard O'Keefe
There is no agreement between Smalltalk systems about how to compare block contexts for equality. In Smalltalk-80 (and I have two versions of Smalltalk-80 to compare), block equality is identity. The same in VisualAge Smalltalk 8.6.3. The same in GNU Smalltalk. The same in Smalltalk/X-JV. Squea

[Pharo-users] Re: Collection>>reduce naming

2023-04-13 Thread Richard O'Keefe
Actually, #inject:into: is what is normally called fold or foldl, and #reduce: is commonly called fold1. It is very confusing to call foldl1 #fold:. To the best of my knowledge, the name 'reduce' comes from APL. "Z <- LO/R has the effect of placing the function LO between adjacent pairs of item

[Pharo-users] Re: Collection>>reduce naming

2023-04-13 Thread Richard O'Keefe
The standard prelude in Haskell does not define anything called "fold". It defines fold{l,r}{,1} which can be applied to any Foldable data (see Data.Foldable). For technical reasons having to do with Haskell's non-strict evaluation, foldl' and foldr' also exist. But NOT "fold". https://hackage.h

[Pharo-users] Re: Porting from VW to Pharo

2023-04-13 Thread Christian Haider
Great, you perfectly understood the CodeHolder! Instance variables not present? Leave them undeclared. Since that code never runs in this image, it does no harm. It just fills your Undeclareds list. Here is an example where I extend an existing class referencing a variable (#array) only

[Pharo-users] Re: Comparison of blocks

2023-04-13 Thread Steffen Märcker
Hi Richard! You're completely right. Function equivalence is a beast and in the context of a computer program undecidable for nontrivial cases. And that's a valid reason to ban this entirely. Personally, I can also see some value in recognizing equality in trivial cases, e.g., 1) constant bloc

[Pharo-users] Re: Collection>>reduce naming

2023-04-13 Thread Steffen Märcker
Hi Richard and Sebastian! Interesting read. I obviously was not aware of the variety of meanings for fold/reduce. Thanks for pointing this out. Also, in some languages it seems the same name is used for both reductions with and without an initial value. There's even a list on WP on the matter:

[Pharo-users] Re: Comparison of blocks

2023-04-13 Thread Steffen Märcker
I forgot: Is there currently a good way to test whether a block is a copying block (in the VW meaning) in Pharo (11)? This means a block that: - Copies only variables not changing after block creation - Does not need the outer context for evaluation So far did not find an obvious way. It seems t

[Pharo-users] Re: Collection>>reduce naming

2023-04-13 Thread Richard O'Keefe
OUCH. Wikipedia is as reliable as ever, I see. compress and reduce aren't even close to the same thing. Since the rank of the result of compression is the same as the rank of the right operand, and the rank of the result of reducing is one lower, they are really quite different. compress is Fortr

[Pharo-users] Re: Collection>>reduce naming

2023-04-13 Thread Steffen Märcker
:-D I don't know how compress made onto that site. There is not even an example in the list of language examples where fold/reduce is named compress. Richard O'Keefe schrieb am Donnerstag, 13. April 2023 16:34:29 (+02:00): OUCH. Wikipedia is as reliable as ever, I see. compress and reduce ar

[Pharo-users] Re: Collection>>reduce name clash with transducers

2023-04-13 Thread Steffen Märcker
The reason I came up with the naming question in the first place is that I (finally !) finish my port of Transducers to Pharo. But currently, I am running into a name clash. Maybe you have some good ideas how to resolve the following situation in a pleasant way. - #fold: exists in Pharo and is