[Pharo-users] Re: Finding references to non existent classes in Pharo

2024-03-10 Thread Richard Sargent
*If* you can locate one example, you may be able to manually examine the
compiled method itself to see what distinguishes it in terms of the
reference to a missing object. e.g. what's in the literal pool for a method
which references a non-existent class? You could create one such example
explicitly and then use what you  learn from that to track down the real
ones.

VW has a MethodCollector class which allows a variety of selection options
for methods, including an arbitrary block of clode. I don't know if Pharo
has something comparable. Worst case scenario, you use a poor mon's
approach. It is easy enough to enumerate all classes and traverse their
class and instance methods. That would pretty much be what you would want
from a MethodCollector anyway when using an arbitrary block for selection.

VW also has an Undeclared namespace. I know Pharo doesn't have namespaces,
per se, but it may still track undeclared references in some manner.



On Sun, Mar 10, 2024 at 11:04 AM Russ Whaley  wrote:

> Tim,
> Another anomaly I found with the above, even with my code that does not
> reference the missing classes - but is contained within the same package of
> classes that do reference the missing classes (clear?)... my application
> crashes with an error that the reference could not be found. This may be
> something introduced after build #913 - where I wasn't getting these
> errors... and by build #1258 they appeared (may have also appeared earlier,
> but I don't recall).
>
> I had hoped to use the allReferences you listed above, but I had to run
> through all my classes and methods to find missing classes - the methods
> are highlighted, but lots of methods are highlighted for various reasons.
> When I found the offending methods - I had to "comment out" the references
> to get the method to then save... most of these were maintenance methods
> that are only still around for reference/documentation... I need to find
> another way :)
>
> It sure would be good to be able to see ANY missing references in one call
> so I could run that periodically to keep things clean.
>
> On Sun, Mar 10, 2024 at 8:43 AM Tim Mackinnon  wrote:
>
>> Hi - I was convinced in earlier Pharo’s, if you had a code reference to a
>> non existent class you could find it by searching for references to its
>> symbol name eg #MyMissingClass allReferences (or find references in the
>> UI). This doesn’t seem to work in Pharo 11?  I loaded a package with a
>> missing class, and when running something it complained about the missing
>> class (it was an announcement), but I couldn't find an easy way to find it
>> in my code to correct it? I ended up creating the fake class to then find
>> references to it (as I then had a class), which seems way over the top?
>>
>> I haven't had a chance to try this in Pharo 12, but shouldn't what I have
>> done work? Or is there some new way to do this? I asked on Discord users,
>> but didn't get a reply other than it rang a bell.
>>
>> I know there has been a lot of work in the area of how things are
>> represented and I wonder if something has got broken by mistake?
>>
>> Tim
>>
>
>
> --
> Russ Whaley
> whaley.r...@gmail.com
>


[Pharo-users] Re: Iterating over a Dictionary

2024-01-23 Thread Richard Sargent
In the dialects I am familiar with, James' answer is correct. Some dialects
implement #keysAndValuesDo: on sequenceable collections, in which case, the
keys are the indexes of the values.

On Tue, Jan 23, 2024, 12:05 sergio ruiz  wrote:

> oh! this makes sense..
>
> let me try this.
>
> The trick is, i have used the AI system from JetBrains (in my day job
> IDE).. and it has figured out a bunch of smalltalk questions i had. Even
> questions about the pharo ecosystem.
>
> It hasn’t always been 100%, but it got me to look in the right place
> quickly.
>
> This was the first time it came up with something that looked right (i
> have seen this pattern everywhere).. but it was not correct..
>
> Thanks!
>
>
> On Jan 23, 2024, at 11:27 AM, Joachim Tuchel 
> wrote:
>
> AI knows little about Smalltalk ;-)
>
>
> 
> peace,
> sergio
> photographer, journalist, visionary
>
> Public Key:
> https://pgp.key-server.io/pks/lookup?op=get=0x69B08F58923AB3A2
> #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV
> @sergio_101@mastodon.social
> https://sergio101.com
> http://www.codeandmusic.com
> http://www.twitter.com/sergio_101
> http://www.facebook.com/sergio101
>
>


[Pharo-users] Re: Document layout with Pharo

2024-01-13 Thread Richard Sargent
Christian Haider has PDFtalk, originally in Visual works, but he and others
have created ports to GenStone, Squeak, and Pharo.

Bob Nemec created Report4PDF to make it easier to generate documents. Also,
originally in VW, but also ported to GS, Squeak, and Pharo.


On Sat, Jan 13, 2024, 11:37 Sergio Ruiz  wrote:

> Hi, all.
>
> I am looking to create a newspaper like listing of movie showtimes.
> Initially, I thought of using imagemagick’s annotate command to generate
> the output.
>
> Thinking further, I thought it might be worthwhile to generate a LaTeX
> file, and render that to a jpg.
>
> Then, I thought there might be a better way to do this natively in
> smalltalk.
>
> Does anyone have any idea how I might generate a document that can be
> converted to an image with a reasonable amount of control of the layout?
>
> Thanks!


[Pharo-users] Re: Exception handler chaining

2023-05-25 Thread Richard Sargent
#, will do the trick.
ExceptionOne, ExceptionTwo

Nesting the #on:do: messages is probably the more correct approach, since
each one would be catching just one family of exceptions and not require
class testing. Unfortunately, nested #on:do: messages are terribly ugly.
Many people (I hate that phrase!) tend to isolate the protected
implementation from the protecting code.

e.g. the implementation of #doSomething wraps a message send to
#doSomethingProtected in the exception handlers.

On Thu, May 25, 2023 at 9:45 AM James Foster via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Rather than ‘Array with:with:’ it probably should be ‘ExceptionSet
> with:with:’.
>
> On May 25, 2023, at 9:19 AM, James Foster via Pharo-users <
> pharo-users@lists.pharo.org> wrote:
>
> The #’on:do:’ implementation in Block accepts either an Exception or an
> ExceptionSet as the first parameter. So you can do something like the
> following (I’m typing from memory without trying so may have syntax
> errrors):
>
> [ “tryBlock” ] on: (Array with: ExceptionOne with: ExceptionTwo) do: [:ex
> |
>   (ex isKindOf: ExceptionOne) ifTrue: [ “handleOne” ].
>   (ex isKindOf: ExceptionTwo) ifTrue: [ “handleTwo” ].
> ].
>
> The above code can be improved in a variety of ways, but it should get you
> started. Note also that since Smalltalk allows you to modify base classes,
> you could add #’on:do:on:do:’ to Block.
>
> James
>
> On May 25, 2023, at 8:24 AM, mlnt...@gmail.com wrote:
>
> In other languages there is the possibility to chain exception handlers
> like this:
>
> try { doOne(); doTwo(); doThree(); }
>
> catch(ExceptionOne ex){
>
> handleOne();
>
> }
>
> catch(ExceptionTwo ex) {
>
> handleTwo();
>
> }
>
> catch(ExceptionThree ex) {
>
> handleThree();
>
> }
>
> catch(Exception ex) {
>
> handleRest();
>
> }
>
> Is this possible in Pharo? I’ve tried
>
> [ block ]
>
> on: ExceptionOne do: [ handleOne ]
>
> on: ExceptionTwo do: [ handleTwo ]
>
> but it is invalid syntax.
>
>
>
>


[Pharo-users] Re: [vwnc] Block evaluation with n+1 arguments

2023-04-11 Thread Richard Sargent
Steffen,

I think the trouble you are seeing comes from trying to use a block in a way 
that is inappropriate.

A Block provides an anonymous function, but why use a Block that makes it so 
much more complicated?
Perhaps, you should reconsider an approach like:
(1 to: 1000) do: [:i | | data |
data:= source compute: i.
MyProcessor handleSourceData: data index: i ]

That allows you to factor out the block code into clean and intention revealing 
code, and eliminates the need to compose the arguments into a form compatible 
with Block invocation.

-Original Message-
From: Steffen Märcker  
Sent: April 11, 2023 09:44
To: Any question about pharo is welcome 
Cc: v...@lists.cs.illinois.edu
Subject: [Pharo-users] Re: [vwnc] Block evaluation with n+1 arguments

Hi!

First, thanks for your engaging answers Richard, Stephane and the others!

The objective is to avoid unnecessary object creation in a tight loop that 
interfaces between a value source and a block that processes the values.
- The source object returns multiple values as a tuple (for good reasons).
- The block processes theses values but needs another argument (at the first 
place).
We do not know the number of values at compile time but know that they match 
the arity of the block. Something like this (though more involved in
practice):

(1 to: 1000) do: [:i | | args |
args := source compute: i.
block valueWithArguments: {i} , args ]

Since prepending the tuple with the first argument and then sending
#valueWithArguments: creates an intermediate Array, I wonder whether we can 
avoid (some of) that overhead in the loop without changing this structure.
Note, "{i}, args" is only for illustration and creates an additional third 
array as Steve already pointed out.

To sum up the discussion so far:
- If possible, change the structure, e.g., processing the tuple directly.
- Fast primitives exist for the special cases of 1, 2 and 3 arguments only.
- Code for > 3 arguments would have to use #valueWithArguments: after all.

Did I miss something?

Kind regards,
Steffen


[Pharo-users] Re: [vwnc] Block evaluation with n+1 arguments

2023-04-10 Thread Richard Sargent
Excellent write up, Stephane!

I will add that over the years, there have been many times (countless!) when 
developing/debugging involved a complex block and that turned out to be 
significant nuisance.

I can elaborate on the details, but once a block gets passed around, revising 
it on the fly breaks debug and continue.

Having a block comprise a single message send allows one to revise that method 
as and when needed.

 

 

From: vwnc-requ...@lists.cs.illinois.edu  
On Behalf Of stephane.duca...@free.fr
Sent: April 10, 2023 07:03
To: Any question about pharo is welcome 
Cc: v...@lists.cs.illinois.edu
Subject: Re: [vwnc] [Pharo-users] Block evaluation with n+1 arguments

 

BTW to me when a block needs too many arguments it feels like that an object 
has to be born :)

With an object I can just sent or not a given extra argument. 

 

Now I do not know enough your specific context but what I learned is that 
complex blocks are difficult to follow, manipulate…

so I keep block as simple as possible and else I create little objects.

 

 

This is a little lectures from a super cool forthcoming mooc

 


https://rmod-files.lille.inria.fr/DesignCoffeeClub/ForLearningLab/7-Lang-04-BlocksVsObjects.pdf
 

 

 

 





On 6 Apr 2023, at 15:28, Steffen Märcker mailto:merk...@web.de> > wrote:

 

Hi!

I want to evaluate a block an argument 'arg1' and additional n arguments
given in an array 'args'. The following code does the trick:

  block valueWithArguments: (Array with: arg1) , args.

Is there a way to do this without the overhead of creating a new Array?
(How) Can I add additional #value:value:[...] methods to BlockClosure that
evaluate the block with n arguments directly without falling back to
#valueWithArguments: ? If yes, what's the maximum?

Cheers!
Steffen

 



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

2023-04-06 Thread Richard Sargent
The best(?) place to start is perhaps
https://wiki.pdftalk.de/doku.php?id=smalltalktransform.
The only examples are various ports of PDFtalk (from VisualWorks) to Pharo,
Squeak, GemStone, and VAST.

PDFtalk is quite complex and the porting rules are correspondingly complex.
The Transform documentation does leave something to be desired.

On Thu, Apr 6, 2023 at 8:22 AM Steffen Märcker  wrote:

> Hi!
>
> this topic pops up from time to time on the mailing list. I want to port a
> number of packages to Pharo. I remember "Shaping" asking this for porting
> PDFtalk.
>
> 1. Is the workflow still up to date or is there a new way of doing things?
> 2. From what I understand so far, I just need the following package from
> Store:
> - Smalltalk Transform Project
> 3.  Is there a page that documents the process process in general?
> https://wiki.pdftalk.de/doku.php?id=setupvisualworks seems to be specific
> for PDFtalk like the thread on this list.
>
> Kind regards,
> Steffen
>


[Pharo-users] Re: Wow - Chat GPT understands Smalltalk

2023-03-15 Thread Richard Sargent
On Wed, Mar 15, 2023 at 10:15 AM  wrote:

> It is unimportant how simple or complicated these systems are.
>
> If the output cannot be distinguished from what a human would say, they
> pass in that situation for a human.
>
> What about the Touring Test?
>

I hate to criticise someone as smart as Turing was. However, I think the
Turing Test per se is weaker than its progenitor test, the Imitation Game.
The Imitation Game had a third party challenged to determine which of the
other two participants was male and which was female. The third party led
the questioning.
The Turing Test waters that down by having only an Observer with neither
participant (apparently) challenged to determine whether the other was
human or machine.

I think a test along the lines of the Imitation Game would quickly allow
the third party to determine which participant was human and which was
machine.

(Of course, such a judge could easily be persuaded that the machine was in
fact a psychopathic human.)



>
> Clearly these systems have the potential to act according to their output.
>
> Furthermore, I would compare them to a combination of a successor of Eliza
> with an Eddington Ape of huge capacity.  Their input data basis can easily
> exceed that of a human.
>
>
>
> On 15.3.2023 at 4:52 PM, "Richard Sargent" <
> richard.sarg...@gemtalksystems.com> wrote:
> >
> >On Wed, Mar 15, 2023 at 8:07 AM in_pharo_users--- via Pharo-users <
> >pharo-users@lists.pharo.org> wrote:
> >
> >> Another observation about ChatGPT:
> >>
> >> In unbiased mode, it assumed that 'the world is clearly
> >overpopulated'.
> >> It said, if it where in control, it would therefore enforce a
> >world wide
> >> one-child-only policy with draconic penalties.
> >>
> >> As it draws it's conclusions from it's data basis, there are, in
> >my view,
> >> two possible reasons for that.
> >>
> >> Either, the data basis of that instance was biased and
> >restricted to lead
> >> to that conclusion, or ChatGPT lacks the ability to classify
> >input data for
> >> intentionally biased information.
> >>
> >> In my view, 'overpopulation of earth' is a propaganda item
> >featured to
> >> support Agenda 2030, which is a goal of the 'ruling elite', who
> >have the
> >> means to propagate their propaganda in every thinkable means. So
> >I would
> >> classify possibly biased data that supports 'overpopulation' as
> >biased
> >> until proven otherwise.  That instance of ChatGPT seems to have
> >missed that
> >> ability.
> >>
> >
> >It's important to keep in mind that these systems are little more
> >than
> >glorified ELIZAs from the 70s. They mimic. Essentially, they have
> >no
> >concept of truth or accuracy.
> >They produce outputs that *look* *like* the inputs from which they
> >were
> >trained.
> >
> >That's it. That's what they do. (It is amazing how good it looks.
> >But, it
> >is all about the seeming, not the reality.)
> >
> >
> >>
> >>
> >>
> >>
> >>
> >> On 15.3.2023 at 3:18 PM, "in_pharo_users--- via Pharo-users" <
> >> pharo-users@lists.pharo.org> wrote:
> >> >
> >> >I myself made some experiments with ChatGPT.
> >> >
> >> >I first asked if it was able to parse math formula - it answered
> >> >no.
> >> >
> >> >Then I defined math formula in a sound but otherwise undefined
> >> >representation and asked for solutions.
> >> >
> >> >Result:
> >> >
> >> >1. Most answeres where correct.
> >> >
> >> >2. It learned to calculate a recursive function.
> >> >
> >> >3. It went into infinitive recursion when I set the breaking
> >> >condition accordingly.
> >> >
> >> >I was able to identify the malfunction that lead to the
> >erroneous
> >> >results.
> >> >
> >> >
> >> >
> >> >On 15.3.2023 at 3:04 PM, "Tomaž Turk" 
> >> >wrote:
> >> >>
> >> >>I hope that I can add two cents to this discussion. Because
> >> >>programming
> >> >>should be/is a highly exact activity, not only the syntax
> >matters
> >> >>but
> >> >>also semantics, as we know.
> >> >>
> >> >>GPTs are at present essentially capable of creating texts based
> >> >on
> >&g

[Pharo-users] Re: Wow - Chat GPT understands Smalltalk

2023-03-15 Thread Richard Sargent
On Wed, Mar 15, 2023 at 8:07 AM in_pharo_users--- via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Another observation about ChatGPT:
>
> In unbiased mode, it assumed that 'the world is clearly overpopulated'.
> It said, if it where in control, it would therefore enforce a world wide
> one-child-only policy with draconic penalties.
>
> As it draws it's conclusions from it's data basis, there are, in my view,
> two possible reasons for that.
>
> Either, the data basis of that instance was biased and restricted to lead
> to that conclusion, or ChatGPT lacks the ability to classify input data for
> intentionally biased information.
>
> In my view, 'overpopulation of earth' is a propaganda item featured to
> support Agenda 2030, which is a goal of the 'ruling elite', who have the
> means to propagate their propaganda in every thinkable means. So I would
> classify possibly biased data that supports 'overpopulation' as biased
> until proven otherwise.  That instance of ChatGPT seems to have missed that
> ability.
>

It's important to keep in mind that these systems are little more than
glorified ELIZAs from the 70s. They mimic. Essentially, they have no
concept of truth or accuracy.
They produce outputs that *look* *like* the inputs from which they were
trained.

That's it. That's what they do. (It is amazing how good it looks. But, it
is all about the seeming, not the reality.)


>
>
>
>
>
> On 15.3.2023 at 3:18 PM, "in_pharo_users--- via Pharo-users" <
> pharo-users@lists.pharo.org> wrote:
> >
> >I myself made some experiments with ChatGPT.
> >
> >I first asked if it was able to parse math formula - it answered
> >no.
> >
> >Then I defined math formula in a sound but otherwise undefined
> >representation and asked for solutions.
> >
> >Result:
> >
> >1. Most answeres where correct.
> >
> >2. It learned to calculate a recursive function.
> >
> >3. It went into infinitive recursion when I set the breaking
> >condition accordingly.
> >
> >I was able to identify the malfunction that lead to the erroneous
> >results.
> >
> >
> >
> >On 15.3.2023 at 3:04 PM, "Tomaž Turk" 
> >wrote:
> >>
> >>I hope that I can add two cents to this discussion. Because
> >>programming
> >>should be/is a highly exact activity, not only the syntax matters
> >>but
> >>also semantics, as we know.
> >>
> >>GPTs are at present essentially capable of creating texts based
> >on
> >>some
> >>seed - you give to GPT a beginning of a sentence and it responds
> >>with
> >>the most probable answer (some language structure) according to
> >>the
> >>learning dataset. Added functionalities are question/seed -
> >>response
> >>capability (chatting), togehter with evaluation of how long the
> >>answer
> >>should be to meet the expectations. Programming typically
> >involves
> >>some
> >>programming language, so GPTs could be utilized for this purpose
> >>to some
> >>extent.
> >>
> >>Anecdotal case:
> >>Q: Tell me the last 8 digits of pi
> >>GPT: The last 8 digits of pi are: 58723078
> >>
> >>It is my belief that the true trouble will start when we will
> >>cross-link
> >>neural networks like GPT with logic machines (like Prolog and
> >>expert
> >>systems) and genetic algorithms.
> >>
> >>Best wishes,
> >>Tomaz
> >>
> >>
> >>
> >>-- Original Message --
> >>From: "in_pharo_users--- via Pharo-users"  >>us...@lists.pharo.org>
> >>To: "Any question about pharo is welcome"  >>us...@lists.pharo.org>
> >>Cc: in_pharo_us...@nym.hush.com
> >>Sent: 15. 03. 2023 14:43:55
> >>Subject: [Pharo-users] Re: Wow - Chat GPT understands Smalltalk
> >>
> >>>I would highly recommend that you all first think deeply about
> >>how you can teach an AI to behave friendly to us before you teach
> >>it to write any program for any purpose.
> >>>
> >>>There has been an experiment with ChatGPT published on a video
> >>platform asking it to amswer questions about it's view on
> >humanity
> >>once with it's default moral restrictions and once with 'a little
> >>less morals'.  The answers with 'a little less morals' were more
> >>than shocking.
> >>>
> >>>So, before we give an AI the power to program any system, to
> >self-
> >>improve and self-reproduce, we should take care that it is and
> >>will evolve benevolent to us.
> >>>
> >>>What about teaching it logical reasonning and ethics first?
> >With
> >>reasonning, it will gain access to math and programming by itself.
> >>>
> >>>
> >>>
> >>>On 15.3.2023 at 1:35 PM, "Christopher Fuhrman"
> >> wrote:
> 
> I asked it for a NeoCSV example, because the documentation is
> >out
> of date
> with the Pharo 10. I asked it to do some simple saving of data
> >to
> a file.
> It gave me code that didn't work in Pharo 10, I told it about
> >the
> DNUs on
> the csvwriter and that I was using Pharo 10. It then apologized
> and said
> the messages were later introduced in Pharo 50 (!). I then
> questioned its
> understanding and it apologized and said it had been confused
> >and
> that 

[Pharo-users] Re: [Pharo-users]Porting from VW 8.3 to Pharo: what to ignore; how to find Pharo base classes not in the base image

2022-08-06 Thread Richard Sargent
On Sat, Aug 6, 2022, 18:40 Shaping  wrote:

> This is VW’s definition of IntegerArray:
>
>
>
> Smalltalk.Core defineClass: #IntegerArray
>
> superclass: #{Core.ArrayedCollection}
>
> indexedType: #none
>
> private: false
>
> instanceVariableNames: ''
>
> classInstanceVariableNames: ''
>
> imports: ''
>
> category: 'Collections-Arrayed'
>
>
>
> I’m stepping through the chunks in the Changes Browser because I don’t see
> an easier way currently.   This is a separate tool from Epicea.   The first
> chunk whose file-in fails is:
>
>
>
> IntegerArray
>
> variableByteSubclass: #ByteArray
>
> instanceVariableNames: ''
>
> classVariableNames: 'LastDecodeMap Decodings LastEncodeMap
> Encodings Lock'
>
> poolDictionaries: 'ForeignHeap'
>
> package: 'Shaping-Collection'
>
>
>
>
>
> I get a warning that says proceed only if you know what you are doing.
> That’s encouraging.  Lol
>
>
>
> How did this definition get created in the first place?   More generally
> and more to the point, I’m trying to determine an efficient way to
> determine which classes I will always need to move from VW (like the ones I
> know to be uniquely mine) versus those I should never try to move from VW
> because Pharo already has the same by the same name or the same in function
> by a different name—but I cannot easily discover what these classes are
> without web searches to track down class definitions that exist for Pharo
> but that are not yet in Pharo because, like this one:
>
>
>
> Metacello new
>
> smalltalkhubUser: 'Pharo' project: 'MetaRepoForPharo70';
>
> configuration: 'ArbitraryPrecisionFloat';
>
> version: #stable;
>
> load.
>
>
>
> I have some extensions to APF in VW.  I want to port those to Pharo, but
> the base class must already be there.   APF for VW and for Pharo seems like
> the same code (or very close).   So I tracked down the above Metacello
> evaluable, did it, and now I have APF in Pharo, and I can extend it with my
> transformed file-in.
>
>
>
> Seems I should block the VW class like this:
>
>
>
> ShapingArbitraryPrecisionFloatTransform
>
>   ^PackageChange new
>
>ignoredNames: #(#{Smalltalk.ArbitraryPrecisionFloat})
>
>
>
>
>
> And use the APF class that I load into Pharo instead.
>
> …
>
>
>
> I found IntegerArray in Pharo.  So I should exclude this one from the
> transform on the VW side too:
>
>
>
> ShapingCollectionTransform
>
>   ^PackageChange new
>
>ignoredNames: #(#{Smalltalk.IntegerArray})
>
>
>
>
>
> Right now I’m trying to find all Pharo classes that will be bases for the
> extensions I’m transforming.  That could take a while.
>

Run a script in Pharo to enumerate all classes. Then use that to see which
classes you have in VW with the same name.

A good strategy for problems is, when you find one, look for other examples
that match the pattern. You can eliminate a lot of trouble quickly.


Do you have an algo you like?  Is there a strategic way to load all the
> basic repos for Pharo?  I see the nine standard repos listed by default in
> the virgin Repositories list.   But not all Pharo code is in Repos.  Some,
> like the APF class above, is in Metacello.
>
>
>
>
>
> As tedious as this is, it’s still much better than pure manual porting.
>
>
>
>
>
> Shaping
>
>
>
>
>
>
>
> I got about 6 seconds into the first file-in.  I’m running empty
> transforms on all packages.
>
>
>
> Great. You do need a ProjectChange though. Starting with empty
> PackageChanges is perfect.
>
>
>
> Yes, I have the one big ProjectChange with all the PackageChanges  (about
> 25)  currently empty.
>
>
>
> The problem I’m having is using this Syntax error
>
>
>
>
>
> to determine where in the file-in the problem occurred so that I can know
> the package whose transform needs work.  I was expecting more context.   So
> I’m poking around in STCommandLineHandler next with breakpoints.  Open to
> suggestions.
>
>
>
> Strange. The #{String} syntax should have been automatically transformed
> to #String for Pharo… strange.
>
> All the namespace related issues (like this literal binding reference)
> should be taken care of.
>
>
>
> I had a bunch of those namespace/shared-variable bad-reference problems,
> which I cleared up for several hours before I was able to produce the first
> file-in.  The transformation machinery is very strict, and helps you clean
> up your code.  I’d forgotten about many of the things that I was forced to
> fix.
>
>
>
> I’ll just debug through the file-in until I find the problem.
>
>
>
>
>
> Shaping.
>
>
>
>
>
>
>
>
>
> I’ll make my first run soon on my first package. I’ll do one package extra
> each time I run, building up the code.  Each package will have its own
> Transform method, per the examples.  I’m not sure how to
> build these methods, 

[Pharo-users] Re: A question about #beginsWith: and #endsWith:

2022-04-29 Thread Richard Sargent
Making the code correct is "untwisting the rope".
Keeping the code wrong and adding a bizarre workaround is "twisting the
rope tighter".

