About moving tmp closer their use

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

About moving tmp closer their use

Stéphane Ducasse
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
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About moving tmp closer their use

Igor Stasenko
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 <[hidden email]>:

> 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
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About moving tmp closer their use

Peter Hugosson-Miller
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 <[hidden email]> 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 <[hidden email]>:
> 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
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>



--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project



--
Cheers,
Peter

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About moving tmp closer their use

Alain Plantec-4
In reply to this post by Stéphane Ducasse
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
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>  


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About moving tmp closer their use

Stéphane Ducasse
In reply to this post by Peter Hugosson-Miller

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 <[hidden email]> 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 <[hidden email]>:
> > 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
> > [hidden email]
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
> >
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
>
> --
> Cheers,
> Peter
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: About moving tmp closer their use

csrabak
In reply to this post by Stéphane Ducasse
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 < [hidden email] > 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
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project