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

2020-01-05 Thread Santiago Dandois
It's better (conceptually and in performance) to use the inner block, but
is not always necessary. The #or: message sends the `value` message to it's
collaborator if the bolean is false. Blocks responds to value executing
theirs code, but all objects respond to value since it's defined in the
Object class as ^self. Therefore, the result is the same but the messages
involved and the order in which they are being sent are not. In
performance, for the case where the first bolean was true, is better the
one with the surrounding block , since the code inside it is never being
executed.

You should really try both versions with the debugger to see it by yourself.

Cheers,
Santiago Dandois

El dom., 5 ene. 2020 a las 19:53, xap () escribió:

> thx Rixhard. looks like or: takes an 'alternativeBlock', i.e. a block.
> however substituting a parenthesized expression (or what i assume is one)
> as
> I did before, in place of the inner block, w/ no other changes has the
> method continue to work as expected, hence my question. *shrug* i need to
> rtfm :-/
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>


Re: [Pharo-users] Prof Stef questions

2020-01-05 Thread Santiago Dandois
Hi,

I haven't run your code, but I guess that the validation of the number of
arguments of the block is failing.
The block [ 42 ] is a block with zero arguments, but when you do a value:
20, you are calling it with one argument. So it fails.

Happy Coding!

Santiago Dandois


El dom., 5 ene. 2020 a las 13:08, xap () escribió:

> hi, I'm starting out w/ pharo (as my first smalltalk-ish language). am on
> Windows 7 professional; downloaded 64-bit, pharo 8 64-bit development; then
> downgraded to pharo 7, 32-bit stable.
> I went through Prof Stef, and find 1 place of unexpected behavior:
>
> Prof Stef/Conditionals:
>
> "no surprises, prints 100"
> 1 < 2
>   ifTrue: [100]
>   ifFalse: [42].
>
> "i added a, as below, and get an error -- i would've expected a to refer to
> the block, and to be evaluable later, similar to the just prior example in
> ProfStef/Block assignation"
>
> |a|
> a := 1 < 2
>   ifTrue: [:x|x+1]
>   ifFalse: [42].
> a value: 20.
>
> What am I missing, pls?
>
>
>
>
> --
> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>
>