<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-12-18 21:31 GMT+01:00 Sven Van Caekenberghe <span dir="ltr"><<a href="mailto:sven@stfx.eu" target="_blank">sven@stfx.eu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Nicolai,<br>
<br></blockquote><div><br></div><div>Hi :) Thanks for looking into this.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I used the code that I found @<br>
<br>
MCSmalltalkhubRepository<br>
        owner: 'onierstrasz'<br>
        project: 'PharoByExample'<br>
        user: ''<br>
        password: ''.<br>
<br>
(SqueakSource acted really strange).<br>
<br>
I had to change the registration, like you said.<br>
<br>
Inside callbacks it is safe to change state.<br>
<br>
I got the code to work by modifying (added line before last)<br>
<br>
RPNKeypad>>#type: aString<br>
        self inPushMode ifTrue: [<br>
                stackMachine push: stackMachine top.<br>
                self stackClearTop ].<br>
        self inClearMode ifTrue: [ self stackClearTop ].<br>
        stackMachine isEmpty ifTrue: [ stackMachine push: 0 ].<br>
        stackMachine push: (stackMachine pop asString, aString) asNumber.<br>
<br>
#type: is called from inside callbacks.<br>
<br>
Removing the #ensureStackMachineNotEmpty call in  #renderContentOn: does not work, so this remain all quite fishy.<br>
<br>
StackMachine is a model of a mathematical RPN calculator, not one with a keypad and modes.<br>
<br>
In my HP-35 code, there is RPNCalculatorCore for the mathematical abstraction and HP35CalculatorModel for the thing with the keys, input modes, etc.<br>
<br>
If the example UI cannot work with an empty stack, then maybe it should always be initialized with one containing 0, as an invariant ?<br>
<br>
The problem is that too many operations allow the model to go into error (esp. depleting the stack).<br></blockquote><div><br></div><div>I think I will stick with the ensureStackMachineNotEmpty call, otherwise I need to initialize the stack with 0 as top.<br></div><div>And I will guard the keypad stack operations to not operate on an empty stack.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class="gmail-HOEnZb"><font color="#888888"><br>
Sven<br>
</font></span><div class="gmail-HOEnZb"><div class="gmail-h5"><br>
> On 18 Dec 2016, at 17:42, Sven Van Caekenberghe <<a href="mailto:sven@stfx.eu">sven@stfx.eu</a>> wrote:<br>
><br>
>><br>
>> On 18 Dec 2016, at 16:42, Nicolai Hess <<a href="mailto:nicolaihess@gmail.com">nicolaihess@gmail.com</a>> wrote:<br>
>><br>
>><br>
>><br>
>> 2016-12-18 14:06 GMT+01:00 Sven Van Caekenberghe <<a href="mailto:sven@stfx.eu">sven@stfx.eu</a>>:<br>
>> Hi Nicolai,<br>
>><br>
>> This article of mine: <a href="https://medium.com/concerning-pharo/rediscovering-the-ux-of-the-legendary-hp-35-scientific-pocket-calculator-d1d497ece999" rel="noreferrer" target="_blank">https://medium.com/concerning-<wbr>pharo/rediscovering-the-ux-of-<wbr>the-legendary-hp-35-<wbr>scientific-pocket-calculator-<wbr>d1d497ece999</a> contains two Seaside RPN calculator web apps based on a pure domain model. You can find the web stuff towards the end, you will probably have to skip some intro stuff in between. The appendix explains how to get the code. I hope it all still works.<br>
>><br>
>> Thanks for your response,<br>
>> yes, it still works, but it does not really helps me, as it does not have to care about an empty stack or changes state before rendering.<br>
><br>
> I will (re)read section 12.7 in my physical copy of the book and come back to you.<br>
><br>
> But from a theoretical standpoint, the model should just always be consistent in itself, independent of the (web) UI, in my opinion.<br>
><br>
>> Sven<br>
>><br>
>>> On 18 Dec 2016, at 13:27, Nicolai Hess <<a href="mailto:nicolaihess@gmail.com">nicolaihess@gmail.com</a>> wrote:<br>
>>><br>
>>><br>
>>><br>
>>> 2016-12-16 22:06 GMT+01:00 Nicolai Hess <<a href="mailto:nicolaihess@gmail.com">nicolaihess@gmail.com</a>>:<br>
>>><br>
>>><br>
>>> 2016-12-15 14:46 GMT+01:00 Nicolai Hess <<a href="mailto:nicolaihess@gmail.com">nicolaihess@gmail.com</a>>:<br>
>>> Hi,<br>
>>><br>
>>> anyone knows the seaside example from the pharo by example book:<br>
>>><br>
>>> SBE2-SeasideRPN-on.1<br>
>>><br>
>>> MCSqueaksourceRepository<br>
>>>    location: '<a href="http://www.squeaksource.com/SqueakByExample" rel="noreferrer" target="_blank">http://www.squeaksource.com/<wbr>SqueakByExample</a>'<br>
>>>    user: ''<br>
>>>    password: ''<br>
>>><br>
>>> I can not get it to work. On Seaside 3.0 you need to change the class initialization,<br>
>>> because the application registration had changed.<br>
>>> But despite that, the calculator does not work. Everytime I push on a number<br>
>>> I get a empty-collection-error.<br>
>>> I don't understand why, because the rendering of the calculator stack<br>
>>> calls a method ensureStackMachineNotEmpty, that puts a 0 onto the stack.<br>
>>> Now, pushing a keypad button for a number, will pop this element and convert both<br>
>>> the existing number and the new number to a new number.<br>
>>> But somehow the stack is empty, eventhough we call ensureStackMachineNotEmpty.<br>
>>><br>
>>> Anyone has experience with this example or can find out what is wrong ?<br>
>>> I don't have much experience with seaside.<br>
>>><br>
>>> thanks in advance.<br>
>>><br>
>>> Ah, on seaside 3.0 the current (initial state) of the StackMachine is saved once before the rendering (WASnapshot), and if we modify the stack machine state (the OrderedCollection)<br>
>>> during #renderContentsOn:, the prior state (with the empty stack) is restored before executing the callbacks.<br>
>>> This had changed, in seaside 2.8, saving the state snapshots happens first after the initial rendering.<br>
>>> Was this change on purpose ? Is there some information about, when it is  allowed to modify the state during rendering ?<br>
>>><br>
>>> I guess we may have to make sure that any state changes are happening outside of the rendering, is there some ~pattern~ to follow, when it is save to change states ?<br>
>>><br>
>>> thanks in advance<br>
>>><br>
>>> nicolai<br>
>>><br>
>>><br>
>>><br>
>>> Ok I found a hint in <a href="http://book.seaside.st/book/fundamentals/anchors/about-callbacks" rel="noreferrer" target="_blank">http://book.seaside.st/book/<wbr>fundamentals/anchors/about-<wbr>callbacks</a><br>
>>> "Important : Do not change state while rendering....."<br>
>>><br>
>>> Ok, so the old RPNCalculator example does not work anymore if we try to "ensure the stack is not empty" during then renderContentsOn: method.<br>
>>> Now I need to find a way to ensure the stackmachine non-emptyness before doing the rendering.<br>
>>><br>
>>> Is there a hook, called before the rendering, that *can* change the component state ?<br>
>>><br>
>>><br>
>>> ______________________________<wbr>_________________<br>
>>> seaside mailing list<br>
>>> <a href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.<wbr>squeakfoundation.org</a><br>
>>> <a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" rel="noreferrer" target="_blank">http://lists.squeakfoundation.<wbr>org/cgi-bin/mailman/listinfo/<wbr>seaside</a><br>
>><br>
>> ______________________________<wbr>_________________<br>
>> seaside mailing list<br>
>> <a href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.<wbr>squeakfoundation.org</a><br>
>> <a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" rel="noreferrer" target="_blank">http://lists.squeakfoundation.<wbr>org/cgi-bin/mailman/listinfo/<wbr>seaside</a><br>
>><br>
>> ______________________________<wbr>_________________<br>
>> seaside mailing list<br>
>> <a href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.<wbr>squeakfoundation.org</a><br>
>> <a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" rel="noreferrer" target="_blank">http://lists.squeakfoundation.<wbr>org/cgi-bin/mailman/listinfo/<wbr>seaside</a><br>
<br>
______________________________<wbr>_________________<br>
seaside mailing list<br>
<a href="mailto:seaside@lists.squeakfoundation.org">seaside@lists.<wbr>squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside" rel="noreferrer" target="_blank">http://lists.squeakfoundation.<wbr>org/cgi-bin/mailman/listinfo/<wbr>seaside</a><br>
</div></div></blockquote></div><br></div></div>