[Pharo-project] About moving tmp closer their use
Hi guys in squeak a week ago nicolas pushed a cool (from my taste) changes that refactored the complete system so that |temp| declaration would be at the scope where they are used. This is not clear that this is an optimisation but I like the fact that temp are defined at the right place. Now it may lead to code that is a bit less readable in the sense that your temps are not systematically listed at the beginning of the method but occasionally in the closures that use them.
From my hackish lisping state of mind I like it now what do you prefer?
Stef
My own preference is a balance between being readable and efficient. At first, i care above anything to make my code readable. And I think that, being properly formatted, declaring temps in blocks scope not makes code less readable. Also, i think that keeping variables close to desired scope, will instead could help improving code readability. But i must say, we should learn & teach developers to write code short & consise, or at least attempt to (following a well known smalltalk practice - 1/2 lines per method). Then we wouldn't need to choose, what way of declaring temps is better ;) 2010/1/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
Hi guys
in squeak a week ago nicolas pushed a cool (from my taste) changes that refactored the complete system so that |temp| declaration would be at the scope where they are used. This is not clear that this is an optimisation but I like the fact that temp are defined at the right place. Now it may lead to code that is a bit less readable in the sense that your temps are not systematically listed at the beginning of the method but occasionally in the closures that use them. From my hackish lisping state of mind I like it now what do you prefer?
Stef _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.
I remember the first time I ever tried Squeak all those years ago, this was the first thing that bit me - not being able to declare temporary variables within the blocks that use them. I was so used to doing that from VisualAge. So, I vote in favour of the change :-) On Mon, Jan 4, 2010 at 1:58 PM, Igor Stasenko <siguctua@gmail.com> wrote:
My own preference is a balance between being readable and efficient. At first, i care above anything to make my code readable. And I think that, being properly formatted, declaring temps in blocks scope not makes code less readable. Also, i think that keeping variables close to desired scope, will instead could help improving code readability.
But i must say, we should learn & teach developers to write code short & consise, or at least attempt to (following a well known smalltalk practice - 1/2 lines per method). Then we wouldn't need to choose, what way of declaring temps is better ;)
2010/1/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
Hi guys
in squeak a week ago nicolas pushed a cool (from my taste) changes that refactored the complete system so that |temp| declaration would be at the scope where they are used. This is not clear that this is an optimisation but I like the fact that temp are defined at the right place. Now it may lead to code that is a bit less readable in the sense that your temps are not systematically listed at the beginning of the method but occasionally in the closures that use them. From my hackish lisping state of mind I like it now what do you prefer?
Stef _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Cheers, Peter
On Jan 4, 2010, at 2:05 PM, Peter Hugosson-Miller wrote:
I remember the first time I ever tried Squeak all those years ago, this was the first thing that bit me - not being able to declare temporary variables within the blocks that use them. I was so used to doing that from VisualAge.
Me too :) Stef
So, I vote in favour of the change :-)
On Mon, Jan 4, 2010 at 1:58 PM, Igor Stasenko <siguctua@gmail.com> wrote: My own preference is a balance between being readable and efficient. At first, i care above anything to make my code readable. And I think that, being properly formatted, declaring temps in blocks scope not makes code less readable. Also, i think that keeping variables close to desired scope, will instead could help improving code readability.
But i must say, we should learn & teach developers to write code short & consise, or at least attempt to (following a well known smalltalk practice - 1/2 lines per method). Then we wouldn't need to choose, what way of declaring temps is better ;)
2010/1/4 Stéphane Ducasse <stephane.ducasse@inria.fr>:
Hi guys
in squeak a week ago nicolas pushed a cool (from my taste) changes that refactored the complete system so that |temp| declaration would be at the scope where they are used. This is not clear that this is an optimisation but I like the fact that temp are defined at the right place. Now it may lead to code that is a bit less readable in the sense that your temps are not systematically listed at the beginning of the method but occasionally in the closures that use them. From my hackish lisping state of mind I like it now what do you prefer?
Stef _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Cheers, Peter _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Stéphane Ducasse a écrit :
Hi guys
in squeak a week ago nicolas pushed a cool (from my taste) changes that refactored the complete system so that |temp| declaration would be at the scope where they are used. This is not clear that this is an optimisation but I like the fact that temp are defined at the right place. Now it may lead to code that is a bit less readable in the sense that your temps are not systematically listed at the beginning of the method but occasionally in the closures that use them.
From my hackish lisping state of mind I like it now what do you prefer?
Yes, I always prefer to see variable declarations in the scope where they are used Alain
Stef _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Stef, I think that the issue on "readibility" is in the eyes of the beholder (a.k.a. zealot /du jour/).
From a cognitive POV having the variables 'created' and used as near as possible should make the code more understandable than having them all declared at the top of the method and used only (say as a temp variable within a block [worse if the variable is used as temp in two blocks...]).
These issues (on readibility) are less strong in Smalltalk than other languages because ST is dynamic typed and the declaration is more often than not just the name of the variable. Also, ST promotes the creation of short methods and in the average we should be able to see more or less the same way the declaration of a variable be it at the top of the method or inside a block. OTOH, while the reality still strikes us with several large methods, then the ideas of having the declaration as near of the as possible are IMO a good move. my 0.019999... -- Cesar Rabak Em 04/01/2010 10:42, Stéphane Ducasse < stephane.ducasse@inria.fr > escreveu: Hi guys in squeak a week ago nicolas pushed a cool (from my taste) changes that refactored the complete system so that |temp| declaration would be at the scope where they are used. This is not clear that this is an optimisation but I like the fact that temp are defined at the right place. Now it may lead to code that is a bit less readable in the sense that your temps are not systematically listed at the beginning of the method but occasionally in the closures that use them.
From my hackish lisping state of mind I like it now what do you prefer?
Stef _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
participants (5)
-
Alain Plantec -
csrabak@bol.com.br -
Igor Stasenko -
Peter Hugosson-Miller -
Stéphane Ducasse