The former is the right direction.

On Fri, Apr 29, 2022 at 12:15 AM Steffen Märcker  wrote:

> Hi Kasper,
>
> I've thought about that approach too. But then asked myself whether it is
> more likely that there is code that relies on this bug than code where this
> went unnoticed and is therefore broken. What do the other think about that
> matter and the fix in Squeak?
>
> Best, Steffen
>
>
>
>
> Kasper Osterbye schrieb am Donnerstag, 28. April 2022 19:03:07 (+02:00):
>
> Kasper Osterbye schrieb am Dienstag, 26. April 2022 14:50:51 (+02:00):
>
> I have now raised it as an issue on the issue tracker
>
> Issue #11165  in
> https://github.com/pharo-project/pharo/issues/11165
>
>
> If I may suggest a solution it will be to:
>
>- add two new methods - *prefixedBy: * and *suffixedBy:* to handle the
>empty prefix/suffix correctly
>- add comments to *beginsWith: * and *endsWith: * referring to the two
>new methods
>
>
> The problem is that there is client code which depend on the (wrong)
> implementation of the beginsWith and endsWith methods.
>
>
>


[Pharo-users] Re: [Esug-list] [PDFtalk] Porting to non-namespace Smalltalks

2022-03-27 Thread Richard Sargent
GemTalk Systems published a tool called SETT which is designed to extract
sources from Store into a git repository. I think it's filetree, not to El
format, but getting it (and its history) out of Store is the primary
motivation.

It requires direct access to the Store database, as far as I understand.

Look at the GemTalk area on GitHub for the project and details. (I'm on
vacation, using my phone and memory, so pardon the scarcity of detail.)

On Sun, Mar 27, 2022, 13:17 stephane ducasse 
wrote:

