Are you thinking of an optimization that reduces the code size be reducing
duplicate code paths?
Or an optimization that helps factor out common paths for a programmer to
read?
I like the idea of more re-factoring (!!) and some of @erg's plans involve
a parser that will enable new tools to be built, but I'm curious what your
main motivation is...
Best,
John.
On Tue, Apr 9, 2013 at 8:18 PM, leonard <leonard14...@gmail.com> wrote:
> It occurred to me that there must be a general process by which a
> programmer refactors code.
>
> Was wondering if it has ever been attempted to codify this process.
>
> Take this program for example ...
>
> http://re-factor.blogspot.com/2013/04/move.html
>
> : usage ( -- )
>
> "Usage: move source ... target" print ;
>
> : move-to-dir ( args -- )
> dup last file-info directory?
> [ unclip-last move-files-into ] [ drop usage ] if ;
>
>
> : move-to-file ( args -- )
> dup last file-info directory?
> [ move-to-dir ] [ first2 move-file ] if ;
>
>
> : run-move ( -- )
> command-line get dup length {
> { [ dup 2 > ] [ drop move-to-dir ] }
>
> { [ dup 2 = ] [ drop move-to-file ] }
> [ 2drop usage ]
> } cond ;
>
> We could factor out ''last file-info directory?'' into a word ...
>
> : usage ( -- )
>
> "Usage: move source ... target" print ;
>
>
> : target-is-directory? ( args -- ? )
> last file-info directory?
>
> : move-to-dir ( args -- )
>
> dup target-is-directory?
> [ unclip-last move-files-into ] [ drop usage ] if ;
>
>
> : move-to-file ( args -- )
> dup target-is-directory?
> [ move-to-dir ] [ first2 move-file ] if ;
>
>
> : run-move ( -- )
> command-line get dup length {
> { [ dup 2 > ] [ drop move-to-dir ] }
>
> { [ dup 2 = ] [ drop move-to-file ] }
> [ 2drop usage ]
> } cond ;
>
> If refactoring of code may be obvious to a human, it might also be done by
> an algorithm.
>
> Or is this similar to something that already exists in the optimizing
> compiler?
>
> - Leonard
>
>
>
>
> ------------------------------------------------------------------------------
> Precog is a next-generation analytics platform capable of advanced
> analytics on semi-structured data. The platform includes APIs for building
> apps and a phenomenal toolset for data science. Developers can use
> our toolset for easy data analysis & visualization. Get a free account!
> http://www2.precog.com/precogplatform/slashdotnewsletter
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk