[Pharo-project] Moment of fun
Hi guys I would like to build a small lectures based on all the small little crazy expressions that we use like StandardWindow allInstances do: #close. or myObject pointersTo or anObject become: String new. Do you have some cool expressions to share with me. Stef
On Apr 30, 2013, at 10:56 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
anObject become: String new.
for become: related teaching, this is fun: magic #thisIsMagiC isSymbol ifTrue: [#thisIsMagiC become: #(0)]. #thisIsMagiC at: 1 put: (#thisIsMagiC at: 1) +1. ^#thisIsMagiC first.
I was more thinking in something useful :) On Apr 30, 2013, at 11:07 PM, Marcus Denker <marcus.denker@inria.fr> wrote:
On Apr 30, 2013, at 10:56 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
anObject become: String new.
for become: related teaching, this is fun:
magic #thisIsMagiC isSymbol ifTrue: [#thisIsMagiC become: #(0)]. #thisIsMagiC at: 1 put: (#thisIsMagiC at: 1) +1. ^#thisIsMagiC first.
On 1 mai 2013, at 14:03, stephane ducasse wrote:
I was more thinking in something useful :)
Not really useful but fun: simulate classes, subclasses and objects with blocks: makeCounter := [ | this value | value := 0. this := Dictionary new at: #set put: [ :newValue | value := newValue ]; at: #get put: [ value ]; at: #incr put: [ value := value + 1 ]; at: #reset put: [ (this at: #set) value: 0 ]; yourself ]. makeDecrCounter := [ | this | this := makeCounter value at: #decr put: [ (this at: #set) value: (this at: #get) value - 1 ]; yourself ]. aCounter := makeCounter value. (aCounter at: #incr) value. (aCounter at: #set) value: 10. (aCounter at: #reset) value. aDecrCounter := makeDecrCounter value. (aDecrCounter at: #decr) value
On Apr 30, 2013, at 11:07 PM, Marcus Denker <marcus.denker@inria.fr> wrote:
On Apr 30, 2013, at 10:56 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
anObject become: String new.
for become: related teaching, this is fun:
magic #thisIsMagiC isSymbol ifTrue: [#thisIsMagiC become: #(0)]. #thisIsMagiC at: 1 put: (#thisIsMagiC at: 1) +1. ^#thisIsMagiC first.
Hmmm, smells like Lisp (not necessarily bad)⦠On 01 May 2013, at 16:27, Camille Teruel <camille.teruel@gmail.com> wrote:
On 1 mai 2013, at 14:03, stephane ducasse wrote:
I was more thinking in something useful :)
Not really useful but fun: simulate classes, subclasses and objects with blocks:
makeCounter := [ | this value | value := 0. this := Dictionary new at: #set put: [ :newValue | value := newValue ]; at: #get put: [ value ]; at: #incr put: [ value := value + 1 ]; at: #reset put: [ (this at: #set) value: 0 ]; yourself ].
makeDecrCounter := [ | this | this := makeCounter value at: #decr put: [ (this at: #set) value: (this at: #get) value - 1 ]; yourself ].
aCounter := makeCounter value. (aCounter at: #incr) value. (aCounter at: #set) value: 10. (aCounter at: #reset) value.
aDecrCounter := makeDecrCounter value. (aDecrCounter at: #decr) value
On Apr 30, 2013, at 11:07 PM, Marcus Denker <marcus.denker@inria.fr> wrote:
On Apr 30, 2013, at 10:56 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
anObject become: String new.
for become: related teaching, this is fun:
magic #thisIsMagiC isSymbol ifTrue: [#thisIsMagiC become: #(0)]. #thisIsMagiC at: 1 put: (#thisIsMagiC at: 1) +1. ^#thisIsMagiC first.
I really love the use of fuel to serialize errors on the build server: ------------------------------------------------------------------------- [ "some code causing an error" Error signal ] on: Error do: [ :error | FLSerializer serialize: error toFileNamed: 'error.fuel' ] ------------------------------------------------------------------------- Then in a new image open a debugger on the serialized error: ------------------------------------------------------------------------- error := FLMaterializer materializeFromFileNamed: 'error.fuel'. error debug.
Yes, great superpowers! A bit more lightweight and efficient than abort(); gdb myApp core A small reminder for myself: [ (Delay forSeconds: 2 hours asSeconds) wait. WorldState addDeferredUIMessage: [ UIManager default inform: 'You''re Smalltalking too much There are other nice things worth in life' ]. ] fork 2013/5/1 Camillo Bruni <camillobruni@gmail.com>
I really love the use of fuel to serialize errors on the build server: -------------------------------------------------------------------------
[ "some code causing an error" Error signal ] on: Error do: [ :error | FLSerializer serialize: error toFileNamed: 'error.fuel' ]
------------------------------------------------------------------------- Then in a new image open a debugger on the serialized error: -------------------------------------------------------------------------
error := FLMaterializer materializeFromFileNamed: 'error.fuel'. error debug.
On 2013-05-01, at 19:01, Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com> wrote:
Yes, great superpowers! A bit more lightweight and efficient than abort(); gdb myApp core
A small reminder for myself:
[ (Delay forSeconds: 2 hours asSeconds) wait. WorldState addDeferredUIMessage: [ UIManager default inform: 'You''re Smalltalking too much There are other nice things worth in life' ]. ] fork
in Pharo 3.0 you can write that a tad more elegant: [ WorldState addDeferredUIMessage: [ UIManager default inform: 'You''re Smalltalking too much There are other nice things worth in life' ]. ] valueAfterWaiting: 2 hours and in general for waiting on delays you now can do: 2 hours wait that hides away quite some details :)
Oh, sure much more expressive! I learned some of those low level snippets 25 years ago and seems to have an inability to forget them ;) 2013/5/1 Camillo Bruni <camillobruni@gmail.com>
On 2013-05-01, at 19:01, Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com> wrote:
Yes, great superpowers! A bit more lightweight and efficient than abort(); gdb myApp core
A small reminder for myself:
[ (Delay forSeconds: 2 hours asSeconds) wait. WorldState addDeferredUIMessage: [ UIManager default inform: 'You''re Smalltalking too much There are other nice things worth in life' ]. ] fork
in Pharo 3.0 you can write that a tad more elegant:
[ WorldState addDeferredUIMessage: [ UIManager default inform: 'You''re Smalltalking too much There are other nice things worth in life' ]. ] valueAfterWaiting: 2 hours
and in general for waiting on delays you now can do:
2 hours wait
that hides away quite some details :)
On May 1, 2013, at 7:01 PM, Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com> wrote:
Yes, great superpowers! A bit more lightweight and efficient than abort(); gdb myApp core
A small reminder for myself:
[ (Delay forSeconds: 2 hours asSeconds) wait. WorldState addDeferredUIMessage: [ UIManager default inform: 'You''re Smalltalking too much There are other nice things worth in life' ]. ] fork
Excellent! I added that one too :) Stef
Yes! That's a great one :) I added to my presentation. Stef On May 1, 2013, at 6:38 PM, Camillo Bruni <camillobruni@gmail.com> wrote:
I really love the use of fuel to serialize errors on the build server: -------------------------------------------------------------------------
[ "some code causing an error" Error signal ] on: Error do: [ :error | FLSerializer serialize: error toFileNamed: 'error.fuel' ]
------------------------------------------------------------------------- Then in a new image open a debugger on the serialized error: -------------------------------------------------------------------------
error := FLMaterializer materializeFromFileNamed: 'error.fuel'. error debug.
On Tue, Apr 30, 2013 at 12:52 PM, Stéphane Ducasse < stephane.ducasse@inria.fr> wrote:
Hi guys
I would like to build a small lectures based on all the small little crazy expressions that we use like
StandardWindow allInstances do: #close.
or
myObject pointersTo
or
anObject become: String new.
Do you have some cool expressions to share with me.
Stef
my favourite, used to lock up Smalltalk VMs: | pair | pair := { #perform:withArguments:. nil }. pair at: 2 put: pair. pair perform: pair first withArguments: pair. -- best, Eliot
Eliot, you're insane :-) A useful one: Debugger closeAllDebuggers Alexandre
| pair | pair := { #perform:withArguments:. nil }. pair at: 2 put: pair. pair perform: pair first withArguments: pair.
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
| recursion | ( recursion := [ recursion value ] ) value On 30 April 2013 23:56, Eliot Miranda <eliot.miranda@gmail.com> wrote:
On Tue, Apr 30, 2013 at 12:52 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
Hi guys
I would like to build a small lectures based on all the small little crazy expressions that we use like
StandardWindow allInstances do: #close.
or
myObject pointersTo
or
anObject become: String new.
Do you have some cool expressions to share with me.
Stef
my favourite, used to lock up Smalltalk VMs:
| pair | pair := { #perform:withArguments:. nil }. pair at: 2 put: pair. pair perform: pair first withArguments: pair.
-- best, Eliot
-- Best regards, Igor Stasenko.
On Wed, May 1, 2013 at 11:46 AM, Igor Stasenko <siguctua@gmail.com> wrote:
| recursion | ( recursion := [ recursion value ] ) value
At least make it useful. fibonacci := [ :i :j | Transcript show: ((i+j) printString); cr. fibonacci value: j value:(i+j). ]. fibonacci value: 1 value: 1. Doesn't work on my ancient 3.10 image though, but it does run under VW, and might work on more modern closure-capable VMs. Gulik. -- http://gulik.pbwiki.com/
On 1 May 2013 04:17, Michael van der Gulik <mikevdg@gmail.com> wrote:
On Wed, May 1, 2013 at 11:46 AM, Igor Stasenko <siguctua@gmail.com> wrote:
| recursion | ( recursion := [ recursion value ] ) value
At least make it useful.
Useful? :) Let me count, how many times i used Fibonacci sequence in my projects....... 0 + 0 + 0 + 0 + ... + 0 = zero. so.. to me your example is as useful as mine :)
fibonacci := [ :i :j | Transcript show: ((i+j) printString); cr. fibonacci value: j value:(i+j). ]. fibonacci value: 1 value: 1.
Doesn't work on my ancient 3.10 image though, but it does run under VW, and might work on more modern closure-capable VMs.
Gulik.
-- Best regards, Igor Stasenko.
Another useful ones: Smalltalk garbageCollect Object browse Object halt Object haltOnce Object inspect On Apr 30, 2013, at 3:52 PM, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
Hi guys
I would like to build a small lectures based on all the small little crazy expressions that we use like
StandardWindow allInstances do: #close.
or
myObject pointersTo
or
anObject become: String new.
Do you have some cool expressions to share with me.
Stef
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
Hello. (UpdatingStringMorph on: otherMorph selector: #position) openInWorld. and then move otherMorph on screen or (UpdatingStringMorph on: otherMorph selector: #extent) openInWorld. and then resize otherMorph 2013/4/30 Stéphane Ducasse <stephane.ducasse@inria.fr>
Hi guys
I would like to build a small lectures based on all the small little crazy expressions that we use like
StandardWindow allInstances do: #close.
or
myObject pointersTo
or
anObject become: String new.
Do you have some cool expressions to share with me.
Stef
Neat!!!
Hello.
(UpdatingStringMorph on: otherMorph selector: #position) openInWorld.
and then move otherMorph on screen
or
(UpdatingStringMorph on: otherMorph selector: #extent) openInWorld.
and then resize otherMorph
2013/4/30 Stéphane Ducasse <stephane.ducasse@inria.fr> Hi guys
I would like to build a small lectures based on all the small little crazy expressions that we use like
StandardWindow allInstances do: #close.
or
myObject pointersTo
or
anObject become: String new.
Do you have some cool expressions to share with me.
Stef
participants (12)
-
Alexandre Bergel -
Camille Teruel -
Camillo Bruni -
Denis Kudriashov -
Eliot Miranda -
Igor Stasenko -
Marcus Denker -
Michael van der Gulik -
Nicolas Cellier -
stephane ducasse -
Stéphane Ducasse -
Sven Van Caekenberghe