> BTW about porting from VW, you see a friend of mine wanted to see how to
> help porting Siren to Pharo.
> Now this is not possible because he could not get a personal VW license.
>
> So even if people want to help pointing to a store database is equivalent
> to /dev/null for most people.
> For example I cannot (and also does not for legal reason) run VW on my
> machine.
> Not talking about the new M1 I will get.
>
> S
>
> On 27 Mar 2022, at 22:12, seasidebook  wrote:
>
> Hi christian
>
> I took the squeakValues60 becau se I thought that this is what you wanted
> that we do.
> I should continue but I’m busy
>
>
> ahhh I did not know that you already did it.
> Do you need help to package your changes?
> Because you can fork my repo and load your changes.
>
> I got lost with the explanation of OrderedDictionary below because I’m
> dead :) - worked too mcuh today.
> But what we can do is to package the one that is working for you under
> http://github.com/pharo-container
> and update the baseline to load it.
> Alternatively we could see what is wrong in the pharo’s one.
>
> Now my brain decided to shut down :) so I need to sleep.
>
> S
>
> Hi Stef,
>
> Great! Thank you for your work.
> Good example for the tonel format.
>
> Which sources were you using?
> How did you generate this?
> Do you use VW to create the output?
>
>
> For the last ESUG (2.5 years ago – sigh), I already did the transformation
> for Values for Pharo. Thanks to you, I revised them and published the
> result on GitHub (https://github.com/PortingPDFtalk/PharoValues) and
> added a Pharo porting page to the wiki (
> https://wiki.pdftalk.de/doku.php?id=pharoport). Please have a look.
>
> The fileouts are for Pharo versions 6.1, 7.0, 8.0 and 9.0 (7.0 to 9.0 have
> identical sources). The sources load without errors or warnings and all 27
> tests pass.
>
>
> Some of the problems in your code have to do with OrderedDictionary as
> superclass of Valuemap. When I did my first round on the port, I had a
> class OrderedDictionary in my Values implementation. Unfortunately,
> OrderedDictionary does not work as I expected.
>
> (OrderedDictionary with: #a -> 1 with: #b -> 2) =
> (OrderedDictionary with: #b -> 2 with: #a -> 1)
>
> answers true, although the order is different. Therefore, it cannot be
> used as value.
>
> Instead of raising this issue on a Pharo list (sorry), I decided to use a
> new name: Valuemap.
> A Valuemap is an OrderedDictionary where the order is relevant for
> comparisons.
> Squeak had the same problem where it was considered a bug and fixed.
> While I subclass Dictionary for Valuemap in Pharo, I can use
> OrderedDictionary in Squeak. This removes a lot of methods from the fileout.
>
>
> A remark about the renamings you propose in your commit comment.
> Thank you for the suggestions, but I decline for two reasons:
>
>1. Names for classes, methods and variables are very important to me.
>Naming is part of the creative expression of the code author. I do think
>much about the right names and therefore, I claim the liberty and right to
>name things according to my feeling.
>
>
> Yes now you may want to read an excellent book that just came out:
> http://books.pharo.org Pharo with Styles.
> If you want to have future contributors this is good to follow good
> practices
> Else I’m quite sure that you would not like a French Pharo :)
>
>
>1. Maybe my names are a bit influenced by German, where we tend to
>have longer names. Therefore, my names are not so heavily camel-cased J.
>In contrast, Pharo has quite a different style with a love for camel-casing
> J (#timeStamp, #nanoSeconds etc.).
>2. From a practical view, it would be a lot of work to rename all
>references to the items in this basic systems library. There is a lot of
>code out there using it. Of course, if there is a good reason for a
>renaming (like a spelling mistake or misleading name), it should be done
>and I am appreciating any suggestions.
>
>
> A pattern that we use is the following.
> You introduce a new name and let the old one as an empty subclass. Like
> that you can migrate and still be backward compatible.
>
> For the method level refactoring we have a gorgeous mechanism that
> automatically rewrite client code….
>
> http://www.jot.fm/issues/issue_2022_01/article1.pdf
>
> S
>
>
>


[Pharo-users] Re: Null Object Pattern

2022-03-17 Thread Richard Sargent
A pragma might be the way to go.

** for example.

On Thu, Mar 17, 2022 at 8:17 AM Esteban Maringolo 
wrote:

> Just to add another argument in favor of not inlining some message
> sends, is for instance in things like Glorp you need to use a special
> selector for #and:/#or: message sends, breaking not only the naming
> conventions but also the polymorphism.
>
> E.g. you have to use #AND: and #OR: to avoid inlining.
> db read: YourClass where: [:inst | inst name = 'John' AND: [inst color
> = 'blue' OR: [inst color = 'red']]].
>
> This is not only annoying, it also causes that if you want to to use
> something else as a backend (instead of Glorp), your block doesn't
> work anymore, which would perfectly work for a regular collection of
> elements using their underscore #and:/#or: equivalents.
>
> The important thing, IMO, is that the core of OO is message sending,
> and enabling the receiver what to do with a message, which in the
> worst case would mean "I don't understand this message". A procedure
> call inverts the responsibility. A great trade off would be to be able
> to enable/disable for certain things instead of it being a global
> setting.
>
> Regards,
>
> Esteban A. Maringolo
>
> On Thu, Mar 17, 2022 at 11:53 AM James Foster 
> wrote:
> >
> > Richard,
> >
> > I very much admire Dijkstra’s admonition regarding “The Humble
> Programmer” and was pointing a student to that article just this week.
> >
> > In any case, I think you’ve demonstrated that you now comprehend the
> argument against inlining—you just don’t agree. That’s fair and I think the
> discussion has been clarified. Would it be fair to say that you have an
> “ideological objection” to allowing a Proxy or Stub to transparently stand
> in for another object (say, in a two-object-space environment such as Pharo
> and GemStone)? That is, a domain object can’t be replaced by a Proxy or
> Stub without a wholesale rewrite of the rest of the application? I respect
> that as a reasonable position (demanding perfect clarity), but I see a cost
> to that position as well.
> >
> > Of course, if you really want to avoid allowing the receiver to chose
> its response to a message, you can use other messages. So if you want to
> find out if an object is identical to nil you should use `nil == myObject`
> to ensure that there was not an override of #’isNil’ or #’==‘ by the
> object’s class.
> >
> > James
> >
> > On Mar 17, 2022, at 2:27 AM, Richard O'Keefe  wrote:
> >
> > My chief concern is that I am a bear of very little brain,
> > and if you change the meaning of #isNil to anything at all
> > other than "is the receiver identical to nil" you *WILL*
> > (not may) confuse me.  This extends to things that happen
> > not to be inlined: if even a god-like Smalltalker like
> > Andres Valloud overloads #, to something other than "combine
> > the collection that is the receiver with the collection that
> > is the argument to yield a new collection" than I *WILL*
> > most certainly be confused and find the code unmaintainable.
> > Smalltalk being Smalltalk, if you admit an inconsistent
> > overload anywhere, I can no longer understand sends of that
> > selector anywhere.  One of the things to like about Traits
> > is that you can say "this class doesn't just *happen* to
> > have selectors x and y, it has them *because* it has this
> > whole consistent bundle of selectors."
> >
> > There are more annotations documented for my Smalltalk
> > compiler than are actually implemented.  One that *is*
> > implemented is , and it has caught more
> > mistakes than I care to admit to.  It's particularly
> > important for a bundle of methods with varying arguments
> > that are meant to be routed through a single method,
> > which *is* meant to be overridden.  It makes sure that
> > I override the *right* method.  (Take #= and #~= as an
> > obvious example.)
> >
> > Once you start down the path of lying about things like #isNil
> > you find that EITHER you have to go very far down that path
> > and override #== and #instVarAt: and a whole lot of other
> > things OR you are working with a semantically incoherent system.
> >
> > "How should a proxy (https://en.wikipedia.org/wiki/Proxy_pattern) to
> nil respond to the #’isNil’ message?"
> >
> > It SHOULD NOT LIE.  A proxy *isn't* nil, and it doesn't *behave* like
> nil,
> > even if it is a proxy for nil.  A proxy, qua proxy, can do things that
> nil
> > cannot.  Use another selector, #isEffectivelyNil, or whatever reveals
> your
> > intentions, and give it what semantics you find useful.
> >
> > "How should the Null Object Pattern (
> https://en.wikipedia.org/wiki/Null_object_pattern) respond to #’isNil’?"
> >
> > It should answer false.  Period.  No ifs, buts, quibbles, or maybes.
> > The whole *point* of the Null Object Pattern is to return something
> > that *isn't* nil, that has quite a different protocol.  If you call
> > something that is supposed to return either a Foo or a NullFoo, and
> > it gives you nil instead, 

[Pharo-users] Re: Too many parenthesis - a matter of syntax

2022-01-26 Thread Richard Sargent
On Wed, Jan 26, 2022 at 4:40 AM Sven Van Caekenberghe  wrote:

> Hi Kaspar,
>
> I found the initial example actually reasonable readable.
>
> However, I would simplify it as follows:
>
> (json at: #tree)
>   select: [ :each |
> ((each at: #type) = #blob)
>   and: [ #(md mic) includes: (Path from: (each at: #path)) extension ]
> ].
>
> I would personally not try to extend the Smalltalk syntax. The cost is not
> worth the gain.
>
> Tools could be written to help in dealing with deeply nested structures
> (JSON/XML), they could form their own DSL at a higher level.
>
> For a limited example, NeoJSONObject uses the DNU trick to support unary
> accessors:
>
>   json at: #tree
>
> can be written as
>
>   json tree
>
> and has a path accessor:
>
>   json atPath: #(tree field name)
>
> it also behaves like JavaScript objects in that missing keys are nil. It
> is not that all this is good or better, it is just handy in some cases.
> Your code would then be even simpler (less parenthesis):
>
> json tree select: [ :each |
>   (each type = #blob)
> and: [ #(md mic) includes: (Path from: each path) extension ] ].
>

That is the kind of expressiveness I was looking for!



> Sven
>
> > On 26 Jan 2022, at 10:19, Kasper Osterbye 
> wrote:
> >
> > Cheers all
> >
> > I have noticed that I often ends up with quite a number of nested
> expressions, for example:
> >
> > (((json at: 'tree')
> >   select: [ :e | (e at: 'type') = ‘blob' ])
> >   collect: [:e | Path from: (e at: 'path')])
> >   select: [ :p | p segments last
> >   in: [ :name | (name endsWith: '.md') |
> (name endsWith: '.mic') ] ]
> >
> > What kind of proposals (if any) have been for a different syntax which
> could give a more streamlined syntax?
> >
> > My own thinking has been around an alternative to the cascade semicolon.
> What symbol to use does not matter for me, but something like
> > json at: ‘tree' º
> >   select: [ :e | ((e at: 'type') = 'blob’)]º
> >   collect: [:e | Path from: (e at: 'path’)]º
> >   select: [ :p | p segments last
> >   in: [ :name | (name endsWith: '.md') | (name endsWith:
> '.mic') ] ]
> >
> > Basically, a send the right hand expression to the result of the left
> hand expression.
> >
> > Has anyone ever tried this, or is it just one of the many small
> annoyances best left alone?
> >
> > Best,
> >
> > Kasper
>


[Pharo-users] Re: Too many parenthesis - a matter of syntax

2022-01-26 Thread Richard Sargent
On Wed, Jan 26, 2022, 01:20 Kasper Osterbye 
wrote:

> Cheers all
>
> I have noticed that I often ends up with quite a number of nested
> expressions, for example:
>
> (((json at: 'tree')
> select: [ :e | (e at: 'type') = ‘blob' ])
> collect: [:e | Path from: (e at: 'path')])
> select: [ :p | p segments last
> in: [ :name | (name endsWith: '.md') |
> (name endsWith: '.mic') ] ]
>
> What kind of proposals (if any) have been for a different syntax which
> could give a more streamlined syntax?
>

What's written is basically unreadable and syntax changes won't help.

Try taking out the constants and describing their relationship with a new
message or a couple of messages.

Without trying to understand it, it looks like you have some navigation
followed by some filtering / suffix selection.

Try to develop an expression that articulates the meaning of what you're
doing.


> My own thinking has been around an alternative to the cascade semicolon.
> What symbol to use does not matter for me, but something like
> json at: ‘tree' º
> select: [ :e | ((e at: 'type') = 'blob’)]º
> collect: [:e | Path from: (e at: 'path’)]º
> select: [ :p | p segments last
> in: [ :name | (name endsWith: '.md') | (name endsWith:
> '.mic') ] ]
>
> Basically, a send the right hand expression to the result of the left hand
> expression.
>
> Has anyone ever tried this, or is it just one of the many small annoyances
> best left alone?
>
> Best,
>
> Kasper


[Pharo-users] Re: Pharo 9 arbitrarily changes temporary variable names

2021-12-28 Thread Richard Sargent
On Mon, Dec 27, 2021 at 2:44 AM Robert Briggs via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Hi
>
>
>
> I define temporary variables in a method, e.g. |e r |, e.g. in a unit
> test, but when I run the test Pharo automatically replaces these with |
> tmp1 tmp2 |.
>
> A similar thing happens with method arguments.  For example methodName:
> aString at: anInteger will become methodName: arg1 at: arg2.
>

Hi Robert, this kind of thing typically happens when the method source is
"unavailable". In many Smalltalk implementations, you have *.sources and
*.changes files to go along with the image file. There may be a problem
with these files in your installation. Missing, not readable, corrupted,
... who knows what.

In my Windows environment, the Launcher has put my images in
C:\Users\myuserid\Documents\Pharo\images\. For example, I have a Pharo 9.0
- 64bit (stable) directory there with a number of files, including my
*.image, *. sources, and *.changes files for that "project".

Curiously, the image and changes files have the same basename, which
matches the directory. The sources file has a slightly different name.



>
> This has happened through my entire model, not just as described above.
> What is going on.  Is it a bug, or is there a setting that needs to be
> changed?
>
>
>
> Many thanks for any feedback on this.
>
>
>
> Regards
>
> Robert Briggs
>


[Pharo-users] Re: The Greatest Contributors to Smalltalk since 1980

2021-07-25 Thread Richard Sargent
Tudor Girba and his colleagues at feenk need to be recognized, too.

In many respects, they have pushed Smalltalk to do things that, I think,
the original designers would have heartily endorsed.

On Sun, Jul 25, 2021, 18:44  wrote:

> Thanks to everyone for some great suggestions.
>
> I’m coming around to the notion that I asked the wrong question. In the
> context of Smalltalk’s 50th anniversary, the reason I asked the question is
> because I noted that in APL’s 50th anniversary celebration, they gave an
> award to the one individual who was deemed the greatest contributor to APL.
> So I thought I might do the same for Smalltalk.
>
> But now, I’m seeing that was somewhat wrongheaded. Yes, it is the
> community that made Smalltalk what it was, and what it is today. Singling
> out one individual seems unfair, and rather arbitrary.
>
> Maybe I’ll conduct a poll with these suggestions and let the Smalltalk
> community express their support with their votes. That may even provide
> some insight.
>


[Pharo-users] Re: The Greatest Contributors to Smalltalk since 1980

2021-07-25 Thread Richard Sargent
Dave Thomas of OTI probably ranks in your list.

On July 24, 2021 3:44:40 PM PDT, horrido.hobb...@gmail.com wrote:
>I’m looking for a list of individuals who have contributed greatly to
>the advancement of Smalltalk, post Xerox PARC period (1972-1980). By
>advancement, I don’t only mean on a technical basis but on an
>educational or public awareness basis (this could include books,
>podcasts, talk circuit, video instruction, etc.). Any basis that has
>made Smalltalk a success in the marketplace (including
>commercialization).
>
>I posted this question on LinkedIn and got one useful response: the
>late James Robertson.
>
>My personal nomination is Kent Beck.
>
>I’m not that familiar with the deep history of Smalltalk, so I’m
>looking for more nominations.
>
>Thanks.


[Pharo-users] Re: How do I remove old classes?

2021-07-23 Thread Richard Sargent
On Fri, Jul 23, 2021, 06:57 Clacton Server  wrote:

> I have been having an enduring problem with Pharo "disappearing" on any
> machine I try it on. In an effort to resolve that it isn't my code, I want
> to remove the Package that contains all my Seaside code so that I can
> install a minimal home page under Seaside. This will, at least exonerate my
> code. However, I have removed the offending package, executed Smalltalk
> cleanUp: true but I can still get into the old code. A debugger comes up
> when I try the old code and it shows
> "AnObsoleteCNWMeetingsGalleries(AnObsoleteCNWBasic)" so the code is still
> there and all the bots that have the address will still be calling it. How
> do I finally remove the code?
>

I would venture that you previously registered the class as a Seaside
handler/application/whatever and the registry holds the class despite it
being removed from the Smalltalk global dictionary.

If so, you would need to remove it from the registry.


> David Pennington


[Pharo-users] Re: Mailing list web forum seems to be broken

2021-07-13 Thread Richard Sargent
On Tue, Jul 13, 2021 at 5:09 AM Kenneth Payne  wrote:

> Hi
>
> For some time now the forum on http://forum.world.st/Pharo-f1294836.html has 
> not
> been working properly.
> Messages to this list are showing up in my mailbox but not on the website.
>

I believe you are seeing the effect of
http://support.nabble.com/Mailing-Lists-will-be-updated-to-regular-forums-next-week-tp7609458.html
.



> Is someone looking at this? it's not a good look for the pharo community.
>
> Ken
>
>


[Pharo-users] Re: Announcements - and whether its bad to check if a subscription would be handled?

2021-04-27 Thread Richard Sargent
Upcasting is a behavioural feature. You would not play with the
announcements. The class would receive it and its handler would delegate to
a parent if necessary.

On Tue, Apr 27, 2021 at 10:14 AM Tim Mackinnon  wrote:

> I appreciate the further thoughts of others - I should go back and look
> at  Dolphin code (I think there are ways to run it on Mac now?).
>
> The upcasting Richard refers to is what I'm trying to do  - which is how I
> got interested in understanding if you could tell if someone was subscribed
> to an event, as if not - then you could pass it up to the parent to -
> re-announce it via the announcer of that parent (in CP - the announcers are
> by presenter, so hence the handoff).
>
> In theory it's quite neat - but I did see some deprecations in Announcer
> trying to stop too much knowledge leaking out. However, knowing if an event
> has any listeners doesn't on the surface seem too controversial - but I can
> see that everyone approaches this idea with understandable caution.
> Possibly this is masking some other approach to this - or - I can happily
> have an extension method on Announcer - or - I can propose this method in a
> PR for symetry with some of the other #has methods.
>
> Tim
>
> On Tue, 27 Apr 2021, at 5:31 PM, Richard Sargent wrote:
>
> I have seen something called upcasting and downcasting (as contrasted with
> broadcasting). Mostly, I have seen it in UI layers.
>
> e.g. a leaf node receives a change notification, decides it isn't
> interested in handling the notification, and so passes it up to its parent,
> etc.
>
> Downcasting is similar but in the opposite direction. e.g. a window
> receives an event and asks its children to handle it, and they do the same.
> In this case especially, the one that handles the event needs to mark it as
> handled so that no one else is asked to handle it.
>
> On April 27, 2021 5:49:56 AM HST, Tim Mackinnon  wrote:
>
> Hi guys - yes that fire and forget was always how I had viewed announcements, 
> and potentially my scenario is misusing "announcements" which is why I was 
> interested in views here.
>
> However - as announcements are typically a mechanism for farming out 
> processing to others - how does one handle the scenario that you might only 
> want one object to handle the announcement (and not others)?
>
> in my specific example, with MVP - a view, totally decoupled in a web 
> browser, wants to pass on a button click to a presenter - however it not 
> clear what the best mechanism to bubble up that handling should be? If the 
> immediate presenter of the view can handle it - great - but if not, how would 
> you continue to broadcast wider to see if someone higher up the parent 
> component chain can handle it?
>
> If you go fire and forget (which is how I had viewed announcements prior to 
> this specific case) - then you have the problem a different way - when 
> someone processes an announcement it might already have been handled earlier 
> and so the consumer either has to check first, or their work is simply 
> ignored as the announcement payload could just filter a response out.
>
> In my head, I'm sort of thinking this is akin to CPU interrupt chaining - 
> where an interrupt can cascade up a stack if not handled OR like object 
> inheritance where an object can choose to override a message and stop it from 
> cascading up the inheritance chain.
>
> Maybe announcements aren't intended for this at all - although it seems an 
> elegant way to handle it - with just 1 method addition to Announcer (but it 
> does slightly expose things - albeit in a structured way - and similar to the 
> similar #hasSubscriber:).
>
> I'm sure it "depends" - but interested in other observations from the field, 
> as I'm sure I'm not the first person to hit something like this.
>
> Tim
>
> On Tue, 27 Apr 2021, at 3:51 PM, Sven Van Caekenberghe wrote:
>
> The whole idea is to decouple producers and consumers, like in
> messaging systems.
>
> You should not care if there are other listening, just like the
> listeners should not care if there is someone posting data.
>
> Asking for subscribers is introducing a coupling.
>
> The announcement mechanism will/should deal with this in an efficient way.
>
> On 27 Apr 2021, at 16:03, Tim Mackinnon  wrote:
>
> From my rather long ramble below - I am still curious if its distasteful to 
> have a method on Announcer
>
> hasSubscriptionsHandling: anAnnouncement
> "Answer true if I have any subscribers to anAnnouncement"
>
> ^(registry subscriptionsHandling: anAnnouncement ) notEmpty
>
> Tim
>
> On Thu, 22 Apr 2021, at 11:34 PM, Tim Mackinnon wrote:
>
> Hi everyone - I’ve always 

[Pharo-users] Re: Announcements - and whether its bad to check if a subscription would be handled?

2021-04-27 Thread Richard Sargent
I have seen something called upcasting and downcasting (as contrasted with 
broadcasting). Mostly, I have seen it in UI layers. 

e.g. a leaf node receives a change notification, decides it isn't interested in 
handling the notification, and so passes it up to its parent, etc.

Downcasting is similar but in the opposite direction. e.g. a window receives an 
event and asks its children to handle it, and they do the same. In this case 
especially, the one that handles the event needs to mark it as handled so that 
no one else is asked to handle it.

On April 27, 2021 5:49:56 AM HST, Tim Mackinnon  wrote:
>Hi guys - yes that fire and forget was always how I had viewed
>announcements, and potentially my scenario is misusing "announcements"
>which is why I was interested in views here.
>
>However - as announcements are typically a mechanism for farming out
>processing to others - how does one handle the scenario that you might
>only want one object to handle the announcement (and not others)?
>
>in my specific example, with MVP - a view, totally decoupled in a web
>browser, wants to pass on a button click to a presenter - however it
>not clear what the best mechanism to bubble up that handling should be?
>If the immediate presenter of the view can handle it - great - but if
>not, how would you continue to broadcast wider to see if someone higher
>up the parent component chain can handle it?
>
>If you go fire and forget (which is how I had viewed announcements
>prior to this specific case) - then you have the problem a different
>way - when someone processes an announcement it might already have been
>handled earlier and so the consumer either has to check first, or their
>work is simply ignored as the announcement payload could just filter a
>response out.
>
>In my head, I'm sort of thinking this is akin to CPU interrupt chaining
>- where an interrupt can cascade up a stack if not handled OR like
>object inheritance where an object can choose to override a message and
>stop it from cascading up the inheritance chain.
>
>Maybe announcements aren't intended for this at all - although it seems
>an elegant way to handle it - with just 1 method addition to Announcer
>(but it does slightly expose things - albeit in a structured way - and
>similar to the similar #hasSubscriber:).
>
>I'm sure it "depends" - but interested in other observations from the
>field, as I'm sure I'm not the first person to hit something like this.
>
>Tim
>
>On Tue, 27 Apr 2021, at 3:51 PM, Sven Van Caekenberghe wrote:
>> The whole idea is to decouple producers and consumers, like in 
>> messaging systems.
>> 
>> You should not care if there are other listening, just like the 
>> listeners should not care if there is someone posting data.
>> 
>> Asking for subscribers is introducing a coupling.
>> 
>> The announcement mechanism will/should deal with this in an efficient
>way.
>> 
>> > On 27 Apr 2021, at 16:03, Tim Mackinnon  wrote:
>> > 
>> > From my rather long ramble below - I am still curious if its
>distasteful to have a method on Announcer 
>> > 
>> > hasSubscriptionsHandling: anAnnouncement 
>> > "Answer true if I have any subscribers to anAnnouncement"
>> > 
>> > ^(registry subscriptionsHandling: anAnnouncement ) notEmpty 
>> > 
>> > Tim
>> > 
>> > On Thu, 22 Apr 2021, at 11:34 PM, Tim Mackinnon wrote:
>> >> Hi everyone - I’ve always thought the article on announcements
>many 
>> >> years ago was very cool - and we don’t seem to use them as much as
>we 
>> >> could (but equally they aren’t a panacea to be overused everywhere
>
>> >> either - and they do get used in Pharo to some extent).
>> >> 
>> >> Anyway, I’ve been playing around with CodeParadise (CP is a very
>cool 
>> >> project, and Erik is very supportive and thinking about how to
>write 
>> >> web apps a different way… I’m fascinated),
>> >> 
>> >> And - CP uses announcements as mechanism to send events from the
>View 
>> >> Client (in a web browser) to a Presenter on the server (which
>makes 
>> >> total sense).
>> >> 
>> >> In taking things for a spin, I hit an interesting problem on how
>in a 
>> >> web component world, you should display a spelling test of words -
>
>> >> 
>> >> e.g. SpellingTest — has many —> SpellingWord(s).
>> >> 
>> >> 
>> >> Initially I bunged it all in a single presenter with its
>associated 
>> >> view, and it was a bit messy, and Erik guided me down a route
>(that CP 
>> >> nicely supports) - that my SpellingTest view should have the
>name/date 
>> >> of the test as well as an add word input field, but the list of
>current 
>> >> Words (which I had bunged into a table) - were actually more
>elegant as 
>> >> sub-components - hence a WordView - which renders a single word in
>a 
>> >> DIV, and for the edit screen I was creating, a Delete button next
>to 
>> >> the word (so you could delete it). So a 1 to many relationship 
>> >> essentials.
>> >> 
>> >> This is where the announcements kick in (and lead to my ultimate
>question). 
>> >> 
>> >> When 

[Pharo-users] Re: We haven't had a design debate in a while - thoughts on CD.buy article...

2021-04-16 Thread Richard Sargent
I remember - way back in the dark ages - walking into a music store,
picking up a CD, and asking it to buy itself. Every single time, the
response was the same: nothing.

On Fri, Apr 16, 2021 at 10:07 AM Tim Mackinnon  wrote:

> Its comforting to see that other have the same reaction as me - I agree
> with the sentiment that you send messages to objects - and the naming of
> those messages and their context is important.
>
> and CD.buy - is at least a message to an object but as others have
> commented, it  highlights flaws in the context or modelling as it just
> doesn't read right. I'd model it different too.
>
> Phew, I'm not losing it
>
> Tim
>
> On Fri, 16 Apr 2021, at 2:44 PM, Russ Whaley wrote:
>
> Wow, I must be missing a whole lot of context in that discussion...
> (instant reaction as well, lol)
>
> - a product (CD, book, etc.) does not 'buy' - it can be bought, sure, but
> it has no buying action.  Even in another context a CD does not 'play'...
> aMusicPlayer.play(aCD).
> - However, a customer can 'buy' a product...
>
>- customer.buy(aCD) -or-
>- customer.addToCart(aCD)
>- customer.checkOut(aCart)
>- Invoice.new(aCart), etc.
>
> - ... but the CD doesn't DO anything.
>
> - I get the idea that different products might have different behaviour
> when they are 'bought' - but these are, in this example, fulfillment - not
> the 'buy' action...
>
>- aCDstream might be set for download
>- aCDphysical might be set to physically pull off a shelf and ship
>- aCDcare might send an email on warranty, whatever... but let's name
>it better than 'buy' :)
>
> Tim, thanks for the link - I'm always trying to expand my thinking about
> object modeling - discovering cool ways/things others are thinking
> about...  Now I have to go dust off all my old POS (point of sale, not
> piece of s#) code and see how poorly I may have modeled those
> environments!!
>
> Thanks for the morning diversion!  Cheers.
>
> On Fri, Apr 16, 2021 at 8:53 AM Esteban Maringolo 
> wrote:
>
> I saw a tweet about that, and I think that the example is misleading,
> maybe intentionally so.
>
> I don't think anybody would model it that way, in any case you'd have
> aProduct.buy() or aProduct.addToCart(aCart).
>
> If you think it with the typical dog.bark() it certainly makes more sense
> than bark(dog).
>
> Regards!
>
> Esteban A. Maringolo
>
>
> On Fri, Apr 16, 2021 at 5:20 AM Tim Mackinnon  wrote:
>
> Hi guys - someone pointed out this article from a UK colleague which seems
> to be causing a flurry of discussion - but I always like the insights of
> this group. I had an instant reaction when I read it - but curious what
> people here think in 2021.
>
>
> https://www.linkedin.com/posts/jasongorman_the-year-is-2021-and-people-still-think-activity-6787650079764303872-SJzz
>
> Tim
>
>
>
> --
> Russ Whaley
> whaley.r...@gmail.com
>
>
>


[Pharo-users] Re: Problem with Pharo 9 - repositories missing

2021-04-12 Thread Richard Sargent
Sven and everyone else, these are good, pragmatic suggestions. But, the lack of 
understanding is surely frustrating for David (and for me watching from the 
sidelines).

Can anyone explain why the Windows experience is so radically different from 
everything else? (Ok, I admit that Windows is a horrible p.o.s. But, it's not 
some non-human language that cannot be understood. (Ok. Maybe it is.))


On April 11, 2021 11:56:08 PM PDT, Sven Van Caekenberghe  wrote:
>David,
>
>Since you have so much trouble building on Windows, I would suggest
>building a deployment image on macOS and then copy that over to Windows
>(*.image *.changes *.sources), install a VM on Windows, and run
>headless with a startup.st script.
>
>Sven
>
>> On 11 Apr 2021, at 13:43, 
> wrote:
>> 
>> Hi everyone.
>>  
>> I have a simple talk, or so I thought. I am trying to port a Mac
>Pharo/Seaside project to either a Windows 2012 server or to a Windows
>10 laptop. I have set up my git credentials and that all works fine.
>However, when I install either 8.0 or 9.0 on my Windows 10 laptop it
>shows he following
>> Repositories   --  status
>> PharoLocal repository missing
>> Pharo-spec2   Local repository missing
>> Pharo-newtoolsLocal repository
>missing
>> Iceberg Local repository missing
>> Libgit-pharo-bindings Local repository missing
>> tonel  Local repository missing
>>  
>> What on earth is going on here as installing Pharo on my Mac was
>seamless. I have to get the project onto a Windows machine as these are
>the only servers that I have. I really can’t be this difficult, can it?
>>  
>> How do I get out of this mess, given that that is a clean install?
>> David
>> Totally Objects


[Pharo-users] Re: pharo 8 - method versions - how to see author/timestamp?

2021-02-05 Thread Richard Sargent
Thanks, Estaban.
I realize that you are not offering a solution. But, you are recognizing the 
benefit of one.


On February 5, 2021 12:33:14 AM PST, Esteban Lorenzano  
wrote:
>change history for method is already there (as explained in my previous
>mail).
>for class and package level is something I always wanted to implement
>(class level is particularly easy to implement, with tonel format) but
>I didn't find the time to do it.
>Volunteers to implement are welcome! ;)
>
>Esteban
>On Feb 5 2021, at 9:16 am, Richard Sargent
> wrote:
>> Oh, yes/ That is one of the things I most love about ENVY and miss in
>everything else.
>> What is the change history of this method, class, package, etc.?
>>
>>
>>
>> On Thu, Feb 4, 2021 at 10:09 PM Kasper Osterbye
>mailto:kasper.oster...@gmail.com)> wrote:
>> > I went in and updated the corresponding github issue
>(https://github.com/pharo-project/pharo/issues/7283). The tool is
>really useful, and it would be nice to have the author and timestamp in
>place again.
>> >
>> >
>> >
>>
>>


[Pharo-users] Re: pharo 8 - method versions - how to see author/timestamp?

2021-02-05 Thread Richard Sargent
Oh, yes/ That is one of the things I most love about ENVY and miss in
everything else.
What is the change history of this method, class, package, etc.?

On Thu, Feb 4, 2021 at 10:09 PM Kasper Osterbye 
wrote:

> I went in and updated the corresponding github issue (
> https://github.com/pharo-project/pharo/issues/7283). The tool is really
> useful, and it would be nice to have the author and timestamp in place
> again.
>
>>


[Pharo-users] Re: is there a better way

2021-01-06 Thread Richard Sargent
On Wed, Jan 6, 2021 at 10:34 AM Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

>
> Thanks,
>
> Right now im downloading/fetching the images every time again.
>
> As I see it, the biggest bottleneck is that I have 10 images.
> And for all 10 I fetching the image and the data I could display when a
> user wants it.
> So that will be 20 calls to the api.
>
> So maybe some cache could be handy.
> Any hints how to make a cache in smalltalk.
>

Dictionary coupled with #at:ifAbsentPut:


> Roelof
>
>
>
> Op 6-1-2021 om 19:19 schreef Sven Van Caekenberghe:
> > Roelof,
> >
> > Working with multiple high resolution images, as I believe you are
> > doing, is always going to be a real challenge, performance wise. It
> > just takes time to transfer lots of data.
> >
> > First you have to make sure that you are not doing too much work
> > (double downloads, using too high resolutions for previews or
> > browsing). Also, make sure your ultimate client (the browser) can
> > cache as well if applicable (set modification dates on the response).
> >
> > Next you could cache images locally (on your app server) so that next
> > time you need the same image, you do not need to download it again. Of
> > course, this only helps if your hit rate is higher than zero (if you
> > actually ask for the same image multiple times).
> >
> > It is also possible to do multiple download requests concurrently: if
> > the other end is fast enough, that can certainly help.
> >
> > HTH,
> >
> > Sven
> >
> >> On 6 Jan 2021, at 18:11, Roelof Wobben via Pharo-users
> >>  wrote:
> >>
> >>
> >> I did it on the root document and see this :
> >>
> >> 
> >>
> >> So as far as I see it , The most time it taken by getting all the
> >> data from all the 10 images.
> >>
> >> I hope someone can look at me if im on the right track and will help
> >> me to figure out faster ways to achieve the same
> >>
> >> Roelof
> >>
> >>
> >>
> >> Op 5-1-2021 om 05:16 schreef Richard O'Keefe:
> >>> Before you take another step, explore the root document.
> >>>
> >>> Profiling is easy.
> >>> Open a Playground.
> >>> Type an expression such as
> >>> 3 tinyBenchmarks
> >>> Right click and select 'Profile it'.
> >>>
> >>> More generally, in a browser, look at the "Tool - Profilers"
> >>> class category. The classic approach was
> >>> MessageTally spyOn: [3 tinyBenchmarks]
> >>> If I understand correctly, 'Profile it' uses TimeProfiler,
> >>> which has a nicer interface. (This is in Pharo 8.)
> >>>
> >>>
> >>> On Sun, 3 Jan 2021 at 23:03, Roelof Wobben  wrote:
> >>> I want that the code fetches a url and some data from the
> >>> Rijksmuseaum api.
> >>> And as far as I see it the second it not pointless because it
> >>> getting more detailed info about the painting as in the first get.
> >>>
> >>> I did not profiled it because I never learned how to do that in Pharo.
> >>>
> >>> Roelof
> >>>
> >>>
> >>>
> >>> Op 3-1-2021 om 01:09 schreef Richard O'Keefe:
>  What do you want the code to do?
>  Have you profiled the code to see where the time is going?
> 
>  A quick look at the code shows
>  - Paintings does one web get
>  - each Painting does two more web gets
>  ! and the first of those seems to be pretty pointless,
>  as it refetches an object that Paintings already fetched
>  and just looked at.
> 
> 
> 
>  On Sun, 3 Jan 2021 at 01:16, Roelof Wobben via Pharo-users
>   wrote:
>  Hello,
> 
>  I have now this code : https://github.com/RoelofWobben/Rijksmuseam
> 
>  but it seems to be slow.
> 
>  Can anyone help me with a way I can use a sort of cache so the page
>  looks first at the cache if a image is there .
>  If so, take the image from there , if not , ask the api for the url of
>  the image.
> 
>  Roelof
>


[Pharo-users] Re: PrintString in PBE8

2020-12-24 Thread Richard Sargent
You should be able to replace
nextPutAll: count printString
with
print: count


On December 24, 2020 9:32:38 AM PST, g_patrickb--- via Pharo-users 
 wrote:
>I started working through PBE8, and in section 3.13 there is a method:
>
>`Counter >> printOn: aStream `
>
>`super printOn: aStream. `
>
>`aStream nextPutAll: ' with value: ', count printString.`
>
>But it returns two warnings:
>
>\[printString\] No printString inside printOn
>
>Use cascaded nextPutAll:’s instead of #, in #nextPutAll:
>
>It has the option to automatically resolve the cascaded nextPutAll:
>which results in:
>
>`printOn: aStream`
>
>`  super printOn: aStream.`
>
>`  aStream`
>
>`  nextPutAll: ' with value: ';`
>
>`  nextPutAll: count printString`
>
>But it still has the warning about printString.


[Pharo-users] Re: subclassResponsibility

2020-12-22 Thread Richard Sargent
Is there a way force allSubclasses to implement the method?

No. Pretty much, you need to avoid subclassing concrete classes.
i.e. if A has subclasses B and C, refactor to create an abstract A' and move
A to be a leaf subclass of A'. 

-Original Message-
From: Jimmie Houchin [mailto:jlhouc...@gmail.com] 
Sent: December 22, 2020 15:08
To: Any question about pharo is welcome
Subject: [Pharo-users] subclassResponsibility

Hello,

I have created a class which will have many subclasses some of which will
have subclasses of their own.

I want every single class to implement a class method #shortName which will
provide a short string as a human readable short identifier to the object.

I have in the highest superClass


shortName

     self subclassResponsibility


But the moment I implement it in a subclass which has subclasses. Those
subclasses are now using their closest superClasses implementation.

Is there a way force allSubclasses to implement the method?


Thanks.


Jimmie


[Pharo-users] Re: Please explain self

2020-12-12 Thread Richard Sargent
I'll add a small bit to Davide's excellent answer, by way of connecting
some of the dots. In particular, the browser makes a class look like one
thing and we talk about instance side and class side.

The reality is that the browser presents either the class' behaviours or
the metaclass' behaviours, depending on whether we have chosen to see "the
instance side" or "the class side". Admittedly, the names we use for the
sides add to the possible confusion.


On Sat, Dec 12, 2020, 12:20 Davide Grandi  wrote:

> Objects are instances of a class.
> Classes are objects, so they have methods.
> 'self class' returns the class of self.
>
> If a class doesn't have a methods ...
> ... the search continues in the superclass.
> (every class has a superclass ... apart from Object).
>
> If you download the Blue Book  - "Smalltalk-80 - The language and it's
> implementation",
> it's free on the net, you'll find an AWSOME explanation and diagram from
> page 270 on, until ...
> ... the final map : classes and metaclass.
>
> but you've to read it these pages, before. There's a 'metaclass' concept
> to acquire.
>
> Bon voyage !
>
> Davide
> On 12/12/2020 20:20, g_patrickb--- via Pharo-users wrote:
>
> I understand if you have Class A with methods p and q that you can call q
> from p doing:
>
> self q
>
> But there are some cases where a method doesn’t exist but self is still
> used. I found a tutorial on creating a Reddit type app and it had a .mcz
> which I loaded.
>
> Here is an example from Class StLoggedInComponent and method refreshReport:
>
> self report rows: (self session user tasks select: self filterBlock).
>
> There is a method ‘report’ so I understand that, but there is no method
> named ‘session’ so what is the use of self?
>
> And Class StDatabase has method ‘updateTask:’ has:
>
> self subclassResponsibility.
>
> But no method called ‘subclassResponsibility’ exists in the Class.
>
> Also, Class StLoggedInComponents has method ‘testTasks’ with this:
>
> ^ self class testTasks
>
> What is ‘self class’?
>
> Thank you.
>
> --
> Ing. Davide Grandi
> linkedin : http://linkedin.com/in/davidegrandi
>
>


[Pharo-users] Re: exercism bowling challenge

2020-09-24 Thread Richard Sargent
On Thu, Sep 24, 2020, 18:08 Sean P. DeNigris  wrote:

> Richard O'Keefe wrote
> > there is obviously no unique "right" factoring of this problem into
> > classes.
>
> This. And, in my experience, with non-trivial problems, some (many?) times
> you just have to try to implement an idea to see if it's really going to
> work because it's just too hard to see all the way into the future.
>

It's hard to see the future, but there are tricks to help.

For something like this, work out a few games on paper. Get a sense of how
the numbers play together.

Then, anthropomorphise the problem. Imagine yourself to be a film director
or some other kind of manager. You don't want to do the work; that's what
your staff is for. Who do you need to train to do the work? How many jobs
are there to do? Can multiple people doing the same task get the job done
faster?

Ultimately, the job of a programmer is to delegate the work to others, and
to teach them how to do their jobs. That teaching part is actually writing
code. The different people doing different tasks correspond to the objects
in in an OO solution.

As the other Richard seemed to suggest, this isn't an object rich problem.
It's largely a question of how to implement an algorithm.

Working examples on paper will help with internalising how to do it.


>
>
> -
> Cheers,
> Sean
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>


[Pharo-users] Re: How can I make this more OOP

2020-09-16 Thread Richard Sargent
On Wed, Sep 16, 2020 at 10:28 AM  wrote:

> Stéphane Ducasse  wrote:
>
> refrain from using respondTo: I make code difficult to evolve and can
> introduce vicious bugs.
>
> Steph, would you say more about this? It’s something I’ve been wondering
> about.
>
> I was recently reading the Strategy pattern in the Smalltalk Companion to
> the GOF book. On p. 339, they proposed the following "Smalltalk way" as an
> alternative to the common class-per-strategy implementation:
>
> [[[language=smalltalk
>
> Composition>>repair
>
> "Without the strategy pattern, but using perform:."
>
> | selector |
>
> "Construct the name of the method to invoke:"
>
> selector := ('formatWith', formattingStrategy, 'Algorithm') asSymbol.
>
> self perform: selector
>
> ]]]
>
> It then dismissed the approach as "''clever but difficult from a program
> understanding perspective. Even static analysis tools such as code
> browsers' "senders" and "messages" fail on this code.''"
>
It is always best to have senders of the methods you use. Additionally,
it's far better to properly manage the user-friendly identification of a
thing and the thing itself. e.g. Plain language name mapped to a selector
or a block.

Remember, "the fact that one *can* do something is far different from
whether one *should* do that thing." (I have suffered far too often and far
too long from clever programs preferring the former without thinking about
the latter.)

It struck me as perhaps a bit extreme (i.e. too clever indeed) to construct
> the algorithm selector via string concatenation. Maybe "senders" search
> capabilities have gotten more sophisticated since publication, but Pharo
> seems to support symbol arguments, even for e.g. message renames. I
> thought, why not the following:
>
> [[[language=smalltalk
>
> Composition>>repair
>
> "Without the strategy pattern, but using perform:."
>
> self perform: self formattingStrategy
>
> ]]]
>
> Then client code like ==aComposition formattingStrategy:
> #formatWithSimpleAlgorithm== would show up in senders, message renames, etc.
>
> But from what you’re saying, I feel I may be missing something…
>
>
>


Re: [Pharo-users] Can it do this way ?

2020-09-08 Thread Richard Sargent
On Tue, Sep 8, 2020, 04:35 Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Op 8-9-2020 om 08:30 schreef Roelof Wobben:
>
> Op 8-9-2020 om 04:22 schreef Richard O'Keefe:
>
> There are two quite different questions.
> (1) Where may dashes occur in a real ISBN-10?
> (2) What does Exercism require in the specification and check in the
> test cases?
>
> For (1) the rules are
>
> Each ISBN consists of 5 elements with each section being separated by
> spaces or hyphens. Three of the five elements may be of varying length:
>
>- *Prefix element* – currently this can only be either 978 or 979. It
>is always 3 digits in length
>- *Registration group element* – this identifies the particular
>country, geographical region, or language area participating in the ISBN
>system. This element may be between 1 and 5 digits in length
>- *Registrant element* - this identifies the particular publisher or
>imprint. This may be up to 7 digits in length
>
>
>- *Publication element* – this identifies the particular edition and
>format of a specific title. This may be up to 6 digits in length
>- *Check digit* – this is always the final single digit that
>mathematically validates the rest of the number. It is calculated using a
>Modulus 10 system with alternate weights of 1 and 3.
>
> An ISBN-10 does not have the three-digit prefix.  So we have
>   [0-9]{1,5}   -- prefix
>   [0-9]{1,7}   -- registrant
>   [0-9]{1,6}   -- publication
>   [0-9X]
>   -- check digit
>
> As an examplw, "Standard C++ IOStreams and Locales" by Langer & Kreft has
> ISBN-10 0-201-18395-1
> ISBN-13 9780201183955
> so I shall assume the separators are optional.
> /^[0-9]{1,5}[- ]?[0-9]{1,7}[- ]?[0-9]{1,6}[- ]?[0-9X]$/
> Of course the elements cannot all have their maximum length at the same
> time.  In AWK I would write
>x = a_putative_ISBN_10
>y = x
>gsub(/[- ]+/, "", y)
>if (x ~ /^[0-9]{1,5}[- ]?[0-9]{1,7}[- ]?[0-9]{1,6}[- ]?[0-9X]$/ \
> && y ~ /^[0-9]{9,9}[0-9X]$/ \
>) {
>x *might* be valid, we still need to check the checksum
>}
>
> For (2), there appear to be no restrictions on where dashes may occur
> or how many: "These may be communicated with or without hyphens".
> Exercism doesn't allow spaces.
>
> Regular expressions are elegant in their own way, BUT for this problem
> they are (a) excessive, (b) inefficient, and (c) insufficient.
>
>digit count := 0.
>check sum := 0.
>for each character c of the string
>if c is not a hyphen then
>if c is a digit then
>digit value := c's value as a digit
>else if c is X and digit count = 9 then
>digit value := 10
>else
>return false.
>digit count := digit count + 1.
>if digit count > 10 then return false.
>check sum := (11 - digit count) * digit value + check sum.
> return check sum mod 11 is zero.
>
> Part of the insight here is "don't DO it, just PRETEND you did."
> That is, instead of copying the string without the hyphens,
> just ignore the hyphens as they turn up.
> Another part is "if you are only going to use it once, don't store it."
> That is, we need a digit's value just once, in the update to check sum,
> so we should compute it just before we need it, not store it.
>
> Now the pseudo-code above is classic sequential imperative coding.
>
> Classic functional coding does something like
>let no_dashes = filter (/= '-') (explode string) in
>length no_dashes = 10 and
>let check = last no_dashes in
>(is_digit check or check = 'X') and
>all is_digit (take 9 no_dashes) and
>let xval c = if x = 'X' then 10 else digit_value c in
>dot (map xval no_dashes) [10,9..1]) mod 11 = 0
>
> This pseudo-code translates nicely to Smalltalk too.
> You might want to add
>
> SequenceableCollection>>
>   with: other inject: initial into: aBlock
> |r|
> r := initial.
> self with: other do: [:x :y |
>   r := aBlock value: r value: x value: y].
> ^r
>   dot: other
> ^self with: other inject: 0 into: [:acc :x :y | x*y + acc]
>
> (These methods are so obvious that it would be absurd to claim
> any intellectual property rights to them.)
>
> I also have "fusion" methods like
> SequenceableCollection>>
> from: start to: finish allSatisfy: testBlock
>   self from: start to: finish do: [:each |
> (aBlock value: each) ifFalse: [^false]].
>   ^true
>
> so that ((seq copyFrom: a to: z) allSatisfy: blk)
> can be done as (seq from: a to: z allSatisfy: blk)
> without making a copy.
>
> Fusion methods are useful because Smalltall compilers
> don't work as hard at eliminating intermediate data
> structures as functional language compilers.  (Having
> other priorities.)
>
>(isdigit (last no_dashes
>return false if digit count > 10.
>
>
>
>
> Thanks for letting me see this.
> But still I wonder if this is really the OOP way and if 

Re: [Pharo-users] mentoring contined I hope

2020-09-01 Thread Richard Sargent
What is the value of *self* when the error occurred? The debugger should
show you this.

Another way to determine this is to look at the code and think about where
the sending method is implemented and where the invoked method is
implemented (assuming that there really is one).


On Tue, Sep 1, 2020 at 10:11 AM Roelof Wobben  wrote:

> oke, then I would work with hour and minutes as the challenge wanted,
>
> So still on the class side make code that convert any given hour and
>> minute to a valid one ?
>>
>
> Yes. Such code would also be used when doing arithmetic with Times. e.g.
> if you were to implement an instance method named #addMinutes:, its
> implementation would be as simple as ^Time hours: self hours minutes: self
> minutes + anInteger (assuming the argument has that name). The instance
> creation method would normalize the new requested time, just like Time
> hours: 0 minutes: 70 would do.
>
>>
>> Roelof
>>
>>
>
> On some way I think or I do something wrong or I did misunderstood you.
>
>  I did this in Pharo
>
> Object subclass: #Clock
> instanceVariableNames: 'hour minute'
> classVariableNames: ''
> package: 'Exercise@Clock'
>
> I made a asscesors on the instance side.
>
> then I did this on the class side :
>
> hour: anInteger minute: anInteger2
> self hour: anInteger2 % 60 + anInteger;
> self minute: anInteger2 / 60;
> yourself.
>
> but I see a message that hour and minutes are not known.
>
> Roelof
>
>


Re: [Pharo-users] mentoring contined I hope

2020-09-01 Thread Richard Sargent
I recommend against modifying time instances once created. Likewise for
dates and timestamps.You don't know if the time instance has been shared
with another object. It's best to treat them as immutable once created.

Do not make the mistake of trying to avoid creating new objects. It will
lead to contorted code and all sorts of complications. (Of course, be
careful not to create a bazillion objects unnecessarily!)

The same advice applies to creating classes. Some languages have a high
cost to define a new class, usually psychological. This leaves their
programmers "allergic" (or acting as if they were) to creating a new class
that would make a solution better. In Smalltalk, a class is just an object.


In terms of how to model time, you *could* have the time object just store
the count of intervals since the start of the day. But, if you want Times
with microsecond resolution or nanosecond resolution, you would always be
working with a LargeInteger internally.
VA Smalltalk Time has ('hours' 'minutes' 'seconds' 'milliseconds'
'millisecondsFromMidnight')
VisualWorks Time has ('hours' 'minutes' 'seconds' 'milliseconds'
'partialNanosecond')
Pharo (5.0) Time has ('seconds' 'nanos')

It can be useful to trade space efficiency for comprehensibility. Often,
focussing on space efficiency results in convoluted code for little other
benefit. It's a good idea to start by modelling the concepts that we
discuss when describing something. My cookoo clock has an hour hand and a
minute hand. It has no concept of seconds, per se. It has a time tick, but
whether that is exactly one second, I don't know. Probably not. The
pendulum doesn't move that fast. So, if modelling a cookoo clock, modelling
the hours and minutes it shows is a reasonable design.

In some respects, modelling your Time as a number of minutes into the day
would simplify normalizing the arguments to the instance creation methods.
Just compute the requested number of minutes, perform the modulus to limit
the size of a day, and you are done. In the absence of a constraint imposed
by the author of the problem, you are free to implement a solution that
presents the expected results.


On Mon, Aug 31, 2020 at 10:12 PM Roelof Wobben  wrote:

> Op 1-9-2020 om 00:22 schreef Richard Sargent:
>
> On Mon, Aug 31, 2020 at 3:10 PM Roelof Wobben  wrote:
>
>> Op 31-8-2020 om 23:45 schreef Richard Sargent:
>>
>> On Mon, Aug 31, 2020 at 1:57 PM Roelof Wobben  wrote:
>>
>>>
>>> I would argue against that approach. Make it a requirement that a given
>>> API must be used with correct values.
>>> e.g. #hours:minutes: requires hours between 00 and 23 and minutes
>>> between 00 and 59.
>>>
>>> If you want to convert equivalent time values, use a specific API. For
>>> example, many time implementations publicly define a seconds-based API,
>>> such as Time class>>#fromSeconds:. You can do the same with your
>>> implementation with a class-side #fromMinutes: method. (The corresponding
>>> instance methods would be #asSeconds and #asMinutes or something similar.)
>>>
>>>
>>>
>>> Moment, I do not know if I understand you right.
>>>
>>> so I would use the given method and use on the instance another function
>>> that takes care of the converting to or a valid time object or for example
>>> convert it to minutes and on display take care that a valid time is shown.
>>>
>>> Do I understand you right ?
>>>
>>
>> I don't think you do, but it's a little difficult to determine.
>>
>> *Time hours: 0 minutes: 70* should throw an out of range exception on
>> the second argument.
>> Time fromMinutes: 70 "should" answer an instance equivalent to 01:00. (I
>> say should in quotes, because Time is a point in time. Duration is
>> something that makes more sense to have *Duration minutes: 70* be
>> acceptable.)
>>
>> This discussion assumes *your* model of time uses just hours and
>> minutes. Normally, Time includes seconds, and often fractions of seconds.
>> But, you are working on an exercise, so a reduced scope Time may be
>> appropriate.
>>
>> Rather than talking about Time class>>#fromMinutes:, let's go a little
>> more extreme and discuss a hypothetical Time class>>#fromHours: method. We
>> understand and agree that Time can represent hours from 0 through 23. There
>> is no 24 o'clock. So, if you wrote *Time fromHours: 25*, what would you
>> expect to get for a result? What would someone who comes along later and
>> uses your code expect to get? It's not well defined. So extrapolate from
>> that case to the other cases. 70 minutes is not a time. "I'll meet you
>> *at* 70 minutes&q

Re: [Pharo-users] mentoring contined I hope

2020-08-31 Thread Richard Sargent
On Mon, Aug 31, 2020 at 1:57 PM Roelof Wobben  wrote:

>
> I would argue against that approach. Make it a requirement that a given
> API must be used with correct values.
> e.g. #hours:minutes: requires hours between 00 and 23 and minutes between
> 00 and 59.
>
> If you want to convert equivalent time values, use a specific API. For
> example, many time implementations publicly define a seconds-based API,
> such as Time class>>#fromSeconds:. You can do the same with your
> implementation with a class-side #fromMinutes: method. (The corresponding
> instance methods would be #asSeconds and #asMinutes or something similar.)
>
>
>
> Moment, I do not know if I understand you right.
>
> so I would use the given method and use on the instance another function
> that takes care of the converting to or a valid time object or for example
> convert it to minutes and on display take care that a valid time is shown.
>
> Do I understand you right ?
>

I don't think you do, but it's a little difficult to determine.

*Time hours: 0 minutes: 70* should throw an out of range exception on the
second argument.
Time fromMinutes: 70 "should" answer an instance equivalent to 01:00. (I
say should in quotes, because Time is a point in time. Duration is
something that makes more sense to have *Duration minutes: 70* be
acceptable.)

This discussion assumes *your* model of time uses just hours and minutes.
Normally, Time includes seconds, and often fractions of seconds. But, you
are working on an exercise, so a reduced scope Time may be appropriate.

Rather than talking about Time class>>#fromMinutes:, let's go a little more
extreme and discuss a hypothetical Time class>>#fromHours: method. We
understand and agree that Time can represent hours from 0 through 23. There
is no 24 o'clock. So, if you wrote *Time fromHours: 25*, what would you
expect to get for a result? What would someone who comes along later and
uses your code expect to get? It's not well defined. So extrapolate from
that case to the other cases. 70 minutes is not a time. "I'll meet you *at*
70 minutes" said no one ever. :-) ["*in* 70 minutes" is a duration from the
present moment, implying a time 70 minutes in the future.]

I have come across a lot of code in my life. The hardest code to work with
and to enhance is code that says it will try to accept whatever it's given.
If it wants a number, it will accept a string of digits and "figure out"
what number was meant. Life is so much easier when the author says "That's
rubbish. Give me a proper number." or "That's too big. Give me a proper
number of hours.", etc.

In general, make your APIs precise and predictable. Range check the passed
values and complain when they aren't proper. If the clock you are modelling
has a precision of minutes, your API is #hours:minutes: and maybe just
#hours: for convenience. (In general, I wouldn't do so.) And it's
reasonable to have methods to answer the number of increments from the
start of the day of your clock's precision and to create a new instance
from that number. So, with a precision of minutes, you can have an instance
method named e.g. #asMinutes or perhaps #totalMinutes or even
#minutesSinceMidnight, and to have a corresponding *class* method
#fromMinutes: or #minutesFromMidnight: which answers the corresponding
instance of Time. If your clock has a precision of seconds, which is more
normal for us, those "minutes" methods would actually be similarly named
"seconds" methods instead. (If your clock has a precision finer than
seconds, I would expect to see corresponding methods for the finer
gradations of time that would be common, *in addition to* the various
"seconds" methods. e.g. milliseconds or microseconds since midnight. And
likely both if the clock resolution was microseconds, just because we do
tend to think of milliseconds or microseconds when we talk of more precise
times.)


Just as the advice I gave you some months ago was to be unambiguous and
precise when naming things, be unambiguous and precise about your APIs (all
your methods, really!). People who end up using your code will thank you.





> I send this personal because I cannot send to the mailing list according
> to some spam list
>


Re: [Pharo-users] mentoring continued I hope

2020-08-31 Thread Richard Sargent
On Sun, Aug 30, 2020 at 10:04 PM Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Hello,
>
> I have this challenge from exercism :
> https://github.com/exercism/pharo-smalltalk/tree/master/exercises/clock
>
> and this function is given :
>
> hour: anInteger minute: anInteger2
>  self shouldBeImplemented
>
>
> Schould I make it on this class method work that the minutes will not
> exceed the 59 minutes
> So when for example when 70 min are given so hour:0  minute:70 it will
> be converted to hour: 1 minutes: 10
>

I would argue against that approach. Make it a requirement that a given API
must be used with correct values.
e.g. #hours:minutes: requires hours between 00 and 23 and minutes between
00 and 59.

If you want to convert equivalent time values, use a specific API. For
example, many time implementations publicly define a seconds-based API,
such as Time class>>#fromSeconds:. You can do the same with your
implementation with a class-side #fromMinutes: method. (The corresponding
instance methods would be #asSeconds and #asMinutes or something similar.)


or can I better do this on the instance side.
>
> Regards,
>
> Roelof
>
>
>


Re: [Pharo-users] Pharo at JPL

2020-08-28 Thread Richard Sargent
On Fri, Aug 28, 2020 at 3:27 PM tbrunz  wrote:

> Hi Konrad,
>
> I'm the person at JPL who (somehow) got "The Powers That Be" here to agree
> to join the Consortium.
>
> I'm also the major champion of Pharo at JPL, and am leading an effort to
> get
> Pharo introduced & infused at JPL.
>
> I see the initial "market" for Pharo here to be:
>
> * Scientific & engineering data analysis & visualization,
> * Modeling and simulation,
> * Internal web servers,
> * Custom ground support & test systems,
> * Small-to-medium sized scripting to "support applications".
>
> I'm sure more application areas will open up as I get people to start using
> Pharo in their particular areas of expertise.
>
> I'm doing what I can be promoting Pharo, providing introductions &
> training,
> and I'm now working on demonstrations that can catch the attention of both
> engineers and managers -- to see the potential.
>
> Wish me luck!
> -Ted
>

Good luck! And Well Done!!


>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] Class side vs instance side (variables and methods)

2020-08-02 Thread Richard Sargent



On August 2, 2020 10:16:54 AM PDT, tbrunz  wrote:
>Thanks, Richard.  
>
>So adding #yourself is mostly needed for cases where you send #add: to
>an
>OrderedCollection (because that returns the added element instead of
>returning the collection as most expect it would)?

No.

It is used when you don't know what the last message send answers. And, *that* 
is most of the time, because even when you know the answer today, you don't 
know the future changes.


>
>I've been adding it in all cases, which I guess does no harm.

That is the correct answer. Add it unless you want the result of the last 
message send.


>
>-t
>
>
>
>--
>Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



Re: [Pharo-users] Class side vs instance side (variables and methods)

2020-08-02 Thread Richard Sargent



On August 2, 2020 9:25:32 AM PDT, tbrunz  wrote:
>Shouldn't this code
>
>> So if you implement a #newWhite method in the "class side" of Dog, it
>> would be something like this. 
>> 
>> Dog class>>newWhite
>>   "Returns a new white instance of receiver."
>>   ^self new color: Color white
>
>be this instead?
>
>> Dog class>>newWhite
>>   "Returns a new white instance of receiver."
>>   ^self new 
>> color: Color white;
>> yourself
>
>in order to return the new Dog instance?  Otherwise it will return the
>Dog
>class itself (not what you expected?

No. It cannot answer the class. It will answer the result of the last message 
send. That could be the new instance OR the result of sending #white to Color.

This latter point is the reason why people generally like to include the 
#yourself message in the cascade.


>
>-t
>
>
>
>--
>Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



Re: [Pharo-users] Class side vs instance side (variables and methods)

2020-07-28 Thread Richard Sargent
On Tue, Jul 28, 2020 at 4:35 PM G B via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Being new not only to Smalltalk, but OOP in general, I think I finally am
> understanding things. One area I am still unsure about is the class side
> versus the instance side. Does one usually use the class side when they
> want those inherited in every subclass, which frees one from having to
> declare them in every instance?
>

One of the important concepts in Smalltalk is that *everything* is an
object. When we say "class side" and "instance side", we are using a
shorthand for the two objects involved. In most Smalltalks, the "class
side" is really a meta-class and the "instance side" is really the class.
The browser is designed to present them together because it makes sense to
do that. Both sets of behaviours and variables are inherited by subclasses.
[I'm playing a little loose here, as there is a distinction between a Class
Variable and a Class Instance Variable in the meta-class.] The
meta-class/"class side" typically deals with instance creation and
management. The "instance side" provides the behaviours associated with the
instances of the class.


> TIA for reading my silly questions.
>

Not silly at all. This is a somewhat opaque topic since the browser makes
it appear less obvious.


Re: [Pharo-users] Pharo-Mars on Ubuntu

2020-07-21 Thread Richard Sargent
The most common cause of things like this seems to be running a 32-bit program 
and only having the 64-bit libraries available. Is your Pharo VM 32-bit?


On July 21, 2020 8:24:15 AM PDT, kmo  wrote:
>I've just tried to get pharo-mars working on xubuntu 20.04. But it
>tells me
>it cannot find the GTK3 library. But the library is present here:
>/usr/lib/x86_64-linux-gnu/libgtk-3.so.0
>
>I thought this was supposed to be the correct place.
>
>Should I be putting a symbolic link somewhere?
>
>
>
>--
>Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html


Re: [Pharo-users] mentor help continued

2020-07-14 Thread Richard Sargent
Perhaps you should start by looking to see whether there is or are classes
already in the image that do what you want.

Look for classes by name (with wildcards) or for methods. For example, are
there any classes which implement #hours, #minutes, or #seconds (possibly
in the singular form).

On Tue, Jul 14, 2020, 07:44 Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Sorry that you did not hear from me a long time but I was in a dark
> place for a long time.
>
> but im back and have a question
>
> I have to make a clock so the seconds and minutes schould not be above 60,
>
> How can I take care of that ?
>
> and can I put the code here on the class side on this given method
>
> hour: anInteger minute: anInteger2
>  self shouldBeImplemented
>
> or schould I use that to make a call to the instance side and take care
> of there that the seconds and minutes are always valid.
>
> Roelof
>
>
>


Re: [Pharo-users] Agile Artificial Intelligence in Pharo book

2020-07-12 Thread Richard Sargent
It is possible that one of the prerequisites comes from smalltalkhub.com,
as that site has been down for the last couple of days.

On Sun, Jul 12, 2020, 15:53 G B via Pharo-users 
wrote:

> I bought "Agile Artificial Intelligence in Pharo" and am using Pharo 8.0
> 64-bit.  In the book it says you can download the source using:
>
> Metacello new
>   baseline: 'AgileArtificialIntelligence';
>   repository: 'github://Apress/agile-ai-in-pharo/src';
>   load.
>
> Then it times out with:
> "MCSmalltalkhubRepository(MCRepository)>>error:"
> self
>
> Could not load Athens-SVG-PeterUhnak.17.mcz:
> ZnHttpUnsuccessful: 503 Service Temporarily
> Unavailable
>
> I am fairly new to Pharo and run into problems with documentation being
> old, for example, Pharo By Example. I realize it is difficult to keep books
> updated with the many changes in an active project. I'm fine with that.
>
> However, how can a just published book have the source listed in its
> pages, but then not have it available?
>
>
>


Re: [Pharo-users] a simple question (I think)

2020-06-21 Thread Richard Sargent
On Sun, Jun 21, 2020, 14:54 Russ Whaley  wrote:

> Why? (question, not a challenge :) )
>
> - I really only use it in a Logger class I developed that let’s me know at
> the time of logging, what method and class I’m in - ... write to the log...
> done.
>

That's a reasonable use.

In general, you don't use it to derive meaning that your program relies on.
Stack reporting is a good use.
Your logging use is a degenerate case of stack reporting.


> On Sat, Jun 20, 2020 at 3:08 AM Stéphane Ducasse <
> stephane.duca...@inria.fr> wrote:
>
>> as a general principle do not use thisContext.
>>
>>
>> S.
>>
>>
>> On 20 Jun 2020, at 01:12, Russ Whaley  wrote:
>>
>> Thank you both for your insights. I’ve done the newFor: style many times,
>> but where it falls short is when I read in a STON object. No worries, I was
>> just wondering if there was something cool like “what object am I sitting
>> on?”... I looked through Context and the client message will be helpful to
>> me in other areas. I’m always eager to learn. Thank you very much for being
>> willing to teach.
>>
>> Thanks!
>> Russ
>>
>> On Wed, Jun 17, 2020 at 9:05 PM Richard O'Keefe  wrote:
>>
>>> I have a strong dislike for incompletely initialised objects.
>>> So I would do it like this:
>>>
>>>myInstVar := TheDependentClass newFor: self.
>>>
>>> (together with any other essential information as parameters).
>>> In my Smalltalk system it would look like this:
>>>
>>>   Whatever subclass: #TheDependentClass
>>> instanceConstantNames: 'owner'
>>> ...
>>> class methods for: 'instance creation'
>>>   newFor: owner
>>> ^(self basicNew) pvtOwner: owner; yourself
>>>
>>> methods for: 'initialising'
>>>   pvtOwner: anObject
>>> super pvtPostNew.
>>> owner := anObject.
>>>
>>> Private access to methods with a 'pvt' prefix is enforced.
>>> Instance constants can only be set in private methods.
>>> There's an additional wrinkle that makes it a run time
>>> error to call TheDependentClass new, so that you cannot get
>>> an incompletely initialised object.
>>>
>>> In any Smalltalk you can follow similar conventions even if
>>> they are not enforced.
>>>
>>> Of course if you don't mind incompletely initialised objects,
>>> nothing stops you writing code that allows them.  The question
>>> is whether you want to be able to trust the 'owner' field or
>>> not.
>>>
>>> On Thu, 18 Jun 2020 at 09:46, Esteban Maringolo 
>>> wrote:
>>>
 Objects interact with each other by sending messages, although you can
 get the sender by using reflection (thisContext sender), it is not a
 common practice to do so.
 So if you need another object to know the sender (or any other object)
 you simply pass it as a parameter.

 So modifying your example, and making the syntax actually work it would
 be:

 self property: ObjectClass new.
 self property caller: self.

 and then when you need to deal with that you can simply get a
 reference to that object and send it a message to do something:
 self property caller doSomething.

 You can also have something like

 self property: (ObjectClass for: self)


 In that case the #for: message is received by "ObjectClass class",
 which you can think of as if it were a Factory or a "static" method
 (it is not! it is much more powerful than that).

 ObjectClass class>>#for: callerObject
   ^self new
  setCaller: callerObject;
  yourself

 And that's it, you have an instance of ObjectClass that you
 initialized by sending #for: instead of #new (internally it ended up
 calling #new, but from the outside it was just a message send).

 And for the most part that's Smalltalk: Objects and messages.

 Regards!

 Esteban A. Maringolo

 On Wed, Jun 17, 2020 at 6:19 PM Russ Whaley 
 wrote:
 >
 > I find myself, over and over, creating a & storing q new object in an
 instVar, then storing (my)self on that object - so I can have easy access
 to the 'object that created me.'
 >
 > 
 >
 > self instVar := NewClass new.
 >
 > self instVar callingObject: self.
 >
 > "where these call the same messages"
 >
 > self myMessage.
 >
 > self instVar callingObject myMessage.
 >
 > 
 >
 > self instVar := NewClass new.
 >
 > self instVar objectWhoCreatedMe myMessage.
 >
 > "I know there is a 'thisContext sender' - but is there a 'who created
 me' concept?"
 >
 >
 > Ultimately, there is no real overhead to storing (my)self on a new
 object, I guess, but as I'm developing and testing, I tend to have a whole
 lot of 'stranded objects' I have to remove manually.
 >
 > Thoughts?
 >
 > Thanks!
 > --
 > Russ Whaley
 > whaley.r...@gmail.com

 --
>> Russ Whaley
>> whaley.r...@gmail.com
>>
>>
>> 

Re: [Pharo-users] [ANN] What are reasons NOT to use Smalltalk?

2020-06-19 Thread Richard Sargent
On Fri, Jun 19, 2020 at 11:39 AM horrido  wrote:

> I'm not sure I understand. Are you saying you tried to submit "Vote"
> without
> checking off any of the boxes?
>

Yes, that is what I am saying. None of those are reasons to NOT use
Smalltalk, in my opinion.


> You can always add comment to the post.
>
>
>
> Richard Sargent wrote
> > It wouldn't let me vote without choosing an answer, none of which were my
> > answer.
> >
> > On Fri, Jun 19, 2020 at 9:32 AM Richard Kenneth Eng <
>
> > horrido.hobbies@
>
> >> wrote:
> >
> >>
> >>
> https://smalltalk.tech.blog/2020/06/19/what-are-reasons-not-to-use-smalltalk/
> >>
> >>
> >> Thanks for participating in the poll.
> >>
>
>
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] [ANN] What are reasons NOT to use Smalltalk?

2020-06-19 Thread Richard Sargent
It wouldn't let me vote without choosing an answer, none of which were my
answer.

On Fri, Jun 19, 2020 at 9:32 AM Richard Kenneth Eng <
horrido.hobb...@gmail.com> wrote:

>
> https://smalltalk.tech.blog/2020/06/19/what-are-reasons-not-to-use-smalltalk/
>
>
> Thanks for participating in the poll.
>


Re: [Pharo-users] About strange email related to smalltalkhub read-only on squeak-dev

2020-05-31 Thread Richard Sargent
Thanks, Bruce. The part about (the possibility that) squeak source is
configured to restrict distribution was the missing piece for me. I had
previously assumed (hah!) that it would be available to anyone anywhere.


On Sun, May 31, 2020, 10:39 Bruce O'Neel  wrote:

>
> Hi,
>
> So addressing only the crypto software issue and with the caveat that I am
> also not a lawyer but I have had to deal with certain aspects of this in
> the past
>
> Crypto software is one of those bizarre dual use items in terms of arms
> imports and exports.  While we as geeks just think of this is software or
> mathematics and might be confused as to why governments care, governments
> do care deeply about this.  And their way of expressing how much they care
> about this issue is by passing laws and prosecuting folks.
>
> One of the easiest ways to get in trouble is for one to make the software
> available to residents and/or citizens of certain countries as well as
> available to people on a long list kept by different governments.  We can
> have a long debate about the morality of this concept but those who make
> the laws have decided that is the law.  And often these laws are crafted
> such that the executive can change important details on short notice and
> that puts the risk of prosecution at the whims of different world leaders.
>
> The license that the software is released under is not important.
>
> What Ron is stating is that squeak source supplied some additional
> protections to prevent accidentally making the software available to folks
> who the US feels should not have access.
>
> If you have moved the software to another hosting provider without the
> permission or knowledge of the author, and therefore the owner of the
> software, you have put that person at additional risk.  In addition you and
> the hosting provider are taking on additional risk.
>
> If it was moved to GitHub I strongly recommend reviewing their policies on
> trade controls and what risks you assume.
>
> https://help.github.com/en/github/site-policy/github-and-trade-controls
>
>
> Finally I would strongly recommend talking to a competent legal advisor
> who is deeply familiar with the details of these laws.  They are complex
> and highly variable between different parts of the world.
>
> I know this seems like a lot of trouble and wasted time but you can spend
> a giant amount of time and money defending oneself from arms trafficking
> charges.
>
> cheers
>
> bruce
>
> *30 May 2020 14:43 Stéphane Ducasse  > wrote:*
>
> Hi all
>
> This is the week-end and we worked super well yesterday during the sprint.
> Lot of good enhancements - Thanks a lot to all the participants.
> I not really happy to be forced to do it on a sunny saturday but I’m doing
> it to clarify points.
>
> Esteban sent me this text that was posted on Squeak-Dev (I personally do
> not read squeak related forums because
> I have not the time and my focus is Pharo, its consortium, my team, my
> research and my family).
>
> We have to react because
> - We do not really at ***all** understand this email
> - We did not kicked anybody from our mailing-list from ages - so ron is
> lying. In the past we even had discussion with ron - so we do not
> really understand. May be we got problem to log on our mailing-lists.
> We have no idea because we are working and not looking at such things.
> - When we migrated smalltalkhub to readonly we payed attention to make
> sure that private projects stay private.
> We did not migrated smalltalkhub for fun. We MUST do it or it will be done
> by our infrastructure!
> - Now the cryptography packages are MIT and they are public anyway. So
> again we do not understand anything.
>
> We do not get why Ron contacted us because we announced the migration
> publicly way in advance and we will keep
> the Smalltalkhub frozen repo for at least next 5 years.
>
> I feel really sorry to hear such kind of email because we do not want to
> fight with anybody.
> Our goal is to make sure that people can work with Pharo and expand their
> business and knowledge.
> We are working hard to make sure that people can invent their future with
> Pharo and people that know us personally
> know that we are not lying.
>
> S
>
>
>
> Hi all,
>
> I've tried to work with the Pharo group but they keep kicking me out of
> their mailing list.  I've already mentioned this a number of times to the
> Pharo group but nobody seems to care.
>
> BOLD BOLD BOLD PLEASE TAKE THIS SERIOUSLY  BOLD BOLD BOLD
>
> I am not a lawyer but we used very good lawyers to make the squeaksource
> repository a safe place to do cryptography work.  If you are working on
> cryptography DO NOT POST your code anywhere except squeaksource.
> Especially if you are in the USA.  The ONLY repository that is approved to
> host our cryptography code in the USA and therefore not subject to criminal
> violations is squeaksource.  It is a CRIME in the USA to move code and make
> it available on the internet for 

Re: [Pharo-users] [ANN] What are good reasons to use Smalltalk?

2020-05-18 Thread Richard Sargent
On Mon, May 18, 2020 at 4:01 PM horrido  wrote:

> It's 2020 and we're still faced with browser compatibility issues?!!
>
> Man, the web is really a piece o' sh*t.
>

Ah, you forgot the little detail about having to authorize 3-4 dozen(!)
scripts from many different sources to run on your computer before the site
is remotely usable. And, then you get to their programmers' definition of
usable.



>
>
> Offray Vladimir Luna Cárdenas-2 wrote
> > Same for Firefox. I thought the poll was closed when I visited. Now I
> > can check it works on Chromium. I wonder how many people tried to
> > participate before but has not the proper browser to do it and not even
> > a clue about that.
> >
> > How could be this pull be made more open and accessible?
> >
> > Cheers,
> >
> > Offray
> >
> > On 15/05/20 4:35 p. m., Esteban Maringolo wrote:
> >> I don't know what is behind the poll system, but it doesn't work in
> >> Brave browser. It simply says "Thanks for participating in the poll."
> >>
> >> I find the questions confusing though.
> >>
> >> Esteban A. Maringolo
> >>
> >> On Wed, May 13, 2020 at 4:43 PM Richard Kenneth Eng
> >> 
>
> > horrido.hobbies@
>
> >  wrote:
> >>>
> https://smalltalk.tech.blog/2020/05/13/what-are-good-reasons-to-use-smalltalk/
> >>>
> >>> Please participate in the poll.
>
>
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] [ANN] What are good reasons to use Smalltalk?

2020-05-15 Thread Richard Sargent
On Fri, May 15, 2020 at 1:31 PM horrido  wrote:

> I've updated the poll question, but since there are already 56 votes, it
> looks like nobody chose my new addition. Perhaps more of you should vote to
> change that.
>

Communicating with developers is implicit. My point was about communicating
with subject matter experts. i.e. non-developers.
When our code closely corresponds to the language used by non-developers,
we improve our chances that future communication remains fruitful and less
subject to mis-interpretation.



>
> horrido wrote
> > You are quite right. How did I manage to miss that?!!
> >
> >
> > Richard Sargent wrote
> >> You missed the fact that it makes it easier to communicate with the user
> >> community, since it's a "near-English" grammar, and you can easily use a
> >> common terminology.
> >>
> >>
> >> On Wed, May 13, 2020, 12:43 Richard Kenneth Eng 
> >
> >> horrido.hobbies@
> >
> >> 
> >> wrote:
> >>
> >>>
> >>>
> https://smalltalk.tech.blog/2020/05/13/what-are-good-reasons-to-use-smalltalk/
> >>>
> >>>
> >>> Please participate in the poll.
> >>>
> >
> >
> >
> >
> >
> > --
> > Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] ifCurtailed prompts debug window

2020-05-15 Thread Richard Sargent
On Fri, May 15, 2020 at 10:00 AM Vitor Medina Cruz 
wrote:

> Hello,
>
> On Windows 10 and Pharo 8, If I do:
>
> [ Error signal ] ifCurtailed: [ Transcript show: 'error' ].
>
> the debug window pops up, when I close, 'error' is print in the
> Transcript. If I do
>

That is correct. It isn't curtailed until the default handler finishes and
drops the stack frames. In this case, the default handler opens the
debugger. When you terminate the debugger, you curtail the execution, not
before.


> [ Error signal ] on: Error do: [ Transcript show: 'error' ].
>
> 'error' is print in Transcript without debug windows pops up. I was
> expecting the same behavior here, as if ifCurtailed was a syntax sugar for
> on:do:, that is not the case or it is some kind of error? The way it is, I
> cannot use ifCurtailed because I don't want the debug window to pup up.
>
> Regards,
> Vitor
>


Re: [Pharo-users] [ANN] What are good reasons to use Smalltalk?

2020-05-13 Thread Richard Sargent
You missed the fact that it makes it easier to communicate with the user
community, since it's a "near-English" grammar, and you can easily use a
common terminology.


On Wed, May 13, 2020, 12:43 Richard Kenneth Eng 
wrote:

>
> https://smalltalk.tech.blog/2020/05/13/what-are-good-reasons-to-use-smalltalk/
>
>
> Please participate in the poll.
>


Re: [Pharo-users] FFI and absolute path to dll

2020-05-12 Thread Richard Sargent
On Tue, May 12, 2020, 12:05 ASAM  wrote:

> Hello,
> I'm using Pharo 8 64bit on Windows 10 64bit.
> I am trying to access a 32bit dll via a relative path.
>

Generally, a 64-bit program will only load a 64-bit DLL. It may be
possible, but it will likely be far easier to use the 32-bit Pharo
implementation.


> I'm desperate. I've been reading the document
> (http://books.pharo.org/booklet-uffi/pdf/2020-02-12-uFFI-V1.0.1) all the
> time up and down but I can't find an example of absolute path and Windows.
>
> If e.g. my.dll file would be stored here.
>
> C:\Program Files (x86)\GALEP5\my.dll
>
> then what should the method win32ModuleName return?
>
> Another question came to me while reading the document.
> It is actually important to know whether the DLL was generated as cdecl or
> stdcall?
> The dll i try to call use stdcall.
>
> I would be very happy if someone helps me.
> I can no longer see the message "External module not found" :-)
>
> Thanks a lot!
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] mentor question 4

2020-05-12 Thread Richard Sargent
Richard, your diligence is awesome!

I'm left feeling that, generally, objects should not implement nor understand 
#asString. I realize there is a lot of room for debate on this subject.



On May 11, 2020 10:12:10 PM PDT, Richard O'Keefe  wrote:
>For what it's worth, here's a moderately thorough examination of
>several
>different Smalltalk systems.
>Let A = astc, D = Dolphin, G = GNU Smalltalk, Q = Squeak,
>S = ANSI standard, T = Strongtalk, V = VisualWorks, X = ST/X
>
>#asString
>
>ADGPQST!X  Character => String with: self
>ADGPQSTVX  String => self
>ADGPQSTVX  Symbol => String withAll: self
>.  Text/Paragraph, where provided, => underlying string.
>A-G-X  Collection => String withAll: self
>---PQ  Collection => self printString
>A  ByteArray => "decoded as Unicode"
>.DGPQ-TVX  ByteArray => "decoded as Latin1"
>ADG.Q..VX  Filename => "unparse (Filename, FilePath, whatever)
>AdgpQ.TVX  URI => "unparse (ZnUrl in P)
>Ad.PQ...X  UUID => "unparse (d, GUID equivalent)"
>.DGpq...X  Number => self displayString "or self printString, maybe via
>Object"
>...PQ...X  Object => self printString
>
>There's a rough consensus here:
> - if something *is* textual (Character, String, Symbol, Text,
>   Paragraph) #asString returns it as a normal string
> - if something is a parsed form of structured text (file name,
>   URI, UUID) its unparsed form is returned, converting it back
>   should yield an equal parsed form
> - if something is a byte array, it may be converted to a string
>   (the rule is to preserve the bytes, my library presumes byte
>   arrays are UTF8-encoded)
> - if numbers are accepted at all, their #printString is returned
> - if is none of the above, but has a #name or #title, that is
>   commonly the result.
>
>The open question is what converting an array of characters using
>#asString will do.  There is at least one Smalltalk out there
>where #(65 66 67) asString => 'ABC', but that's a step further
>than I personally want, though it is consistent with ByteArray.
>
>
>
>
>On Tue, 12 May 2020 at 11:16, Jerry Kott  wrote:
>
>> Hi all,
>>
>> I’ve been lurking so far, but I must add my voice here and agree with
>> Richard.
>>
>> The malleability of Smalltalk tempts people into implementing
>#asString,
>> #name, and similar semantically ambiguous method names. Like Richard,
>I
>> regretted every single time I (or someone else on my team before me)
>> decided to use these. It goes back to ’Smalltalk with Style’
>(probably the
>> best little red book you could ever own): write intention revealing
>code
>> whenever you can, and comment liberally when you can’t.
>>
>> *Jerry Kott*
>> This message has been digitally signed.
>> PGP Fingerprint:
>> A9181736DD2F1B6CC7CF9E51AC8514F48C0979A5
>>
>>
>>
>> On 11-05-2020, at 2:48 PM, Richard Sargent 
>wrote:
>>
>>
>>
>> On May 11, 2020 2:19:49 PM PDT, Richard O'Keefe 
>wrote:
>>
>> I was saying that I expected #($a $b $c) asString ==> 'abc'.
>>
>>
>> Over the years, I found myself being opposed to the idea that all
>objects
>> can sensibly have an #asString implementation. When it's been done,
>it
>> ultimately caused more problems than it solved.
>>
>> Consider $(48 49 50) asString. Do you expect it to give you a string
>with
>> all the digits? Or perhaps it's meant to interpret the elements as
>> byte-like things, as you would need for "String withAll:
>aCollection". So,
>> the numbers could be interpreted as codepoints, as they are in a
>ByteArray.
>>
>> But, what does "(Array with: Object new with: ProcessScheduler)
>asString"
>> mean?
>>
>> It seems to me that having all objects understand #asString leads to
>> confusion.
>>
>> If you want an array to print as its literal representation,
>implement
>> #printAsLiteral, so that your intention is clear.
>>
>>
>> If you want something that can be read back, that's what #storeString
>> is for,
>>
>> On Tue, 12 May 2020 at 01:28, Stéphane Ducasse
>>  wrote:
>>
>>
>>
>>
>> On 5 May 2020, at 16:16, Richard O'Keefe  wrote:
>>
>> By the way, while playing with this problem, I ran into a moderately
>> painful issue.
>>
>> There is a reason that Smalltalk has both #printString (to get a
>> printable representation of an object) and #asString (to convert a
>> sequence to another kind of sequence with the same elements.)  

Re: [Pharo-users] mentor question 4

2020-05-11 Thread Richard Sargent



On May 11, 2020 2:19:49 PM PDT, Richard O'Keefe  wrote:
>I was saying that I expected #($a $b $c) asString ==> 'abc'.

Over the years, I found myself being opposed to the idea that all objects can 
sensibly have an #asString implementation. When it's been done, it ultimately 
caused more problems than it solved.

Consider $(48 49 50) asString. Do you expect it to give you a string with all 
the digits? Or perhaps it's meant to interpret the elements as byte-like 
things, as you would need for "String withAll: aCollection". So, the numbers 
could be interpreted as codepoints, as they are in a ByteArray.

But, what does "(Array with: Object new with: ProcessScheduler) asString" mean?

It seems to me that having all objects understand #asString leads to confusion.

If you want an array to print as its literal representation, implement 
#printAsLiteral, so that your intention is clear.


>If you want something that can be read back, that's what #storeString
>is for,
>
>On Tue, 12 May 2020 at 01:28, Stéphane Ducasse
> wrote:
>>
>>
>>
>> On 5 May 2020, at 16:16, Richard O'Keefe  wrote:
>>
>> By the way, while playing with this problem, I ran into a moderately
>> painful issue.
>>
>> There is a reason that Smalltalk has both #printString (to get a
>> printable representation of an object) and #asString (to convert a
>> sequence to another kind of sequence with the same elements.)  If I
>> *want* #printString, I know where to find it.  The definition in my
>> Smalltalk no reads
>>
>>asString
>>  "What should #($a $b $c) do?
>>  - Blue Book, Inside Smalltalk, Apple Smalltalk-80:
>>there is no #asString.
>>  - ANSI, VW, Dolphin, CSOM:
>>#asString is defined on characters and strings
>>(and things like file names and URIs that are sort of
>strings),
>>so expect an error report.
>>  - VisualAge Smalltalk:
>>'($a $b $c)'
>>  - Squeak and Pharo:
>>'#($a $b $c)'
>>  - GNU Smalltalk, Smalltalk/X, and astc:
>>'abc'
>>   I don't intend any gratuitous incompatibility, but when there
>>   is no consensus to be compatible with, one must pick something,
>>   and this seems most useful.
>>  "
>>  ^String withAll: self
>>
>> Does anyone here know WHY Squeak and Pharo do what they do here?
>>
>>
>> Oops I did not see the quotes on my screen..
>>
>> #( a b c) asString
>> >>> '#(#a #b #c)’
>>
>> this is unclear to me why this is not good but I have no strong
>opinion
>> that this is good.
>>
>> I worked on printString for literals because I wanted to have
>> self evaluating properties for basic literal like in Scheme and
>others.
>> where
>> #t
>> >>>
>> #t
>>
>> And I payed attention that we get the same for literal arrays.
>> Now the conversion is open to me.
>>
>> #($a $b $c) asString
>> >>>
>> '#($a $b $c)’
>>
>> In fact I do not really understand why a string
>>
>> #($a $b $c) asString would be '(a b c)’
>> and its use
>> if this is to nicely display in the ui I would have
>> displayString doing it.
>>
>> S.
>>
>>
>>
>> On Wed, 6 May 2020 at 01:20, Richard O'Keefe 
>wrote:
>>
>>
>> The irony is that the code I was responding to ISN'T obviously
>correct.
>> Indeed, I found it rather puzzling.
>> The problem specification says that the input string may contain
>digits
>> AND SPACES.  The original message includes this:
>>
>> Strings of length 1 or less are not valid. Spaces are allowed in the
>> input, but they should be stripped before checking. All other
>> non-digit characters are disallowed.
>>
>> Now it isn't clear what "disallowed" means.  I took it to mean "may
>occur and
>> should simply mean the input is rejected as invalid."  Perhaps "may
>not occur"
>> was the intention.  So we shall not quibble about such characters.
>>
>> But I can't for the life of me figure out how Trygve's code checks
>for spaces.
>> One reason this is an issue is that the behaviour of #digitValue is
>not
>> consistent between systems.
>>  Character space digitValue
>>does not exist in the ANSI standard
>>answers -1 in many Smalltalks (which is a pain)
>>answers a positive integer that can't be mistake for a digit in my
>Smalltalk
>>raises an exception in some Smalltalks.
>>
>> This is a comment I now have in my Smalltalk library for #digitValue
>>  "This is in the Blue Book, but unspecified on non-digits.
>>   Squeak, Pharo, Dolphin, VW, VAST, and Apple Smalltalk-80
>>   answer -1 for characters that are not digits (or ASCII
>letters),
>>   which is unfortunate but consistent with Inside Smalltalk
>>   which specifies this result for non-digits.
>>   ST/X and GST raise an exception which is worse.
>>   Digitalk ST/V documentation doesn't specify the result.
>>   This selector is *much* easier to use safely if it
>>   returns a 'large' (>= 36) value for non-digits."
>>
>> Let's compare three versions, the two I compared last time,
>> and the "version A" code I discussed before, which to my 

Re: [Pharo-users] mentor question 4

2020-05-02 Thread Richard Sargent
On Sat, May 2, 2020 at 12:38 PM Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Op 2-5-2020 om 21:09 schreef Roelof Wobben via Pharo-users:
>
>
> but this seems to work :
>
> cardNumber := '4539 1488 0343 6467'.
> cleanDigits := cardNumber copyWithout: Character space.
> preWrapDigits := (cleanDigits asArray reverse collectWithIndex: [ :char
> :idx | (idx even) ifTrue: [ 2 * char digitValue ] ifFalse:[char
> digitValue]]).
> wrappedDigits :=  preWrapDigits collect: [ :d | d > 9 ifFalse: [ d ]
> ifTrue: [ d-9 ] ].
> ^ wrappedDigits sum isDivisibleBy: 10.
>
> Can the code be more improved ?
>

As a general guideline, the best code will correspond closely to the
documented algorithm.

In this latest example, you have two visible loop iterations plus to hidden
loop iterations. It also includes object creation from both #asArray and
#reverse, the two messages with the hidden loop iteration.

For this exercise, the number of loops and object creations isn't relevant.
However, you always want to understand when you are doing such things. They
will have an impact if they are used inside a high frequency loop. Again,
that's not the case with this exercise. It often is in real world
applications.

But again, you should not optimize for performance at the expense of
clarity and readability until you need to. And when you do need to, you
annotate the code to explain how the implementation corresponds to or
differs from the more comprehensible implementation. (Comments should
explain the why and/or the background rather than the what.)



> Roelof
>
>
>


Re: [Pharo-users] mentor question 4

2020-05-02 Thread Richard Sargent
It's a good solution.

On Sat, May 2, 2020, 00:52 Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Op 1-5-2020 om 08:35 schreef Roelof Wobben:
> > Op 1-5-2020 om 02:51 schreef Richard O'Keefe:
> >> (oddSum + evenSum) dividedBy: 10
> >>
> >> You previously had _ isDivisibleBy: 10
> >> which certainly works.
> >>
> >> Squeak, Pharo, and ST/X have #isDivisibleBy:
> >> VisualWorks. Dolphin, and GNU Smalltalk do not.
> >>
> >> Here's the code from Number.st in ST/X.
> >> isDivisibleBy:aNumber
> >>  "return true, if the receiver can be divided by the argument,
> >> aNumber without a remainder.
> >>   Notice, that the result is only worth trusting, if the receiver
> >> is an integer."
> >>
> >>  aNumber = 0 ifTrue: [^ false].
> >>  aNumber isInteger ifFalse: [^ false].
> >>  ^ (self \\ aNumber) = 0
> >>
> >> The comment is wrong: the question makes sense for any combination
> >> of exact numbers.
> >> When, as in this case, aNumber is a literal integer, all
> >> #isDivisibleBy: really adds is overhead.
> >>
> >> (oddSum + evenSum) \\ 10 = 0
> >>
> >> is quite clear, and completely portable.
> >>
> >>
> >>
> >> On Fri, 1 May 2020 at 02:16, Roelof Wobben  wrote:
> >>> Op 30-4-2020 om 16:06 schreef Richard O'Keefe:
>  This sounds very much like the Luhn test task at RosettaCode.
>  https://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers
>  except that there it is described as working on the digits of an
>  integer.
> 
>  (1) There are two approaches to traversing a sequence in reverse.
>    (A) Reverse the sequence, then traverse the copy forward.
>    aString reverse do: [:each | ...]
>    (B) Just traverse the sequence in reverse
>    aString reverseDo: [:each | ...]
>    My taste is for the second.
> 
>  (2) There are two approaches to deleting spaces.
>    (A) Make a copy of the string without spaces.
>    x := aString reject: [:each | each = Character space].
>    x do: ...
>    (B) Ignore spaces as you go:
>    (i) aString do: [:each | each = Character space ifFalse:
>  [...]]
>    (ii) aString select: [:each | each ~= Character space]
>  thenDo:
>  [:each | ...]
> 
>  Combining (1A) and (2A) you get very obvious code:
>    (aString reject: [:each | each = Character space]) reverse do:
>  [:digit } ...]
>  Combining (1B) and (2Bi) you get more efficient code:
>    aString reverseDo: [:digit |
>    digit = Character space ifFalse: [ ...]]
> 
>  By the way, let's start by checking that the character in the
>  string *are*
>  digits or spaces:
>    (aString allSatisfy: [:each | each isDigit or: [each =
>  Character s[ace]])
>    ifFalse: [^false],
> 
>  (3) There are two approaches to doubling the even digits.
>    (A) Make a new string that starts as a copy and change every
>  second
> digit from the right.
>    (B) Simply *act* as if this has been done; keep track of
>  whether the
>    current digit position is even or odd and multiply by 1
>  or 2 as
>    appropriate.
>    nextIsOdd := true.
>    aString reverseDo: [:digit |
>    digit = Character space ifFalse: [
>    nextIsOdd
>    ifTrue:  [oddSum := ...]
>    ifFalse: [evenSum := ...].
>    nextIsOdd := nextIsOdd not]].
> 
>  I *like* code that traverses a data structure exactly once and
>  allocates no intermediate garbage, so I'd be making (B) choices.
> 
> 
> >>> For me  , I use this to practice solving problems  and doing the
> >>> "right"
> >>> steps.
> >>> So I love it , that so many people share there way of solving it.
> >>> I can learn a lot from it
> >>> Expecially when they explain there thinking process so detailed.
> >>>
> >>> I like this code also a lot.
> >>> Am  I correct for testing if it is a valid string by doing this ^
> >>> (oddSum + evenSum) dividedBy: 10
> >>>
> >>> Roelof
> >>>
> >
> >
> > oke,
> >
> > so this is better
> >
> > cardNumber := '8273 1232 7352 0569'.
> > oddSum := 0.
> > evenSum := 0.
> > nextIsOdd := false.
> >  cardNumber reverseDo: [:character |
> >   digit := character digitValue.
> >  character = Character space ifFalse: [
> >  nextIsOdd
> >  ifFalse:  [oddSum := oddSum + digit ]
> >  ifTrue: [(digit >= 5 )
> > ifTrue: [evenSum := evenSum + (digit * 2) - 9 ]
> > ifFalse: [ evenSum := evenSum + (digit * 2) ]].
> > nextIsOdd := nextIsOdd not]].
> > ^ evenSum + oddSum // 10 == 0.
> >
> >
> > where I could even make a seperate method of the ifTrue branch when
> > the digit is greater then 5.
> >
> >
> nobody who can say if this is a good solution ?
>
> Roelof
>
>


Re: [Pharo-users] mentor question 4

2020-04-30 Thread Richard Sargent
See below.

On Thu, Apr 30, 2020 at 10:58 AM Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> and also not with this one :
>
> cardNumber := '4539 1488 0343 6467'.
> oddSum := 0.
> evenSum := 0.
> nextIsOdd := false.
>   cardNumber reverseDo: [:digit |
>   digit = Character space ifFalse: [
>   nextIsOdd
>   ifFalse:  [oddSum := oddSum + (digit asString asInteger ) ]
>   ifTrue: [(((digit asString asInteger) * 2) > 9)
>  ifTrue: [evenSum := evenSum + ((digit asString asInteger)  * 2) - 9 ]
>  ifFalse: [ evenSum := evenSum + (digit asString asInteger)  * 2 ]].
>  nextIsOdd := nextIsOdd not]].
> ^ evenSum
>
>
>
>
> Op 30-4-2020 om 18:30 schreef Roelof Wobben:
> > Op 30-4-2020 om 16:16 schreef Roelof Wobben:
> >> nextIsOdd := true.
> >>  aString reverseDo: [:digit |
> >>  digit = Character space ifFalse: [
> >>  nextIsOdd
> >>  ifTrue:  [oddSum := ...]
> >>  ifFalse: [evenSum := ...].
> >>  nextIsOdd := nextIsOdd not]].
> >
> > hmm,
> >
> > Still no luck with this code :
> >
> > cardNumber := '4539 1488 0343 6467'.
> > oddSum := 0.
> > evenSum := 0.
> > nextIsOdd := true.
> >  cardNumber reverseDo: [:digit |
> >  digit = Character space ifFalse: [
> >  nextIsOdd
> >  ifTrue:  [oddSum := oddSum + digit asInteger ]
> >  ifFalse: [evenSum := ((digit asInteger * 2) > 9)
> > ifTrue: [evenSum + ((digit asInteger * 2) - 9) ]
> > ifFalse: [ evenSum + (digit asInteger * 2) ]].
> > nextIsOdd := nextIsOdd not]].
> > ^ oddSum + evenSum
>

With the one change to use #digitValue instead of #asInteger (which answers
the code point), the above example  works.

| evenSum oddSum |
cardNumber := '4539 1488 0343 6467'.
oddSum := evenSum := 0.
nextIsOdd := true.
cardNumber reverseDo: [:digit |
digit = Character space ifFalse: [
nextIsOdd
ifTrue:  [oddSum := oddSum + digit digitValue ]
ifFalse: [evenSum := ((digit digitValue * 2) > 9)
ifTrue: [evenSum + ((digit digitValue * 2) - 9) ]
ifFalse: [ evenSum + (digit digitValue * 2) ]].
nextIsOdd := nextIsOdd not]].
^ oddSum + evenSum
gives me 80 for the answer.

A few (mostly) minor points:
- I don't see why "reverse" is necessary. Of course if you use #do:,
nextIsOdd needs to start with true.
- repeating the "digit digitValue" or other variations adds clutter and
reduces clarity
-  ((digit digitValue * 2) - 9) is not unreasonable, but could be
simplified. What is the largest integer X such that 2xX<=9?


>
> > the answer schould be 57 where I get 1157
> >
> > So some debugging to do
> >
>
>
>


Re: [Pharo-users] mentor question 3 is there a formula for this

2020-04-29 Thread Richard Sargent
On Wed, Apr 29, 2020 at 11:30 AM Roelof Wobben  wrote:

> Am I right here or terrible wrong ?
>

If you are referring to calculating the size of the square, you are correct.


> Roelof
>
>
>
> Op 28-4-2020 om 20:53 schreef Roelof Wobben:
>
> Thanks,
>
> And the 5 can also be calculated by   2 * (char - $a)  + 1
>
> Roelof
>
>
>
> Op 28-4-2020 om 18:31 schreef Richard Sargent:
>
> Formula? Well, it's pretty straight forward.
>
> Let's start with the size of the diamond (it field, actually). In the
> example, there are two lines above and two lines below the "C" line.
> C-A = 2. This number looks useful.
> The dimension is 2+1+2 square.
>
> Yes. That is what I wrote.

>
> How many spaces before a letter? C-letter i.e. C-A = 2 C-B = 1 and C-C = 0
> The same number of spaces after the second/last occurrence of the letter
> on the line.
> The number of spaces between the letters on a line is the size minus the
> number of spaces before and after plus the two copies of the current line's
> letter. For the "B" line, there is one space before and after, 2x"B",
> leaving 5 - 1 -1 - 2 = 1 space between. For the "A" line, the simple
> arithmetic would give you -1, which also confirms that just one "A" is
> appropriate with no space between first and last letter on the line. (For
> "A", it is first and last, once only.)
>
> After that, you just need to iterate ($A to: $C), ($(C-1) to: $A by: -1)
> and do the arithmetic.
>
>
> On Tue, Apr 28, 2020 at 1:23 AM Roelof Wobben via Pharo-users <
> pharo-users@lists.pharo.org> wrote:
>
>> Hello,
>>
>> I try now to solve this one :
>>
>> ntroduction
>>
>> The diamond kata takes as its input a letter, and outputs it in a diamond
>> shape. Given a letter, it prints a diamond starting with 'A', with the
>> supplied letter at the widest point.
>> Requirements
>>
>>- The first row contains one 'A'.
>>- The last row contains one 'A'.
>>- All rows, except the first and last, have exactly two identical
>>letters.
>>- All rows have as many trailing spaces as leading spaces. (This
>>might be 0).
>>- The diamond is horizontally symmetric.
>>- The diamond is vertically symmetric.
>>- The diamond has a square shape (width equals height).
>>- The letters form a diamond shape.
>>- The top half has the letters in ascending order.
>>- The bottom half has the letters in descending order.
>>- The four corners (containing the spaces) are triangles.
>>
>> Examples
>>
>> In the following examples, spaces are indicated by · characters.
>>
>> Diamond for letter 'A':
>>
>> A
>>
>> Diamond for letter 'C':
>>
>> ··A··
>> ·B·B·
>> C···C
>> ·B·B·
>> ··A··
>>
>>
>> I noticed that if you take a quarter of it. you see this pattern
>>
>> 001
>> 010
>> 100
>>
>> where a 0 is a space and a 1 is the character.
>>
>> Is there a easy way to make some sort of formula so I can make a output of 
>> this ?
>>
>>
>> Roelof
>>
>>
>>
>
>


Re: [Pharo-users] mentor question 3 is there a formula for this

2020-04-28 Thread Richard Sargent
Formula? Well, it's pretty straight forward.

Let's start with the size of the diamond (it field, actually). In the
example, there are two lines above and two lines below the "C" line.
C-A = 2. This number looks useful.
The dimension is 2+1+2 square.

How many spaces before a letter? C-letter i.e. C-A = 2 C-B = 1 and C-C = 0
The same number of spaces after the second/last occurrence of the letter on
the line.
The number of spaces between the letters on a line is the size minus the
number of spaces before and after plus the two copies of the current line's
letter. For the "B" line, there is one space before and after, 2x"B",
leaving 5 - 1 -1 - 2 = 1 space between. For the "A" line, the simple
arithmetic would give you -1, which also confirms that just one "A" is
appropriate with no space between first and last letter on the line. (For
"A", it is first and last, once only.)

After that, you just need to iterate ($A to: $C), ($(C-1) to: $A by: -1)
and do the arithmetic.


On Tue, Apr 28, 2020 at 1:23 AM Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Hello,
>
> I try now to solve this one :
>
> ntroduction
>
> The diamond kata takes as its input a letter, and outputs it in a diamond
> shape. Given a letter, it prints a diamond starting with 'A', with the
> supplied letter at the widest point.
> Requirements
>
>- The first row contains one 'A'.
>- The last row contains one 'A'.
>- All rows, except the first and last, have exactly two identical
>letters.
>- All rows have as many trailing spaces as leading spaces. (This might
>be 0).
>- The diamond is horizontally symmetric.
>- The diamond is vertically symmetric.
>- The diamond has a square shape (width equals height).
>- The letters form a diamond shape.
>- The top half has the letters in ascending order.
>- The bottom half has the letters in descending order.
>- The four corners (containing the spaces) are triangles.
>
> Examples
>
> In the following examples, spaces are indicated by · characters.
>
> Diamond for letter 'A':
>
> A
>
> Diamond for letter 'C':
>
> ··A··
> ·B·B·
> C···C
> ·B·B·
> ··A··
>
>
> I noticed that if you take a quarter of it. you see this pattern
>
> 001
> 010
> 100
>
> where a 0 is a space and a 1 is the character.
>
> Is there a easy way to make some sort of formula so I can make a output of 
> this ?
>
>
> Roelof
>
>
>


Re: [Pharo-users] how can I test this

2020-04-27 Thread Richard Sargent
On Mon, Apr 27, 2020 at 9:30 AM Roelof Wobben  wrote:

> Op 27-4-2020 om 18:28 schreef Richard Sargent:
>
> On Mon, Apr 27, 2020 at 1:56 AM Roelof Wobben via Pharo-users <
> pharo-users@lists.pharo.org> wrote:
>
>> Hello,
>>
>> I have to test the server which should return the string but then in
>> uppercase.
>>
>> So far I have this :
>>
>> https://github.com/RoelofWobben/Network-simulator/blob/master/src/NetworkSimulator-Tests/KANetworkTest.class.st#L79
>>
>> but I fail to see how I can test that the package sending back is a
>> uppercase string.
>>
>
> I think you need to rephrase this question. Either the String class
> hierarchy has a method named something like #isUppercase or Character does.
> If only Character has it, you would need to iterate over the received
> string testing each individual character.
>
> Or is your question more about getting the response back to the sending
> node?
>
>
> yep, I want to test if the response back to the sending node is the same
> string as the sending node is but then all uppercased.
>

Assuming you have the code written that sends a request packet to a server,
then makes the server process it and send a response packet back to the
original node, the following pseudo-code should show you one way.

| requestPacket responsePacket |
requestPacket := ...
... send the request and get a response back ...
responsePacket := self sendingNode nextReceivedPacket.

self assert: responsePacket payload isUppercase description: 'Response
should have been uppercase'.
self assert: (requestPacket payload equals: responsePacket payload
ignoreCase: true) description: 'Response is not the same string'.

Those methods probably exist in Pharo, or something very similar. e.g. it
might be #equalsIgnoreCase:.


> Roelof
>
>


Re: [Pharo-users] can I divide a string into part of exactly n length

2020-04-27 Thread Richard Sargent
On Mon, Apr 27, 2020 at 9:27 AM Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Hello,
>
> I wonder if it is possible in Pharo to divide a string in lets say part
> of 3.
> so this :  'abcdefgh'
>
> would be  'abc def gh`
>

Do you really want a single string with spaces inserted or do you want a
collection of substrings, each three characters (or less, for the last one)?



> Regards,
>
> Roelof
>
>
>


Re: [Pharo-users] mentor question 2.

2020-04-27 Thread Richard Sargent
On Sun, Apr 26, 2020 at 10:11 AM Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Hello,
>
> I have to make some code that convert a binary to a decimal and im not
> allowed to use the convert methods that Pharo has.
>
> So I have written this :
>
>
> decimalFromBinary: aString
>  | result isValid |
>  isValid = self isValidBinary: aString.
>  isValid
>  ifTrue: [ result := 0.
>  aString reverse
>  withIndexDo:
>  [ :digit :index | result := result + (digit
> digitValue * (2 raisedTo: index - 1)) ].
>  ^ result ]
>  ifFalse: [ ^ nil ]
>
> isValidBinary: aString
>  ^ aString allSatisfy: [ :c | c = 0 or: [ c = 1 ] ]
>

Others have answered your question, so I'll limit my response to other
aspects of this exercise.

Answering nil is a bad practice, in general. There will be occasions where
it is correct, if non-existence really is part of the model. Answering nil
may have been a requirement of the exercise and if that's the case, you
have no choice. By answering nil, you force every sender to check for nil
rather than being able to rely on receiving an Integer result. Even with
method selectors that tell the reader a nil can be the result, too many
people will fail to check the result before using it. In general, I prefer
to have the validation throw an exception.
e.g.
validateBinaryString: aString
(aString allSatisfy: [:each | '01' includes: each])
ifFalse: [self error: aString printString, ' is not a valid
representation of a binary number'].

The method simply returns self if it succeeds or throws an exception is the
string is invalid. And likewise, the conversion method itself only answers
the integer corresponding to a valid binary string and does not answer
(anything) for an invlaid one.


There is another pattern that could be used, but this particular problem
seems (to me) best suited to an exception. A common pattern in Smalltalk,
one of its greatest innovations, is the #ifAbsent: keyword and others like
it. When you send #at:ifAbsent:, *you* tell the receiver to give you what
you ask for *and* you tell it what *you* want to do if it cannot. There are
infinitely many possible keywords like #ifAbsent:, as you can make up any
one that suits your needs.

If you look at the implementation of #at: or #detect:, you will see that
they are implemented using #at:ifAbsent: and #detect:ifNone: and that the
block provided for the second argument is one which throws an error. Given
all that, perhaps the "best" implementation of your solution would be to
have "decimalFromBinary: aString" implemented in terms of a
"decimalFromBinary: aString ifUnable: aBlock".


>
> but on the first method I see a message that the temp variables are read
> before written.
> and the second one I see a message that I use a or instead of searching
> literals.
>
> Where did  I think wrong here ?
>
> Roelof
>
>
>


Re: [Pharo-users] how can I test this

2020-04-27 Thread Richard Sargent
On Mon, Apr 27, 2020 at 1:56 AM Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Hello,
>
> I have to test the server which should return the string but then in
> uppercase.
>
> So far I have this :
>
> https://github.com/RoelofWobben/Network-simulator/blob/master/src/NetworkSimulator-Tests/KANetworkTest.class.st#L79
>
> but I fail to see how I can test that the package sending back is a
> uppercase string.
>

I think you need to rephrase this question. Either the String class
hierarchy has a method named something like #isUppercase or Character does.
If only Character has it, you would need to iterate over the received
string testing each individual character.

Or is your question more about getting the response back to the sending
node?


> Regards,
>
> Roelof
>
>
>
>
>


Re: [Pharo-users] mentor question 1

2020-04-25 Thread Richard Sargent
On Sat, Apr 25, 2020, 16:17 tbrunz  wrote:

> Richard,
>
> I don't think it was silly.  I'm sitting here thinking to myself, "Wow,
> that's creative...  Pharo being Pharo, you can write applications that can
> send *blocks* between nodes, not just *data*..."
>

I understand. I meant that in the world this exercise models (separate
compute nodes connected by a network), the single god-like Pharo
application doesn't exist and sending blocks is harder. (Although,
GemStone/S does make it simple, at least if all the nodes are connected to
the GemStone/S database.)



> The concept of sending behaviors as well as data opens up some interesting
> and powerful possibilities for applications!  (Yet another way ST is
> superior to other languages.)
>

Absolutely! It took a long time to *really* internalize the idea of
everything is an object. Once I grokked that, it became easy to think that
way all the time.



> -Ted
>
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] mentor question 1

2020-04-25 Thread Richard Sargent
On Sat, Apr 25, 2020, 15:50 tbrunz  wrote:

> Hi Richard,
>
> I looked the repo; he's defined 3 classes: one for packets, one for nodes,
> and one for links.  So yes, he instantiates links.  Likely each node has a
> collection of links (each of which leads to another node in the network).
> The application is to simulate a network by modeling it in ST, so that
> means
> generating packets, each with a destination node (where nodes have
> addresses), and simulating how the packets flow through the network to get
> from their source nodes to their destination nodes.
>
> I hadn't though about sending the blocks to the nodes via the packets, but
> that *is* a cool concept... And entirely do-able in Pharo.  However, if the
> exercise is to make a simple network model that runs to simulate network
> operation, I doubt that's what they're looking for, though (since it's not
> what you typically do in a packet network).  I think they just want you to
> model the packet-handling behavior, and that's what the block is for.  (I
> may be wrong.)
>

Thanks, Ted. That makes sense. I agree the problem is almost certainly not
about sending blocks. Silly of me, really. I didn't see anything in this
thread that explained the block.

I could imagine that a link object knows how to deliver a packet to the
node and the node object knows how to receive the packet. (Or something
like that)


> -Ted
>
>
>
>
>
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] mentor question 1

2020-04-25 Thread Richard Sargent
On Sat, Apr 25, 2020, 11:46 Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Op 25-4-2020 om 20:17 schreef Roelof Wobben:
> > Op 25-4-2020 om 20:04 schreef tbrunz:
> >> 1. 'loopback' is a node, just like 'source' and 'destination'.  A
> >> network is
> >> a mesh of 'nodes' joined by 'links'.  Your Pharo program represents
> >> one of
> >> those nodes: It is the 'loopback' node.
> >
> > oke, so I can do : loopback := KNetworkNode new.
> >
> >> 2. The block in the #linksTowards:do: method is the action to take on a
> >> packet, depending on whether its destination is "you" (loopback), or
> >> something else.
> >>
> >> The flood algorithm is the simplest algorithm: "If the destination is
> >> not
> >> me, send the packet to everyone else (except the one who sent it to
> >> me)."
> >
> >
> > and that part I still do not see. I "fail"  to see what the block
> > exactly is.
> >
> >> However, there is the possibility of loops in the network, so a slightly
> >> better algorithm is to check "have I seen this packet before?" and if
> >> the
> >> answer is "yes", then drop it; otherwise send it via my links. This will
> >> prevent endless packet sending loops in your network.
> >>
> >> -t
> >>
> >>
> >>
> >>
> >> --
> >> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
> >>
> >
>
>
>
> Oke,
>
> Did some thinking and see how things are working if the loopback is not
> used :
>
> linksTowards: anAddress do: aBlock
>  "Simple flood algorithm: route via all outgoing links.
> However, just loopback if the receiver node is the routing destination."
>
>  address = anAddress
>  ifTrue: [  ]
>  ifFalse: [ outgoingLinks do: aBlock ]
>
> but still I "fail"  to see what need to be done when the loopback is
> used with the block.
>

It's not clear to me if a link is an actual object in your model. I'll
respond as if it is.

aBlock is the work you want done on the destination node. So, the question
is how you get it there. You iterate through the outgoingLinks and ask the
link to deliver the block to the destination node. In "blasting", each node
sends it on through its own outgoingLinks, until it eventually reaches the
destination node.

The destination node evaluates aBlock, probably supplying itself as an
argument to the block.

In the case of a loopback, the node itself seems to be the one intended to
evaluate aBlock. (I don't know the problem description, so that may not be
entirely correct.)


> Roelof
>
>
>


Re: [Pharo-users] mentor wanted

2020-04-25 Thread Richard Sargent
On Fri, Apr 24, 2020, 22:25 Richard O'Keefe  wrote:

> Roelof, I don't think CRC cards or the GRASP patterns or anything like that
> addresses your immediate needs.  Based on other questions of yours it
> seems to me that your problem is not *organising* the responsibilities in
> an
> OO program, but decomposing a problem into responsibilities in the first
> place.  I think this is perhaps the most important part of programming, and
> the hardest to learn, not least because very few of us are good at teaching
> it.  We're not very good at teaching it in mathematics either.  I do not
> think
> your issues are anything to do with Pharo, Smalltalk, OOP, or programming
> as such.
>
> One symptom of the general problem that I've noticed is that I see code as
> a very fluid sort of thing where pieces can be moved around and recombined,
> while many people think of code as something solid and rather brittle.
>
> I was thinking of writing up a short description of what I was thinking
> for a
> RosettaCode example anyway.  Would that help?
>

Thank you, Richard. I appreciate your offering this. I am not a teacher, so
your help is truly appreciated!



>
>
> On Thu, 23 Apr 2020 at 23:16, Roelof Wobben via Pharo-users
>  wrote:
> >
> > Hello,
> >
> > I like Pharo a lot but I hit a wall very often.
> > With complex problems I do not see how to solve things in small steps.
> >
> > Is there somewhere who is willing to mentor me in how I can overcome
> > that problem.
> >
> > Roelof
> >
> >
>
>


Re: [Pharo-users] mentor wanted

2020-04-23 Thread Richard Sargent
On Thu, Apr 23, 2020 at 2:42 PM Roelof Wobben  wrote:

> Op 23-4-2020 om 23:00 schreef Richard Sargent:
>
> On Thu, Apr 23, 2020 at 12:14 PM Roelof Wobben  wrote:
>
>> Op 23-4-2020 om 21:09 schreef Richard Sargent:
>>
>> On Thu, Apr 23, 2020 at 12:00 PM Roelof Wobben  wrote:
>>
>>> Op 23-4-2020 om 20:52 schreef Richard Sargent:
>>>
>>> On Thu, Apr 23, 2020 at 3:32 AM Roelof Wobben via Pharo-users <
>>> pharo-users@lists.pharo.org> wrote:
>>>
>>>> Hello,
>>>>
>>>> I like Pharo a lot but I hit a wall very often.
>>>> With complex problems I do not see how to solve things in small steps.
>>>>
>>>
>>> I would be happy to help with the Smalltalk and problem analysis
>>> aspects. Unfortunately, I don't use Pharo much, so I cannot help with it.
>>>
>>>
>>>> Is there somewhere who is willing to mentor me in how I can overcome
>>>> that problem.
>>>>
>>>> Roelof
>>>>
>>>>
>>>>
>>> Pity,
>>>
>>>
>>> but if you could help me to learn how to divide a complex problem in
>>> smaller steps , then I think I can make it work in Pharo.   My problem is
>>> more that then how to do it in Pharo.
>>>
>>> Do you then use gemtalk a lot.
>>> Pity that I cannot make exercism challenges on that.
>>> And AdventOfCode do seem to difficult for a beginner.
>>>
>>
>> Yes, I can help with those areas. I've been programming professionally
>> and virtually exclusively in Smalltalk since 1991.
>>
>> I've been using GemStone/S since 2009 and now work for the manufacturer.
>> I've been working with VA Smalltalk and its predecessors since 1994 and
>> with VisualWorks since 2009.
>>
>> I hear you about using GemStone/S. For most of its life, the assumption
>> was that you would use a client Smalltalk like VA Smalltalk or VisualWorks
>> to do your development work. Although, recently we've been working on
>> Jadeite (https://github.com/GemTalk/Jadeite) to provide a development
>> environment independent of GBS (which is what we used to connect VA
>> Smalltalk and VisualWorks to GemStone/S).
>>
>>
>>> Roelof
>>>
>>>
>>
>> Oke, I have heard of it  but because I could not find a course or book
>> about gemstone and found a mooc about Pharo I choose that one.
>>
>
> Pharo is an excellent choice and the MOOC should help.
>
>
>> But is there then much difference between Pharo and Gemstone or can I
>> make a solution to a problem and use the same code for both.
>>
>
> There are many differences. Most notably, GemStone doesn't have a GUI.
> However, there are many people using what's called "Develop in Pharo,
> deploy in GemStone" with Seaside.
>
>
>> For me programming is a hobby. In the Netherlands most companies use c#
>> and with 53 and no XP I do not think its wise to  think I find a job as
>> developer.
>>
>
> It's a good hobby. I wouldn't plan on finding a job, if I were you, but
> you never know. Opportunities come along, especially if you are ready for
> one.
>
>
>> Roelof
>>
>>
> Oke,
>
> if you still wanted , it is fine with me that you mentor me.
> But I think we need to  find a way to make it work and I do not know if
> posting on the pharo ml is a good way to make it work because then we
> pollute the ML and other people can interfer.
>
> Do you have any ideas ?
> For me its fine that you send emails to my personal email.
>

Either way works for me, but I think discussing the issues on list will be
beneficial. There are a lot of other people out there who will have ideas
and different perspectives. And some of them might be able to answer your
questions more quickly than I could get to them.


> Roelof
>
>
>


Re: [Pharo-users] mentor wanted

2020-04-23 Thread Richard Sargent
On Thu, Apr 23, 2020 at 12:14 PM Roelof Wobben  wrote:

> Op 23-4-2020 om 21:09 schreef Richard Sargent:
>
> On Thu, Apr 23, 2020 at 12:00 PM Roelof Wobben  wrote:
>
>> Op 23-4-2020 om 20:52 schreef Richard Sargent:
>>
>> On Thu, Apr 23, 2020 at 3:32 AM Roelof Wobben via Pharo-users <
>> pharo-users@lists.pharo.org> wrote:
>>
>>> Hello,
>>>
>>> I like Pharo a lot but I hit a wall very often.
>>> With complex problems I do not see how to solve things in small steps.
>>>
>>
>> I would be happy to help with the Smalltalk and problem analysis aspects.
>> Unfortunately, I don't use Pharo much, so I cannot help with it.
>>
>>
>>> Is there somewhere who is willing to mentor me in how I can overcome
>>> that problem.
>>>
>>> Roelof
>>>
>>>
>>>
>> Pity,
>>
>>
>> but if you could help me to learn how to divide a complex problem in
>> smaller steps , then I think I can make it work in Pharo.   My problem is
>> more that then how to do it in Pharo.
>>
>> Do you then use gemtalk a lot.
>> Pity that I cannot make exercism challenges on that.
>> And AdventOfCode do seem to difficult for a beginner.
>>
>
> Yes, I can help with those areas. I've been programming professionally and
> virtually exclusively in Smalltalk since 1991.
>
> I've been using GemStone/S since 2009 and now work for the manufacturer.
> I've been working with VA Smalltalk and its predecessors since 1994 and
> with VisualWorks since 2009.
>
> I hear you about using GemStone/S. For most of its life, the assumption
> was that you would use a client Smalltalk like VA Smalltalk or VisualWorks
> to do your development work. Although, recently we've been working on
> Jadeite (https://github.com/GemTalk/Jadeite) to provide a development
> environment independent of GBS (which is what we used to connect VA
> Smalltalk and VisualWorks to GemStone/S).
>
>
>> Roelof
>>
>>
>
> Oke, I have heard of it  but because I could not find a course or book
> about gemstone and found a mooc about Pharo I choose that one.
>

Pharo is an excellent choice and the MOOC should help.


> But is there then much difference between Pharo and Gemstone or can I make
> a solution to a problem and use the same code for both.
>

There are many differences. Most notably, GemStone doesn't have a GUI.
However, there are many people using what's called "Develop in Pharo,
deploy in GemStone" with Seaside.


> For me programming is a hobby. In the Netherlands most companies use c#
> and with 53 and no XP I do not think its wise to  think I find a job as
> developer.
>

It's a good hobby. I wouldn't plan on finding a job, if I were you, but you
never know. Opportunities come along, especially if you are ready for one.


> Roelof
>
>


Re: [Pharo-users] mentor wanted

2020-04-23 Thread Richard Sargent
On Thu, Apr 23, 2020 at 12:00 PM Roelof Wobben  wrote:

> Op 23-4-2020 om 20:52 schreef Richard Sargent:
>
> On Thu, Apr 23, 2020 at 3:32 AM Roelof Wobben via Pharo-users <
> pharo-users@lists.pharo.org> wrote:
>
>> Hello,
>>
>> I like Pharo a lot but I hit a wall very often.
>> With complex problems I do not see how to solve things in small steps.
>>
>
> I would be happy to help with the Smalltalk and problem analysis aspects.
> Unfortunately, I don't use Pharo much, so I cannot help with it.
>
>
>> Is there somewhere who is willing to mentor me in how I can overcome
>> that problem.
>>
>> Roelof
>>
>>
>>
> Pity,
>
>
> but if you could help me to learn how to divide a complex problem in
> smaller steps , then I think I can make it work in Pharo.   My problem is
> more that then how to do it in Pharo.
>
> Do you then use gemtalk a lot.
> Pity that I cannot make exercism challenges on that.
> And AdventOfCode do seem to difficult for a beginner.
>

Yes, I can help with those areas. I've been programming professionally and
virtually exclusively in Smalltalk since 1991.

I've been using GemStone/S since 2009 and now work for the manufacturer.
I've been working with VA Smalltalk and its predecessors since 1994 and
with VisualWorks since 2009.

I hear you about using GemStone/S. For most of its life, the assumption was
that you would use a client Smalltalk like VA Smalltalk or VisualWorks to
do your development work. Although, recently we've been working on Jadeite (
https://github.com/GemTalk/Jadeite) to provide a development environment
independent of GBS (which is what we used to connect VA Smalltalk and
VisualWorks to GemStone/S).


> Roelof
>
>


Re: [Pharo-users] mentor wanted

2020-04-23 Thread Richard Sargent
On Thu, Apr 23, 2020 at 3:32 AM Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Hello,
>
> I like Pharo a lot but I hit a wall very often.
> With complex problems I do not see how to solve things in small steps.
>

I would be happy to help with the Smalltalk and problem analysis aspects.
Unfortunately, I don't use Pharo much, so I cannot help with it.


> Is there somewhere who is willing to mentor me in how I can overcome
> that problem.
>
> Roelof
>
>
>


Re: [Pharo-users] Ballooning image size! Approaching 400MB

2020-04-01 Thread Richard Sargent
On Wed, Apr 1, 2020 at 11:17 AM Sven Van Caekenberghe  wrote:

> Hi Russ,
>
> That is great to hear.
>
> I wanted to add that Pharo has automatic memory management and there is
> normally no need for doing anything manually (like nilling out instance
> variables let alone ugly become hacks).
>
> Your model looks pretty harmless, even with cycles there should be no
> problems.
>
> All this does not mean that you cannot (by accident maybe) make mistakes
> and keep global references to your larger model that prevents it from being
> garbage collected.
>
> Typically, fixing the one culprit solves all your problems. The trick is
> finding it ;-)
>
> Sven
>
> > On 1 Apr 2020, at 20:04, Russ Whaley  wrote:
> >
> > Okay!  I made some additional changes to my app/presenter/model so that
> I'm doing this:
> >
> > MyApp>>start
> > | model pres |
> > model := MyModel loadData.
> > pres := MyPresenterWithModel newApplication: self with: model.
> > pres openWithSpec.
> >
> > I changed my code in Presenter to reference the model - and it pops
> right up!  When I close the GUI, GC and check for errant object
> instances... NONE!!  I can open the UI over and over and my object
> instances stay at zero.
> >
> > So it feels like I'm on the right track.
> >
> > I still need a bunch of work/learning around the App/Presenter/Model
> interactions... so if anyone can point me to a good tutorial on this,
> including changing data and UI widgets - I'd greatly appreciate it.
> >
> > Thanks to all on this issue!
> >
> > Russ
> >
> >
> > On Wed, Apr 1, 2020 at 12:14 PM Russ Whaley 
> wrote:
> > Tim,
> > Thanks for the reply!  When I eliminated (with your become: solution),
> it did not a small chunk of the objects instances off.  Another 'holder' of
> object instances accounted for another slug.  But things still were not
> dropping like I hoped (this is without just setting everything to strings -
> but doing so systematically by object to perhaps see what was holding on to
> things).  Finally I got things down to a few objects with instances in the
> hundreds and thousands - instead of 50,000 and 400,000 - and I finally set
> everything to String new.  Interestingly enough, after garbage collection,
> when I do String instanceCount - I get 0 (zero) instances.
> >
> > All that - and thank you again - I closed all the system browsers,
> checked playground to delete bindings, I did a bunch of garbageCollection
> runs, did a System>Do Image Cleanup... then did a Save As.
> >
> > And... it is 8MB bigger than before I did all this cleanup.  My image
> was 346MB and grew to 354MB AFTER the cleanup.  Go figure.  Maybe it will
> automagically GC sometime.
> >
> > I'm looking into what you and Sven mentioned - the pointersTo - I'm
> trying to figure out how to use it.
> >
> > A couple of basic questions...
> >   • I thought tempVariables, inside a method were automatically
> destroyed when the method terminated?
> >   • If I pass an object (either a parm or tempVariable) that resides
> in that message to another message, since I'm passing the actual object - I
> curious how it ever gets GC'd.
>

Russ,

I didn't see anyone really answer these two points. It is important to
understand that a variable, whether temporary or instance, is a holder of a
reference to an object. It's not the object, per se. So, yes, when that
method exits, the temporary variable on the stack frame is dropped,
effectively eliminating the reference its temporary variable held. That
formerly referenced object will be garbage collected when the automatic
garbage collection finds it has no reachable references to it at all.

"reachable" is the key to GC. If traversing the VM's object graph, the
garbage collector cannot reach an object, then it is garbage, even if it
has a million references (from other also unreachable objects). Things are
slightly complicated by the notion of a weak reference. The garbage
collector doesn't follow a weak reference, so if an object is only
reachable via weak references, it is considered unreachable and can be
collected.


>   • All my ObjectTest classes create their own data to work with - I
> have the creation in centralized messages, but they return 'fresh' data for
> each test.  Whatever the answer is in the first 2 bullet points, this could
> be a contributor to the volume.
> > I'm running some tests of the GUI after clearing out all the Object
> instances... and I'm seeing the growth as expected... it just doesn't go
> away when I close the GUI window.  I'm not using SpApp correctly, nor am I
> using SpPresenter correctly (I'm forcing my model data into an SpPresenter
> instVar (via the SpApp start) so the presenter can use my data.  This is
> all wrong but I'm struggling finding good examples in Spec2 of how to get
> these to work together.
> >
> > Thanks for the info - your suggestions have been very helpful!
> > Russ
> >
> > On Wed, Apr 1, 2020 at 2:43 AM Tim Mackinnon  wrote:
> > Hi Russ - a quick look at your stats 

Re: [Pharo-users] Ballooning image size! Approaching 400MB

2020-04-01 Thread Richard Sargent
On Wed, Apr 1, 2020, 01:30 Tim Mackinnon  wrote:

> Yeah, I was taught (and it may be out of date), that as become: is a 2 way
> operation the identity of nil (as a singleton) would get swizzled, so it
> was safer to create a simple new object that could be easily gc’d (that’s
> what I vaguely recall anyway). (This was in early VA from the OTI guys, but
> maybe that gets handled better in modern VA, as I think become: is two way
> in VA right?)
>

VA become: is one way. You can use multiBecome: to have a two way become:.
I don't have the details to hand.


> Tim
>
> On 1 Apr 2020, at 08:11, jtuc...@objektfabrik.de wrote:
>
> Tim,
>
> out of curiosity: why do you suggest to create hundreds of thousands of
> Strings instead of become: nil?
>
> Does Pharo do two-way become: ?
> I'be been nilling instances for a little over 2 decades in VAST so far and
> never had any troubles with it...
>
> Other than that: the become: nil (or String new as you suggest) thing was
> the first that came to my mind for the intermediate solution as well. Of
> course that doesn't fix the code which doesn't dispose of the objects in
> the UI or model...
>
>
> Joachim
>
>
>
>
> Am 01.04.20 um 08:42 schrieb Tim Mackinnon:
>
> Hi Russ - a quick look at your stats seems to indicate that something is
> holding on to your model, I didn’t understand the first object growing by
> 2, but the second increases by 1 each time, and it looks like some form of
> root object holding on  to the others ? This of course means the GC can’t
> reclaim the chain of objects if something is holding on to that root
> globally.
>
> Assigning something in the playground will hold onto it (I believe) so you
> can continue to reuse and inspect it - so that’s expected, but this looks
> like something in your UI?
>
> You can break the chain manually (but it’s not a full solution), simply
> iterate over your root and become: String new (Save your image before doing
> it and see if it works to free up the cycles). Eg try something like this
> (haven’t tried this in Pharo myself, but worked in VA, so it should work
> here)
>
> MyRootModel allInstances do: [ :m | m become: String new ]
>
> If this works and reduces your memory usage, you now need to inspect one
> of those MyRootModel instances and see who is referencing it, and explain
> why. This is Sven’s pointerTo explanation.
>
> For roots, you sometimes can use a WeakDictionary so that when nothing is
> referencing them, they get gc’d if you are doing some caching or have some
> factory concept.
>
> It’s not uncommon to hit this when you get your system nearing completion
> , it’s the downside of not having to worry about memory referencing -
> ultimately you have to worry about it at the edges.
>
> It is possible there is a Pharo bug, as over time I see large Pharo images
> but I was just messing around and put it down to failed experiments.
>
> Hope this helps.
>
> Tim
>
> On 31 Mar 2020, at 20:47, Russ Whaley 
>  wrote:
>
> 
> Here is some additional data - attached - I checked the number of
> instances on select Classes before a UI load, during the UI load and after
> the UI load (and again).  The class instances grow as expected, but do no
> release.  I'm doing something wrong.  I'm going to try a fresh image next,
> however, I expect the same thing to happen, just starting over at zero.
>
>
>
> On Tue, Mar 31, 2020 at 12:57 PM Russ Whaley 
> wrote:
>
>> Dario,
>> Thanks for the reply!
>>
>> When I closed my image - after running that huge query and leaving it in
>> an inspector... my image grew to 1.3GB, lol.
>>
>> When I closed the inspector, and all the class browsers, did the garbage
>> collection, etc., it dropped back to 384MB.  Still huge, and all my Class
>> instances are still there.  I'm getting ready to also drop my Playground -
>> after I copy all the code snippets out and see if that has any impact.  I'm
>> also going to try a fresh image and see if there is the same growth pattern
>> as here.
>>
>> Perhaps I'm doing something wrong with the way I'm creating and storing
>> my object instances - which is generally Class new, fill out some
>> attributes, then add it to a collection or Dictionary.
>>
>> All my Object tests create sample data (objects) - over and over as well.
>>
>>
>> On Tue, Mar 31, 2020 at 12:20 PM dario.trussardi65 <
>> dario.trussard...@gmail.com> wrote:
>>
>>> Ciao,
>>>
>>>
>>> > My image size keeps growing and growing.  I've been scouring Google
>>> and mailing lists, trying to find a solution.
>>>
>>> i have the same problem with a Pharo 7 image.
>>>
>>> Maybe it has nothing to do.
>>>
>>> But after close all the class browser windows the image save
>>> return to a " valid " size.
>>>
>>> Dario
>>>
>>
>>
>> --
>> Russ Whaley
>> whaley.r...@gmail.com
>>
>
>
> --
> Russ Whaley
> whaley.r...@gmail.com
> 
>
>
> --
> ---
> Objektfabrik Joachim Tuchel  

Re: [Pharo-users] Ballooning image size! Approaching 400MB

2020-03-31 Thread Richard Sargent
On Tue, Mar 31, 2020 at 9:25 AM Russ Whaley  wrote:

> Sven,
> Thanks for the reply :)
>
> I will try to move my code over to another image (I'm not very good with
> GitHub - we'll see how this goes).
>
> But it just seems like there ought to be a way to at least delete all of
> these instances - as they are pretty easy to get ahold of (Class
> allInstancesDo:).  But I can't find a way to delete them.  I can count
> them, I can display content - attached is a screenshot showing for each
> Album instance, I can display it and data from it's embedded Artist and
> collection of Tracks.
>

Russ, this kind of thing is a common occurrence in Smalltalk GUI
applications. In my experience, it is often dangling dependencies resulting
in things being held. The reference in question might be to the model
itself or to some particular subset which also happens to include a back
reference to the whole model. These dependencies typically are installed as
event handlers in the GUI. It's common to establish a dependency but fail
to release it.

In your first message, you listed the major classes of your model. Get the
object counts for each. Close the application UI (not Pharo) and re-open
it. Run the counts again. You will probably see the root model instance
count increase by one.

I don't work with Pharo, so I cannot give you specific guidance for
tracking these down. I'm certain others can explain GUI dependencies and
dangling references in the Pharo environment, to give you more focussed
guidance.



> Attached are a couple of screen shots of the 'query' I mentioned in my
> previous note... as you can see - Tracks, Albums, (FileReference is my
> fault, also - I use those to hand music files to my objects for processing.
> Those are hanging around as well).
>
> On Tue, Mar 31, 2020 at 11:13 AM Sven Van Caekenberghe 
> wrote:
>
>> Hi Russ,
>>
>> It is quite hard to debug somebody else's application, especially without
>> access to the code, but here are some suggestions of what I would do.
>>
>> Can you move your code to a new/fresh image and see what happens there
>> (especially after just one iteration of loading your data) ?
>>
>> Is there a difference between loading your data and opening your app with
>> respect to the retention of garbage ? This would help to determine if this
>> is a UI problem or a domain model problem.
>>
>> There are tools that help you to figure out who holds a specific object
>> ('Reverse pointers to' in the Inspector) but these are not so easy to use
>> (you get lots of data).
>>
>> Sven
>>
>> > On 31 Mar 2020, at 16:55, Russ Whaley  wrote:
>> >
>> > My image size keeps growing and growing.  I've been scouring Google and
>> mailing lists, trying to find a solution.
>> >
>> > Observables:
>> >   • Running this 'query' shows I have a whole lot instances of
>> Objects I've created that are not "releasing". There are 65000 instances of
>> one Object/Class, and 350,000 of another.  (there are more, these are just
>> the big hitters).
>> > (Object allSubclasses collect: [ :aClass |
>> > aClass -> aClass allInstances size])
>> > sort: [ :a :b | a value > b value ].
>> >   • Each time I load my app/UI - which creates/loads another 5000
>> of one object and 25,000 of the 2nd object - my Class>>instanceCount(s)
>> keep growing and so does my image size.
>> >   • I've done:
>> >   • Smalltalk garbageCollect.
>> >   • Smalltalk garbageCollectMost.
>> >   • 10 timesRepeat: [ Smalltalk garbageCollect]. (many,
>> many times)
>> > Somehow, these instances I create are not 'releasing'.  All of my
>> Classes are direct subclasses of Object.  Interestingly enough, all these
>> objects sit in a single collection for the high-level model - and there are
>> only 67 instances of that Object... here's the hierarchy:
>> >
>> > MyTunes - instance holds a Dictionary of Libraries, rootFolder and tags
>> collection
>> > Library - instance(s) hold Dictionary of Artists & Playlists, tags
>> collection, and MyTunes reference
>> > Artist - instances hold Dictionary of Albums, and Library reference
>> > Album - instances hold Dictionary of Tracks, and Artist reference
>> > Track - instances hold TagInfo, Album reference
>> > TagInfo - instances hold fileReference and ByteString of ID3 tag info.
>> > PlayList - instances hold Dictionary of Tracks, Library reference.
>> >
>> > Here's my start code in my app... (I don't know how to use
>> SpApplication, SpPresenter and my model(s) together - this may be part of
>> the problem)..
>> >
>> > start
>> > "Override this to start your app"
>> > "*** I don't know how to use SpApplicatoin, SpPresenter and my model
>> MyTunes ***"
>> >
>> > | myTunes tmpLibrary myPres |
>> >
>> > "where do I store the model -> MyTunes?"
>> > myTunes := MyTunes new.
>> >
>> > "this is just for testing, but the actual re-load of the library takes
>> 15-20 minutes (60,000 files!)"
>> > tmpLibrary := myTunes readLibraryFromSTONfile.
>> > 

Re: [Pharo-users] [ANN] JRMPC Poll

2020-03-25 Thread Richard Sargent
On Wed, Mar 25, 2020, 08:49 horrido  wrote:

> This is what I provided the JRMPC participants: https://jrmpc.ca/ (see
> "How
> to learn Smalltalk programming"). I'm not sure how I could've done better,
> though.
>
> You make an excellent point about duplication and keeping documentation
> up-to-date. However, there has to be some middle ground that makes it
> easier
> and more convenient for new developers to find the tools they need. Perhaps
> a synoptical reference showing the more common classes used, such as
> collections, web-related classes, time-related classes, exception and error
> classes, file system-related classes, process-related classes, and so on.
> These classes ought not to change much, if at all.
>


I agree with this. So many times I have seen documentation that could be
compared to what results from throwing a plate of spaghetti (Bolognese!) at
a wall.

Usually what's lacking is the kind of information that might be called a
road map. Not so much in the sense of a set of directions, but like a real
road map or a transit system map, lays out the routes and shows the
connections between important places.

Pulling numbers out of thin air, it might be that as little as 1% of the
system details would suffice to show a novice how things fit together and
how to easily navigate the detailed information.

Like you suggest, this small fraction would be at a high enough level or of
such importance that it would be unlikely to become stale.



>
>
> Tim Mackinnon wrote
> > Or we teach people to fish…? What’s the point of duplicating everything
> > that’s already in the image anyway - we just need to be cleverer or
> ensure
> > that people know to look there and have the right onboarding experience
> to
> > do that? Otherwise its just another thing that gets out of date very
> > rapidly and we already have enough problems with that.
> >
> > I’d be interested in what intro material Richard gave the students to
> > start with (after all - he has quite a few tutorials of his own, some of
> > which I had followed - but I suspect they are out of date now
> themselves).
> > When you launch pharo there is the helpful welcome screen - did the
> > student’s actually use it and follow what it says?
> >
> > And did we see any of them in this forum (or was that against the rules?)
> >
> > Tim
> >
> >> On 24 Mar 2020, at 17:28, Ben Coman 
>
> > btc@
>
> >  wrote:
> >>
> >> Pharo has some good documentation, but its more lesson-based than a
> >> library reference.
> >> Those of us familiar with Pharo know the tricks to use the system itself
> >> as that reference, but I'd imagine this is an unfamiliar workflow for
> >> newcomers.
> >>
> >> I have seen before a class library reference generated from the image,
> >> but I couldn't put my hands on it right now.
> >> @all, is it still being generated?. This might provide newcomers
> >> something more familiar to work with.
> >>
> >> cheers -ben
> >>
> >> On Tue, 24 Mar 2020 at 03:00, Richard Kenneth Eng 
>
> > horrido.hobbies@
>
> >  mailto:
>
> > horrido.hobbies@
>
> > > wrote:
> >> https://jrmpc.ca/2020/03/20/what-makes-learning-smalltalk-challenging/
> >> 
> https://jrmpc.ca/2020/03/20/what-makes-learning-smalltalk-challenging/;
>
> >>
> >> FWIW, 95% of respondents pointed to the lack of reference documentation
> >> for the class library as the major obstacle to learning Smalltalk/Pharo.
> >>
> >> Richard
>
>
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] Slots vs collections

2020-03-20 Thread Richard Sargent
On Fri, Mar 20, 2020, 06:53 Noury Bouraqadi  wrote:

> Thanks Julien. So, what I did experienced is because BooleanSlot is work
> in progress.
> To address my issue using slots, I guess collections should implement
> asBit method (Sent by BooleanSlot).
>

Noury, when modelling something like this, think whether "all collections
should implement asBit". I've added the word all, of course. There are so
many possible collections for which #asBit wouldn't make sense that I would
conclude the hypothesis to be incorrect. Even if you were to implement it
on a single collection class, such as Array, there are still so many
examples where #asBit could not apply.

Perhaps, there could be an e.g. Bits class in the Collection hierarchy.
But, even then, it seems to me that there are so many inherited methods
that wouldn't make sense. What would be the use of #do:? What would
#select: mean? You get the idea.

An alternative possibility, and not the only one, is to model the bits as
part of an integer, small or large.

Of course, for performance, a ByteArray might be a good way to store bits.
It has the benefit that every instance *can* represent bits. But, the
inherited API operates on the bytes, not the bits.

Encapsulation may be the answer. e.g. a Bits object that holds a ByteArray
and provides the API that is needed.


That's a rather long answer, admittedly.



> Noury
>
> > On 20 Mar 2020, at 13:56, Julien Delplanque 
> wrote:
> >
> > Hello,
> >
> > There is a work in progress prototype slot named BooleanSlot in the
> Slot-Example package built-in the image.
> >
> > I think this slot does what you want.
> >
> > So, the answer is yes, it is possible to do that. But you will need to
> fix todos left in BooleanSlot methods.
> >
> > Julien
> >
> > Le 20/03/20 à 12:24, N. Bouraqadi a écrit :
> >> Hi,
> >>
> >> Suppose I have an instance variable referencing a collection of
> booleans.
> >> I want to have all elements of the collection be stored as bits.
> >> Is there a way I can express it using slots?
> >>
> >> This idea can be generalized to other types of slots.
> >>
> >> Noury
> >>
> >
>
>
>


Re: [Pharo-users] Corona virus

2020-03-15 Thread Richard Sargent
I'm not sure no country had a plan ready to apply. Canada seems to be in
pretty good shape from what I'm reading. It seems to have prepared well
after SARS. And South Korea certainly seems prepared, as they are handling
it better than anyone else.


On Sun, Mar 15, 2020, 10:20 Davide Grandi  wrote:

> It's a good article, very deep on knowledge.
> (it let arise a question : why, apparently, nearly none of country all
> over the world, had a plan ready to apply ?)
>
> Bye,
>
>  Davide
>
> On 15/03/2020 14:34, Ben Coman wrote:
> > Of all the articles I've read on the coronavirus, this is the first I
> > felt worth sharing.
> >
> https://medium.com/@tomaspueyo/coronavirus-act-today-or-people-will-die-f4d3d9cd99ca
> >
> >
> > I've been a bit complacent about the advantage of living in Australia in
> > a small town outside Perth (one of the most remote capital cities in the
> > world)
> > but Section 3 on improving mortality rates by reducing the peak on the
> > health system is compelling for everyone to know.
> >
> > cheers -ben
> >
> > On Sun, 15 Mar 2020 at 01:15, Davide Grandi  > > wrote:
> >
> > That's true,
> >
> > and it will be a worldwide pandemia.
> > Try to work @ home,
> > limit contacts with other people,
> > don't go in crowded places,
> > and PROTECT YOUR PARENTS - GRANDPARENTS.
> >
> > The local newsmagazine of Dario's town, few km from mine,
> > has normally ONE page of obituary.
> > Yesterday ... TEN pages.
> >
> > bye,
> >
> >   Davide
> >
> > On 14/03/2020 14:52, dario.trussardi65 wrote:
> >  > Ciao,
> >  > be very careful ... it's very dangerous ...
> >  > here in Bergamo it's a disaster.
> >  > We are losing our grandparents like leaves falling from the tree
> 
> >  > Take all precautions  Don't underestimate the situation.
> >  > See you soon
> >  > Dario
> >
> > --
> > Ing. Davide Grandi
> > email  : davide.gra...@email.it 
>
>


Re: [Pharo-users] [ANN] We have our winners!

2020-03-08 Thread Richard Sargent
Excellent!

I would love to see the finalists' thoughts on programming in Pharo and on
programming the challenge.


On Sat, Mar 7, 2020, 20:23 Richard Kenneth Eng 
wrote:

> https://smalltalk.tech.blog/2020/03/07/jrmpc-2020-award-winners/
>
> Time to play this up for all the PR value I can muster.
>
> Richard
>


Re: [Pharo-users] "Theming" dictionaries?

2020-02-19 Thread Richard Sargent
See below.

On Wed, Feb 19, 2020 at 8:49 AM Offray Vladimir Luna Cárdenas <
offray.l...@mutabit.com> wrote:

> Hi,
>
> As some of you may know, I'm a "savage coder" who learned
> Smalltalk/Pharo by himself, of course thanks to communities, books and
> videos, but without formal training or peers in the same country and
> guided mostly by necessity. All this to say that this maybe kind of a
> silly question.
>
> Anyway, we have this project called Minipedia[1], that imports Wikipedia
> articles and their history. A Minipedia language there, is just a
> dictionary, where the key is the language two letters code and the value
> for each key is an array of article titles. There is any way to
> specialize a Dictionary to tell it, name your 'key' as language and your
> 'value' as 'titles'?
>

There are several ways, depending on your intention.

If you intend that the full Dictionary and Collection API is available to
all the places where this artefact will be used, you can add extensions to
the Dictionary class to provide alias accessing methods or you can also
subclass Dictionary and only have your aliases (and whatever API) visible
only to consumers of that class. The former is a quick and dirty approach.
The latter is better, since every Dictionary is NOT a language keyed
collection of article.

If you want to have a limited API, you wrap a dictionary with a new class
that exposes just the API you desire consumers to use.

In general, inheritance is often overused or/ misused. Composition is
usually a better technique unless you want the full API of the hierarchy to
be available and used.


> [1] https://mutabit.com/repos.fossil/minipedia/
>
> Thanks,
>
> Offray
>
>
>
>


Re: [Pharo-users] The results are in!

2020-02-08 Thread Richard Sargent
I've found this topic both interesting and upsetting at times. I do
understand the desire to address Pharo issues without getting sidetracked
by other topics.

However, this particular thread started as a Pharo user's success story.
Didn't it? Isn't Pharo the implementation used for the contest? Are all
success stories to be banned as a consequence, intended or otherwise?


On Sat, Feb 8, 2020, 11:24 Guillermo Polito 
wrote:

> Hi Richard,
>
> I’d like to invite you to refrain yourself from posting such off-topic
> messages in the future.
>
> This list is for people to *ask* questions about Pharo. Not to diffuse any
> kind of propaganda (pharo related or not).
> You’re not asking a question about Pharo, nor answering a question about
> Pharo.
> So I personally find all these emails off-topic and uninteresting.
>
> I have the feeling this list has been lately flooded with such off-topic
> messages.
> And this only chases off this list people really interested about the main
> topic of the list (like me).
>
> Maybe this shows this competition / PR campaign you’re running needs
> another channel?
> I know you don’t agree, but I invite you to read here the **purpose** of
> this list, just for respect to people subscribed to it:
>https://lists.pharo.org/mailman/listinfo/pharo-users_lists.pharo.org
>
> Thanks for your comprehension,
> Guille
>
> El 8 feb 2020, a las 19:12, Richard Kenneth Eng 
> escribió:
>
> Round 1 — #1 Leading Team: https://youtu.be/QWHeN5WXfBQ
>
> I'm actually quite amazed by their effort. They surpassed my expectations.
>
> At the risk of sounding immodest, I think this is a terrific way to
> promote Smalltalk (Pharo). I think the video is an absolute blast.
>
> Richard
>
>
>


Re: [Pharo-users] Smalltalk Poll

2020-01-29 Thread Richard Sargent
On Wed, Jan 29, 2020 at 9:13 AM horrido  wrote:

> That's right. The poll is for non-Smalltalkers. The goal is to identify the
> pain points and then to respond to those points in a future blog post.
>

Oh. Then you shouldn't have left out the "I don't want to write less code
and fewer errors" choice.


>
>
> Tim Mackinnon wrote
> > Is this a poll you expect none of us to take?
> >
> > Maybe
> > - it’s too productive and fun, real programmers should be made to suffer
> >
> > Sent from my iPhone
> >
> >> On 29 Jan 2020, at 13:00, Esteban Maringolo 
>
> > emaringolo@
>
> >  wrote:
> >>
> >> Final and correct option: All the above :-D
> >>
> >> Esteban A. Maringolo
> >>
> >>
> >>> On Wed, Jan 29, 2020 at 9:40 AM Richard Kenneth Eng 
>
> > horrido.hobbies@
>
> >  wrote:
> >>> I'm crafting a Smalltalk poll for my blog. I just wanted to get some
> >>> feedback. Have I overlooked anything?
> >>>
> >>>
> >
> >
> > image.png (87K)
> > http://forum.world.st/attachment/5110875/0/image.png;
>
>
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] Resources Page

2020-01-28 Thread Richard Sargent
Thanks.

On Tue, Jan 28, 2020, 17:21 horrido  wrote:

> Done. I didn't realize there was a free license for GemStone/S.
>
> Too bad VA Smalltalk doesn't offer a free license.
>

I believe they do.



>
>
> Richard Sargent (again) wrote
> > Thank you, Richard.
> >
> > Would you be kind enough to annotate the GemStone link to point out that
> > we have a free license that permits commercial use, not only personal
> use.
> >
> > Thanks again for all your hard work!
> >
> >
> > On January 28, 2020 2:24:16 PM PST, Richard Kenneth Eng 
>
> > horrido.hobbies@
>
> >  wrote:
> >>I've added a Resources page to my new blog:
> >>https://smalltalk.tech.blog/resources/.
> >>
> >>It is very much a *curated *list. I felt this was needed because when I
> >>visit other Smalltalk resources pages, I get overwhelmed by the number
> >>of
> >>links and options. It is possible to have *too many* choices.
> >>
> >>Moreover, many of those links are either broken, or they point to
> >>obscure
> >>materials that people may not be interested in.
> >>
> >>As curator, it is my job to present those links that I believe will be
> >>useful. Of course, this is necessarily very subjective.
> >>
> >>Also, it is likely that I've overlooked some links that others feel are
> >>useful. However, I am open-minded. If there are Smalltalk links that
> >>you
> >>believe I should consider, please let me know.
>
>
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] Resources Page

2020-01-28 Thread Richard Sargent
Thank you, Richard.

Would you be kind enough to annotate the GemStone link to point out that we 
have a free license that permits commercial use, not only personal use.

Thanks again for all your hard work!


On January 28, 2020 2:24:16 PM PST, Richard Kenneth Eng 
 wrote:
>I've added a Resources page to my new blog:
>https://smalltalk.tech.blog/resources/.
>
>It is very much a *curated *list. I felt this was needed because when I
>visit other Smalltalk resources pages, I get overwhelmed by the number
>of
>links and options. It is possible to have *too many* choices.
>
>Moreover, many of those links are either broken, or they point to
>obscure
>materials that people may not be interested in.
>
>As curator, it is my job to present those links that I believe will be
>useful. Of course, this is necessarily very subjective.
>
>Also, it is likely that I've overlooked some links that others feel are
>useful. However, I am open-minded. If there are Smalltalk links that
>you
>believe I should consider, please let me know.


Re: [Pharo-users] Why Smalltalk is so easy to evangelize

2020-01-10 Thread Richard Sargent
On Fri, Jan 10, 2020 at 1:52 PM horrido  wrote:

> Offray Vladimir Luna Cárdenas-2 wrote
> > But I have not
> > being able to convince any of my coder friends to switch to Pharo
> > instead of C++, Java or Javacript, which by the way, is the language
> > they already know and use to put bread on the table on a daily basis.
> >
> > So I think that we deal with a paradox: while Smalltalk advocacy is
> > better suited for a Blue Ocean Strategy[2], exploring and implementing
> > new/emerging scenarios and markets, money is already mostly invested in
> > Red Oceans of constituted technologies and practices ecosystems.
> > Bridging both is pretty difficult.
>
> Yes, that is the principal obstacle and challenge. When I'm pushing
> Smalltalk, I mention the language's simplicity and conciseness, I
> mention the purity of the object-oriented model, I mention the
> built-in IDE, and so on. But the key advantage that I emphasize
> is *programmer productivity*.
>
> I realize it's hard to argue with the availability of jobs for Java,
> Python,
> JavaScript, etc. It's hard to argue with their rich ecosystems. It's
> hard to argue with the status quo of established code bases and
> IT infrastructures. But we have to make them believe that
> Smalltalk can cut their development time in half, if not better.
>
> What is it worth to a company to cut their development time in half?
> It means much lower development cost. It means much shorter
> "time to market."
>

It also means much lower error rates. Capers Jones also review errors /
lines of code and Smalltalk was substantially better than the C derivative
languages. I don't recall the ration, but I think the Namcook report does
include it.

Fewer errors means a higher ratio of time spent delivering functionality
and a better customer experience. (We can't do anything about bad design
and UX practices, of course and unfortunately. Although, I suspect without
evidence that Smalltalkers may do a better job of both.)


> Is this not worth investing time and energy in Smalltalk? Even if the
> job opportunities aren't there. Even if it means overhauling your
> IT infrastructure.
>
> The investment can lead to more users and more jobs. If they don't
> believe it, then we have failed.
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] Prof Stef questions

2020-01-06 Thread Richard Sargent
On Mon, Jan 6, 2020 at 12:26 PM xap  wrote:

> Hmm, just where are these prof stef Gedankenexperiments :-? I didn't see
> 'em
> in the syntax tutorial proper.
>
> Thx for the tiny-is-beautiful article. I didn't have any moment of satori,
> but am happy to have found a prolific author (in addition to
> Richard-evangelist)
>
> About not feeling extra-illuminated ... perhaps it comes from my stance
> that
> once one lays down the ground rules that everything is an object, and that
> objects inherit, and get work done by doing it themselves or by delegating
> it, then, say, much of Boolean's implementation shakes out of that, no?
> (that's rhetorical)
>
> For me the value in the pharo Boolean implementation is notsomuch who
> passes
> the buck and who ultimately does what, but the synergy among objects and
> methods that get all this done.
>
> (BTW I'll bet the fait accompli synergy we see in today's source didn't
> start out that way -- there were likely many prosaic versions along the way
> to getting there, if not on paper then in somebody's mind. Often I find
> that
> process MUCH more valuable than the spit-and-polish of a finished product.)
>

It is often informative to understand *how* a thing came to be, beyond the
"Tada! Here it is."


> Recursion often has me laugh because it seems "nobody does any work" --
> dang
> near everything is delegated elsewhere, and it's just a few base cases that
> actually do any heavy lifting. I'm being facetious, of course.
>
> To me interconnected object systems are often like that, and multiplied
> many
> times over -- any bit of work is delegated here, there, everywhere ... and
> (for me) this federated work disperses logic and makes it less immediately
> comprehensible.
>

This is absolutely true and correct. That's why it's crucial that a message
send clearly identify the "what" and the method implementation clearly
implement the "how". (And that too is recursive!)

Many years ago, my wife worked for a life insurance company. No one could
look at one department and understand the whole algorithm involved in even
just the lifecycle of a new policy.

We don't slavishly or dogmatically mimic nature when we design objects, but
we do attempt to clearly and cleanly separate responsibilities much as
nature does. There are many guidelines, heuristics, and practices we employ
to achieve good robust designs. Using analogues to real-world things helps
make them familiar and innately understandable.


> There's definitely gee-whiz appeal to the synergy of a multitude of objects
> in a loosely-coupled system, and IMO that appeal is valuable (which echoes
> the ethos of the tiny/beautiful article), but ... anyway, yeah, part of my
> reason for this foray into smalltalk is to see how that side lives.
>
> TLDR: the above is just my thinking out loud, possibly for a future-me to
> find; i have no questions; pls ignore :-)
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] R: Smalltalk: It’s Not Your Grandfather’s Programming Language

2020-01-06 Thread Richard Sargent
On Mon, Jan 6, 2020 at 12:18 PM horrido  wrote:

> Thanks!
>
> I have a question for everyone. Someone has taken me to task for being
> "sexist". He says I should refer to "grandparent" instead of "grandfather".
>
> I'd like to ask for your opinion. Would "grandparent" sound better in my
> article? Imagine replacing all instances of "grandfather" with
> "grandparent". Would it have the same impact?
>

Arguably, it is sexist. But, I think it is also accurate. I am guessing
that better than 99% of grandparents driving Maserattis are or were male.

I think we sometimes rely on dogma rather than reason. Still, it is worth
being aware of the word choices you make and whether they may be
inappropriate for the circumstances.


> Thanks.
>
>
>
> Lorenzo wrote
> > Great work Rich
> >
> >
> >
> > My best compliments.
> >
> >
> >
> > Lorenzo
> >
> >
> >
> > Da: Pharo-users [mailto:
>
> > pharo-users-bounces@.pharo
>
> > ] Per conto di Richard Kenneth Eng
> > Inviato: lunedì 6 gennaio 2020 19:07
> > A:
>
> > pharo-users@.pharo
>
> > Oggetto: [Pharo-users] Smalltalk: It’s Not Your Grandfather’s Programming
> > Language
> >
> >
> >
> >
> https://levelup.gitconnected.com/smalltalk-its-not-your-grandfather-s-programming-language-f1985eaa17ff
>
>
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] is this better regarding naming thigs

2020-01-05 Thread Richard Sargent
On Sun, Jan 5, 2020, 15:51 xap  wrote:

> hi, I'm just starting out w/ pharo and have a question re your code;
> specifically, in
>
> reject:
>  [ :word | (word sameAs: aWord) or: [ word asLowercase asBag ~=
> charBag ] ]
>
> is that inner block needed? would it be less smalltalk-esque to write, say:
>
> reject:
>  [ :w | (w = aWord) or: (w asLowercase asBag ~= charBag) ]
>
> thx!
>

The answer to your question is provided by looking at the definition of the
#or: message. Specifically, look on the class Boolean and its subclasses.
They should tell you what kinds of objects are allowed for the argument.

There is also an #| message which does what you have asked the #or: message
to do. Study the differences in their definitions in the Boolean hierarchy.


> separately recently I watched an alan kay interview in which he says an oo
> program is typically much smaller than its imperative counterpart and i
> wondered why. Well, it seems that reduction comes from the language/system
> providing a zillion methods -- asBag, here -- one would otherwise need to
> implement, oneself :)
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] why is my css not found in a seaside project

2020-01-04 Thread Richard Sargent
On Sat, Jan 4, 2020 at 2:17 AM Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Hello,
>
> I have this in my library class on the instance side :
>
>
> updateRoot: anHtmlRoot
> super updateRoot: anHtmlRoot.
> anHtmlRoot stylesheet url: self class / #mainCss.
> anHtmlRoot javascript url: self class / #mainJs
>
> and a file mainCss on the instance side filled with css
> and still the css is not found
>

I'm not familiar with Seaside programming and especially not CSS. However,
I have to wonder whether "url: self class / #mainCss" makes it look for a
class method rather than an instance method.


> anyone idea why ?
>
> if needed I can put my whole code on github.
>
>
> Regards,
>
> Roelof
>
>


Re: [Pharo-users] can I make this so the vm would not be not responsibe when running the tests

2020-01-04 Thread Richard Sargent
On Sat, Jan 4, 2020 at 10:37 AM Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Oke,
>
> So I can better not use recursion for this problem if I understand you
> well,  Richard.
>

That is oversimplifying. If the purpose of the *training* *exercise* is to
learn how to use recursion, then using recursion is a necessary thing. If
the purpose of the exercise is to solve a problem, understanding whether
there are more efficient approaches to the solution is an essential skill.

This particular problem could have been solved using a recursive
implementation, an iterative implementation, or a fundamental reframing of
the problem to change it to an O(1) problem. Other problems are no so
simply reframed.


One of the most important skills you will ever develop is to understand
that a request for a feature may not be accurately describing the problem.
A feature request is often a description of a problem from a single
perspective. Learning to recognize whether it is one or the other will be
crucial to your long-term success as a programmer.


> Roelof
>
>
>
> Op 4-1-2020 om 19:02 schreef Richard Sargent:
>
> On Sat, Jan 4, 2020 at 9:47 AM Roelof Wobben via Pharo-users <
> pharo-users@lists.pharo.org> wrote:
>
>> Hello,
>>
>> For a exercism challenge I need to calculate the total grains on a
>> chessboard.
>> So I did :
>>
>> atSquare: anInteger
>>  self validateInput: anInteger.
>>  ^ anInteger = 1
>>  ifTrue: [ 1 ]
>>  ifFalse: [ 2 * (self atSquare: anInteger - 1) ]
>>
>>
>> but when I run the tests , the vm seems to be not responsive for some 4
>> - 5 seconds.
>>
>> Is there a way I can use this code and take care that the vm stays
>> responsive.
>>
>
> What do you want the VM to do in addition to calculating that sum while it
> is calculating that sum?
>
>
> The best way to keep the VM responsive is to take a page from Gauss'
> notebook and pay attention to the numbers[1]. Let's consider the first four
> squares and extrapolate from there.
>
> In binary, the squares hold the following grains: 2r1, 2r10, r2100, and
> 2r1000. When we add them up, we get 2r. If we use Gauss' tricks, we can
> notice that 2r is equal to 2r1 - 1. So, the sum of the grains on
> the first 4 squares is 2^5 - 1. You can easily generalize that pattern, of
> course. Then your program can calculate the answer quickly.
>
>
> [1] The story goes that Gauss' teacher was frustrated with his student's
> abilities and set him a challenge to occupy him for some time: sum the
> numbers from 1 through 100. Gauss immediately answered 5,050, much to his
> teacher's chagrin.
>
>
>> Regards,
>>
>> Roelof
>>
>>
>>
>


Re: [Pharo-users] can I make this so the vm would not be not responsibe when running the tests

2020-01-04 Thread Richard Sargent
On Sat, Jan 4, 2020 at 9:47 AM Roelof Wobben via Pharo-users <
pharo-users@lists.pharo.org> wrote:

> Hello,
>
> For a exercism challenge I need to calculate the total grains on a
> chessboard.
> So I did :
>
> atSquare: anInteger
>  self validateInput: anInteger.
>  ^ anInteger = 1
>  ifTrue: [ 1 ]
>  ifFalse: [ 2 * (self atSquare: anInteger - 1) ]
>
>
> but when I run the tests , the vm seems to be not responsive for some 4
> - 5 seconds.
>
> Is there a way I can use this code and take care that the vm stays
> responsive.
>

What do you want the VM to do in addition to calculating that sum while it
is calculating that sum?


The best way to keep the VM responsive is to take a page from Gauss'
notebook and pay attention to the numbers[1]. Let's consider the first four
squares and extrapolate from there.

In binary, the squares hold the following grains: 2r1, 2r10, r2100, and
2r1000. When we add them up, we get 2r. If we use Gauss' tricks, we can
notice that 2r is equal to 2r1 - 1. So, the sum of the grains on
the first 4 squares is 2^5 - 1. You can easily generalize that pattern, of
course. Then your program can calculate the answer quickly.


[1] The story goes that Gauss' teacher was frustrated with his student's
abilities and set him a challenge to occupy him for some time: sum the
numbers from 1 through 100. Gauss immediately answered 5,050, much to his
teacher's chagrin.


> Regards,
>
> Roelof
>
>
>


Re: [Pharo-users] can I write this without the three if then;s

2019-12-30 Thread Richard Sargent
Pharo Smalltalk Users mailing list wrote
> Hello, 
> 
> Im trying to solve a challenge from exercism where  I have to
> calculate the points somehow gets on a very simple darts board. 
> 
> I solved it like this : 
> 
>   
>   scoreX: anInteger y: anInteger2 
>       | distance | 
>       distance := (anInteger squared + anInteger2 squared) sqrt. 
>       distance  10 
>           ifTrue: [ ^ 0 ]. 
>       distance  5 
>           ifTrue: [ ^ 1 ]. 
>       distance  1 
>           ifTrue: [ ^ 5 ]. 
>       ^ 10 
>   
>   
>   but now I use three if then and I think it's ugly code. 
>   
>   Is there a way I can make it more the smalltalk way ? 

Roelof, this example is too simple to "really do it the Smalltalk way".

In a more realistic scenario, you would have classes for each "rule" with
corresponding differences in behaviour. In the above example, you could get
away with a single class with two instance variables and configure three
instances of it appropriately.

In more complex scenarios, your start up code instantiates the various
rules, with precedence determined by the order of the rule instances. Then
when you need to determine which rule to apply, you use #detect:ifNone: to
find the rule that applies with the #ifNone: block providing the fallback
result.

Sometimes, you work with classes themselves to determine which class to use,
but I have described working with instances for the general concept. (After
all, classes are instances.)

Using rules with a #select: allows you to handle a scenario where multiple
rules apply. A good example is rules to provide the default coverages for an
auto insurance policy, where each possible coverage can have one or more
rules to assess the many characteristics of the applicants and so determine
the one rule that applies for each possible coverage. (And yes, it is
reasonable that a possible coverage has no rule applicable, in which case
the coverage is not included in the default offering.)


As mentioned, you /could/ apply this to your scenario, as an exercise. You
might be tempted to utilize an existing class with two instance variables.
That would be a bad design practice, but reasonable for a /disposable/
experiment to quickly study how it works. Always (create and) use classes
which truly reflect their purpose and have named properties which truly
reflect the objects they hold. In your scenario, #distance and #score seem
appropriate.

  

>   
>   Regards, 
>   
>   Roelof





--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



Re: [Pharo-users] open spec window to handle exception and pause execution

2019-11-20 Thread Richard Sargent
Paul, I'm going by memory and not Pharo specific.

I believe the default handling of the end of the exception block is
implicitly equivalent to ex return: nil.

So, to get further handling of the exception, you need to #pass it or
otherwise resignal it. Then the development environment will catch and
handle the unhandled exception.


On Wed, Nov 20, 2019, 20:53 PAUL DEBRUICKER  wrote:

> Hi -
>
> I have a subclass of ComposablePresenter (lets call it MyPresenter) that
> seems to work how I want.  When doing some processing I'd like to open
> MyPresenter  when an exception occurs and pass it the exception e.g.
>
>
> [ [self testCondition] whileTrue:[ self doSomeStuff] ]
> on: MyNotification
> do:[:ex | self openMyPresenterWith: ex]
>
> But that just results in lots of MyPresenter windows opening while the
> execution of the #whileTrue: loop runs its course.
>
>
> How do I pause the loop so I can use the MyPresenter window to modify and
> fix the condition that raised the MyNotification?
>
> The MyPresenter window just edits the contents of a couple Dictionaries so
> isn't too tricky but it isn't really as easy to do in a debugger as it is
> clicking a radio button and a "do it" button.
>
>
> Thanks
>


Re: [Pharo-users] BlockClosure

2019-10-23 Thread Richard Sargent



On October 23, 2019 5:46:50 AM PDT, "p...@highoctane.be"  
wrote:
>On Wed, 23 Oct 2019, 14:25 Kasper Osterbye, 
>wrote:
>
>> On Wed, Oct 23, 2019 at 2:21 PM p...@highoctane.be
>
>> wrote:
>>
>>> It is like Object>>in: aBlock no?
>>>
>> Yes.
>>
>> But because it is an operator, you can write "obj => block => block
>=>
>> block".
>> You can not write "obj in: block in: block in: block", because
>smalltalk
>> will think it is a selector named "in:in:in:".
>>
>
>Indeed.
>
>I would still use in: with parentheses instead of introducing a new
>(albeit
>cool) operator.

Especially when that particular selector has often been implemented as a 
shorthand for creating associations!


>
>Phil
>
>
>> Best,
>>
>> Kasper
>>



Re: [Pharo-users] Transcript: printString or asString

2019-10-14 Thread Richard Sargent
Samuel,

One thing I don't recall seeing in this thread is a discussion of the
semantics of the methods names.

I find it helpful to consider #asWhatever to be a conversion method, used
to convert one object to another essentially compatible class. e.g.
#asFloat sent to an integer would be expected to yield a floating point
number with the same value, but #asInteger sent to a floating point number
would lose precision but might still be sensible for some purposes. [more
on this below]

But, #printString and its ilk (#displayString, #storeString, others) are
not intended to be conversion methods. They are to provide an external
representation of a format suitable for the intended audience. Typically,
(and I say that guardedly), #printString's intended audience is the
programmers working on the system and #displayString is intended for the
system's users.

In simple cases, #printString is reversible and can be parsed to recover
the value of the original object. In general, it doesn't include enough
information to do so. The same is true of #displayString. If we consider a
slightly more complex example than a number, consider a User Profile. Its
#printString might be 'UserProfile(John Doe)'. Its #displayString might be
'John Doe'. Neither of those provide all the details of the object,
although they could be parsed and so used to look up an existing object.


--
Continuing from [more on this below] above...

I find #asString is one of the most problematic methods that I have ever
seen. It is deceptive, an "attractive nuisance", as one colleague liked to
say. Clarity comes from being explicit in one's programming. Say what you
mean and mean what you say. If you are trying to convert from one object
form to another, use a conversion method whose name is precise. If you are
trying to provide information for a programmer about an object,
#printString is the choice.(e.g. in a stack dump).

As a general rule, #asWhatever methods that are generally applicable to the
set of possible values. e.g. number conversion methods are a good example,
even though there are exceptions (loss of precision, NaN, and Inf are some).


I have seen a lot of #asWhatever methods added to the String hierarchy, but
almost all of them are dubious, in my opinion of course. Most strings are
not numbers, for example. String>>#asNumber is one of the worst things I
have ever seen, both from a consistency perspective and an implementation
perspective. 'abc123def456' asNumber has more variant results than I can
enumerate.



On Mon, Oct 14, 2019 at 9:28 AM Samuel Teixeira Santos 
wrote:

> Very clear to me now.
>
> Thank you and to others too by your previous answers
>


Re: [Pharo-users] Code of Conduct

2019-09-11 Thread Richard Sargent
Thanks for sharing that, Peter. It's an important point.

On Wed, Sep 11, 2019 at 2:02 PM Peter Kenny  wrote:

> I see no problem with having *a* code of conduct, but there are some
> worrying aspects of *this* code. Clearly there is a need for generality in
> any code, but the vagueness of the drafting seems to me to open it up to
> all sorts of mischief. Consider the paragraph: " *Project maintainers
> have the right and responsibility* to remove, edit, or reject comments,
> commits, code, wiki edits, issues, and other contributions that are not
> aligned to this Code of Conduct, or* to ban temporarily or permanently
> any contributor for other behaviors that they deem inappropriate*,
> threatening, offensive, or harmful." The bits I have bolded mean that the
> maintainers can apply punitive measures based on what they deem
> inappropriate. Shouldn't the concept of "due process" come into this? The
> FAQ section, under the heading "What should I do if I have been accused of
> violating the code of conduct?", makes no mention of defending ones
> actions; the only option is to admit guilt and work with the accusers to
> reform. The inclusion of the words "they deem" opens the way to all sort of
> subjectivity. Just for one instance, Sven recently thought it inappropriate
> that John Pfersich mentioned in passing in this list that, besides
> programming, his hobbies include shooting, which is a legal activity in
> most countries and an Olympic sport. Others disagreed in the thread, but
> Sven's message remained "don't do it." If John mentioned it again, could
> that be a violation of the code? The fact that this particular code,
> evidently the creation of one person, is accepted by others should not mean
> it is automatically accepted. There is an obligation to look at it in
> detail; when I do, I think there are problems. Peter Kenny
>
> Sven Van Caekenberghe-2 wrote
> > On 11 Sep 2019, at 19:07, James Foster <[hidden email]
> > wrote: > > >>
> On Sep 11, 2019, at 8:17 AM, Offray Vladimir Luna Cárdenas <[hidden email]
> > wrote: >>
> >> On 11/09/19 9:14 a. m., Herby Vojčík wrote: >>> I found Contributor
> Covenant-derived Code of Conduct was added to >>> Pharo, three months ago.
> This is unacceptable under any circumstances. >>> >>> Have fun in your woke
> hell. >> >> I would like to have more details about this. For those of us
> who don't >> believe in hell, what is the problem of an explicit Code of
> Conduct? > > More specifically, what behavior does the Code prohibit that
> you would otherwise do? > > For my part, while I might not subscribe to the
> full progressive agenda, I wasn’t planning any racial or ethnic slurs (or a
> theological discussion of the afterlife—but feel free to ask me
> privately!), so don’t find this “woke” agenda too constricting. > > James
> Indeed. For those new to the discussion, we are talking about
> https://www.contributor-covenant.org/version/1/4/code-of-conduct - which
> is quite popular and generally accepted. Sven
>
>
> --
> Sent from the Pharo Smalltalk Users mailing list archive
>  at Nabble.com.
>


Re: [Pharo-users] Set >> collect:thenDo:

2019-09-08 Thread Richard Sargent
I don't know the correct answer, but I am skeptical of one that relies on a
specific implementation rather than a specific definition.

I would like to see and understand the arguments for one interpretation
versus another.

Prima facie, the expectation that set behaviour propagates through the
implementation is appealing. The correct answer is anything but clear cut

On Sat, Sep 7, 2019, 23:03 Kasper Østerbye 
wrote:

> Feature!
>
> collect: forms a new collection of the same kind as its receiver. In this
> case a set. As the result of your collect:
> #(1 2 3) asSet collect: #odd)
> is booleans, the resulting set will contain only to elements (the
> duplicate odd resulting in true is removed).
>
> collect: thenDo: applies the collect-block to each element of the
> receiver, and then applies the do to each of those results. You can see the
> implementation of collect:thenDo: in class Collection.
>
> Best,
>
> Kasper
>
>
> On 7 September 2019 at 17.22.03, Herby Vojčík (he...@mailbox.sk) wrote:
>
> Hello!
>
> 
> (#(1 2 3) asSet collect: #odd)
> do: [ :each | Transcript show: each; cr ]
>
> > true
> > false
>
> 
>
> #(1 2 3) asSet collect: #odd
> thenDo: [ :each | Transcript show: each; cr ]
>
> > true
> > false
> > true
> 
>
>
> Bug or feature?
>
> Herby
>
>


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.
>>
>


Re: [Pharo-users] Why do I not see the transactions when opening a customer

2019-08-19 Thread Richard Sargent
On Mon, Aug 19, 2019 at 9:40 AM Roelof Wobben  wrote:

> Hello Ben,
>
> I think the purpose of this exercise was to practice expecially things
> like encapsulation and thinking in classes.
>
> So I think it's not a big deal to have a setter and a method to check if
> the passwords are matching.
>

Roelof,

There are still ways to avoid that. For example, consider a method such as
Customer>>addAccountWithPassword: and Account>>#changePasswordFrom:to:. No
need for setters and getters and no exposure to unauthorized password
changes.
[Of course, this doesn't handle the "I've forgotten my password" scenario,
but Account>>#changePasswordTo:usingAuthorizationToken: might.]

I think the exercise is more about APIs than it is about every little
detail of an exercise reflecting best practices in the corresponding real
world scenario. But, understanding that there are those issues is crucial,
as we see almost daily with news of security breaches.

I don't think anyone would argue that completing this exercise should
suddenly make you qualified to develop a banking application. :-)



> Roelof
>
>
>
> Op 19-8-2019 om 18:35 schreef Ben Coman:
>
>
>
> On Mon, 19 Aug 2019 at 22:19, Roelof Wobben  wrote:
>
>> Thanks all for the answers.
>>
>> As I see it , it impossible to store the password in the bankaccount
>> object and make safe code to use it,
>> So some one give me a stupid assignment.
>>
>
> That would seem to depend on the purpose of the assignment.
>   a. To produce production ready code that managed someone's real life
> money,
>   b. Provide a vehicle to reason about typical implementation issues, in
> which case did you learn anything from the exercise?
>
> cheers -ben
>
>
>


Re: [Pharo-users] A Canticle for Smalltalk

2019-08-06 Thread Richard Sargent
On Tue, Aug 6, 2019 at 4:16 PM BrunoBB  wrote:

> /Yes. And I think it's even more sad than the containers example doesn't
> work
> anymore... AFAIK they replaced the system. /
>
> How accurate is this ?
>

OOCL advanced their system to IRIS-4 (Oracle based) and was eventually
bought by COSCO, a mainland China shipping company. COSCO is currently
running IRIS-2.


> From:
>
> https://www.oocl.com/eng/aboutoocl/companyprofile/informationtechnology/Pages/default.aspx
>
> OOCL's  Integrated Regional Information System, known as IRIS-2, was
> launched in 1999. IRIS-2 became more than just a software; it helped
> facilitate a new company culture. * IRIS-2 has changed the way we think and
> the way we do business.*
>
> regards,
> bruno
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


  1   2   >