Re: [Pharo-users] [ANN] Iterators

2019-08-24 Thread Steffen Märcker

Hi Julien,

nice work! Could you please tell how your approach is related to
transducers from the user perspective and technically?
(https://github.com/Pharophile/Transducers)

Your example suggests that the API is quite similar to the data flow API
of transducers. Let me show your example using transducers.


result := (#+ init: 0) <~ [:x | x * 2] map <~ #(1 2 3).
OrderedCollection with: result.


Or the more classical way:


result := #(1, 2, 3)
transduce: [:x | x * 2] map
reduce: #+
init: 0.
OrderedCollection with: result.



Best regards,
Steffen



[Pharo-users] Putting checkboxes in ListPresenter

2019-08-24 Thread Steve Quezadas
Guys,

I am learning this new "spec" thing. I created a simple Spec "list" object
with the following code:
arbitraryList := ListPresenter new.
arbitraryList
   items: #('one' 'two' 'three' 'four. . .');
   title: 'Arbitrary list'.
arbitraryList openWithSpec.

Which creates a simple list like follows:
https://steverstuff.s3.amazonaws.com/arbitrary_list.png

Is there any way to make a SpecPresenter object with an arbitrary list of
checkboxes? Kind of like a check-off list?

What is the best way of doing this? Should I put checkbox objects in the
"items:" selector? Or is there another way to do it?

Please forgive the naive question.


Re: [Pharo-users] Putting checkboxes in ListPresenter

2019-08-24 Thread Renaud de Villemeur
Hi Steve.

This is not at all a naive question. This is partly showned in the advance
part of spec, and as it said: "ListModel can show more than just text, it
can also visualize any kind of widget."

Here is how you could do a static list of checkBox:
 In your initializeWidget method, create your checkbox:

item1 := self newCheckBox label: 'label1'; help: 'help1'; yourself.
item2 := self newCheckBox label: 'label2; help: 'help2'; yourself.
item3 := self newCheckBox label: 'label3'; help: 'help3'; yourself.

You can then create and display your list:

projectList := (self instantiate: ListPresenter)
displayBlock: [ :x | x buildWithSpec ];
items: {item1 . item2 . item3};
yourself.


And your defaultSpec can be as simple as:

defaultSpec [
^ SpecLayout composed
add: #projectList;
yourself
]

Hope this helps.
Renaud


Le sam. 24 août 2019 à 14:53, Steve Quezadas  a écrit :

> Guys,
>
> I am learning this new "spec" thing. I created a simple Spec "list" object
> with the following code:
> arbitraryList := ListPresenter new.
> arbitraryList
>items: #('one' 'two' 'three' 'four. . .');
>title: 'Arbitrary list'.
> arbitraryList openWithSpec.
>
> Which creates a simple list like follows:
> https://steverstuff.s3.amazonaws.com/arbitrary_list.png
>
> Is there any way to make a SpecPresenter object with an arbitrary list of
> checkboxes? Kind of like a check-off list?
>
> What is the best way of doing this? Should I put checkbox objects in the
> "items:" selector? Or is there another way to do it?
>
> Please forgive the naive question.
>


Re: [Pharo-users] [ANN] Iterators

2019-08-24 Thread Richard O'Keefe
Distinguishing between "pull-based" and "push-based" streams in
Smalltalk makes no sense, because
   do: aBlock
  [self atEnd] whileFalse: [aBlock value: self next].
is in the same  protocol in the ANSI standard
as #atEnd and #next, and in most Smalltalk systems it is in
Stream.  There should never be anything that has #atEnd and
#next that doesn't have #do:.

In some Smalltalk systems, Stream and Collection both inherit
from a common superclass.  In GNU Smalltalk, it's called Iterable,
and provides, amongst other things
  stream1 , stream2
  stream allSatisfy: filterBlock
  stream anySatisfy: filterBlock
  stream collect: transformBlock
  stream count: filterBlock
  stream detect: filterBlock
  stream detect: filterBlock ifNone: exceptionBlock
  stream do: actionBlock
  stream do: actionBlock separatedBy: separatorBlock
  stream fold: combinerBlock
  stream inject: initial into: combinerBlock
  stream noneSatisfy: filterBlock
  stream reject: filterBlock
  stream select: filterBlock

My Smalltalk library does not do that, but it does have an
Enumerable class that's somewhat similar (the distinction is
that multiple traversal of a Collection must work, but only
single traversal of an Enumerable is required), so

  readStream asEnumerable reject: filterBlock

This makes about 257 Enumerable methods available.

Combinators are good, but they should fit in with existing
naming conventions.  *Arbitrary* overloadings are a bad idea.

The pipe "|" allows one to chain iterators
- The ">" allows one to create a new collection with data transformed
through chained iterators
- The ">>" allows one to fill an existing collection with data transformed
through chained iterators

The vertical bar is used in Smalltalk for "or".  It would make sense
to have
   MonadicBlock
 methods for: 'combinators'
   | other
 ^[:x | (self value: x) | (other value: x)]
and so on.  Smalltalk already has a selector that means "concatenation",
namely #, so
   stream1 , stream2
as in GNU Smalltalk would not be too confusing.

Similarly, ">" means "greater than", and it would be deeply confusing to
use it for some sort of data construction.  We would expect
stream1 > stream2
iff the future values of stream1 (as a sequence) are lexicographically
greater than the future values of stream2 (as a sequence).  Or you
could argue for "the relative order of two streams is the relative
order of their positions if the have the same underlying Collection or
file system object, otherwise undefined".


Re: [Pharo-users] Putting checkboxes in ListPresenter

2019-08-24 Thread Richard Sargent
Thank you, Renaud, for explaining that. I am so glad to see that Pharo has
addressed this and made it so simple. I've seen too many UIs that fail on
this kind of thing.

Kudos to those people who created this. You nailed it!


On Sat, Aug 24, 2019, 18:31 Renaud de Villemeur 
wrote:

> Hi Steve.
>
> This is not at all a naive question. This is partly showned in the advance
> part of spec, and as it said: "ListModel can show more than just text, it
> can also visualize any kind of widget."
>
> Here is how you could do a static list of checkBox:
>  In your initializeWidget method, create your checkbox:
>
> item1 := self newCheckBox label: 'label1'; help: 'help1'; yourself.
> item2 := self newCheckBox label: 'label2; help: 'help2'; yourself.
> item3 := self newCheckBox label: 'label3'; help: 'help3'; yourself.
>
> You can then create and display your list:
>
> projectList := (self instantiate: ListPresenter)
> displayBlock: [ :x | x buildWithSpec ];
> items: {item1 . item2 . item3};
> yourself.
>
>
> And your defaultSpec can be as simple as:
>
> defaultSpec [
> ^ SpecLayout composed
> add: #projectList;
> yourself
> ]
>
> Hope this helps.
> Renaud
>
>
> Le sam. 24 août 2019 à 14:53, Steve Quezadas  a
> écrit :
>
>> Guys,
>>
>> I am learning this new "spec" thing. I created a simple Spec "list"
>> object with the following code:
>> arbitraryList := ListPresenter new.
>> arbitraryList
>>items: #('one' 'two' 'three' 'four. . .');
>>title: 'Arbitrary list'.
>> arbitraryList openWithSpec.
>>
>> Which creates a simple list like follows:
>> https://steverstuff.s3.amazonaws.com/arbitrary_list.png
>>
>> Is there any way to make a SpecPresenter object with an arbitrary list of
>> checkboxes? Kind of like a check-off list?
>>
>> What is the best way of doing this? Should I put checkbox objects in the
>> "items:" selector? Or is there another way to do it?
>>
>> Please forgive the naive question.
>>
>