Skip to content

Commit

Permalink
update deprecated projects
Browse files Browse the repository at this point in the history
  • Loading branch information
raganwald committed Jul 24, 2012
1 parent 94e6572 commit 582168b
Show file tree
Hide file tree
Showing 20 changed files with 79 additions and 48 deletions.
@@ -1,7 +1,7 @@
With, Unhygienic, and Call-By-Name Semantics in Rewrite
---

[Rewrite](http://github.com/raganwald/rewrite/tree/master) is a gem that adds code-rewriting to the Ruby programming language. Recently, Caleb Clausen [announced](http://www.ruby-forum.com/topic/169148 "RubyMacros 0.1.0 Released - Ruby Forum") [RubyMacros](http://rubyforge.org/projects/rubymacros "RubyForge: rubymacros: Project Info"). We've had some discussion about the differences between the two projects on the Ruby Forum list and in emails: Caleb has graciously given me permission to repeat some of our discussion here.
[Rewrite](http://github.com/raganwald-deprecated/rewrite/tree/master) is a gem that adds code-rewriting to the Ruby programming language. Recently, Caleb Clausen [announced](http://www.ruby-forum.com/topic/169148 "RubyMacros 0.1.0 Released - Ruby Forum") [RubyMacros](http://rubyforge.org/projects/rubymacros "RubyForge: rubymacros: Project Info"). We've had some discussion about the differences between the two projects on the Ruby Forum list and in emails: Caleb has graciously given me permission to repeat some of our discussion here.

Note well that I will say things like "In rewrite, you can do X" and also things like "In rewrite, Y is the case." These statements do not imply that you cannot do X in RubyMacros, nor do they imply that Y is not the case in RubyMacros. They are simply statements about rewrite.

Expand Down Expand Up @@ -43,7 +43,7 @@ Or you can define them inline, just as Ruby lambdas and blocks are equivalent to
...
end

Or you can use some of the built-in rewriters from rewrite's [prelude](http://github.com/raganwald/rewrite/tree/master/lib/rewrite/prelude):
Or you can use some of the built-in rewriters from rewrite's [prelude](http://github.com/raganwald-deprecated/rewrite/tree/master/lib/rewrite/prelude):

include Rewrite::Prelude

Expand Down Expand Up @@ -71,7 +71,7 @@ following code, performing substitutions here and here and here." Rewrite suppor

Rewrite is very low-level. It uses these ridiculous s-expressions generated by a gem called ParseTree. That is not ParseTree's fault, ParseTree is giving us the very implementation-specific AST that MRI 1.8.x produces. Other Ruby implementations will have different trees. RubyMacros uses its own AST format.

Here's an example of rewrite working directly with s-expressions. It's an excerpt from [try.rb](http://github.com/raganwald/rewrite/tree/master/lib/rewrite/prelude/try.rb):
Here's an example of rewrite working directly with s-expressions. It's an excerpt from [try.rb](http://github.com/raganwald-deprecated/rewrite/tree/master/lib/rewrite/prelude/try.rb):

def process_call(exp)
# [:call, [:dvar, :foo], :try, [:array, [:lit, :bar]]]
Expand Down
2 changes: 1 addition & 1 deletion 2008-12-18/called_by_name.md
Expand Up @@ -316,7 +316,7 @@ Of course, `called_by_name` does so with lots of anonymous functions, and that i
Update (December 18, 2008)
---

I recently discovered that [rewrite](http://github.com/raganwald/rewrite/tree "raganwald's rewrite at master — GitHub") does not work with the latest versions of [ParseTree](http://rubyforge.org/projects/parsetree/ "RubyForge: ParseTree - ruby parse tree tools: Project Info"), Ruby2Ruby and their dependencies. The underlying representation of ruby code seems to have changed. For example, there are no longer any `:dvar` nodes, just `:lvar` nodes. What fun!
I recently discovered that [rewrite](http://github.com/raganwald-deprecated/rewrite/tree "raganwald's rewrite at master — GitHub") does not work with the latest versions of [ParseTree](http://rubyforge.org/projects/parsetree/ "RubyForge: ParseTree - ruby parse tree tools: Project Info"), Ruby2Ruby and their dependencies. The underlying representation of ruby code seems to have changed. For example, there are no longer any `:dvar` nodes, just `:lvar` nodes. What fun!

I am fixing this, and my first priority is to make `called_by_name` work again.

Expand Down
6 changes: 3 additions & 3 deletions 2009-01-02/flight_of_the_phoenix.md
@@ -1,7 +1,7 @@
The Flight of the Phoenix
===

I am working on a new nano-project, the [RewriteRails](https://github.com/raganwald/rewrite_rails/tree) plug-in. RewriteRails applies some of my old [Rewrite Gem](https://github.com/raganwald/rewrite/tree)'s code rewriting to Ruby projects.
I am working on a new nano-project, the [RewriteRails](https://github.com/raganwald-deprecated/rewrite_rails/tree) plug-in. RewriteRails applies some of my old [Rewrite Gem](https://github.com/raganwald-deprecated/rewrite/tree)'s code rewriting to Ruby projects.

Turning Back the Hands of Time
---
Expand All @@ -16,7 +16,7 @@ At that time I had already reached certain decisions about the role blogging (or

So, I decided to create some form of code rewriting or macro facility for Ruby. I already had certain opinions about the value of syntactic abstractions, and I had some experience writing tools that write Java code, so I figured I had a fair shot of actually finishing something worth discussing. At the very least, I figured the adventure of trying would provide grist for a presentation even if I failed.

As things turned out, I did make something that worked, the [Rewrite Gem](https://github.com/raganwald/rewrite/tree). In perverse celebration I decided to make my presentation in the form of code only. Okay, there was one little bit of Marx Brothers to kick it off, but everything else was code, and working code at that. (My presentation is on line at [InfoQ](http://www.infoq.com/presentations/braithwaite-rewrite-ruby). As you can see, I was seriously short of sleep. That's my excuse for giggling so much!)
As things turned out, I did make something that worked, the [Rewrite Gem](https://github.com/raganwald-deprecated/rewrite/tree). In perverse celebration I decided to make my presentation in the form of code only. Okay, there was one little bit of Marx Brothers to kick it off, but everything else was code, and working code at that. (My presentation is on line at [InfoQ](http://www.infoq.com/presentations/braithwaite-rewrite-ruby). As you can see, I was seriously short of sleep. That's my excuse for giggling so much!)

And then I put the Rewrite Gem aside for some little time. And last month, I picked it up again and discovered that it was broken. It seems that in my haste to put it out there, I failed to take some hygienic precautions like carefully documenting the version dependencies, and when [ParseTree](http://rubyforge.org/projects/parsetree/ "RubyForge: ParseTree - ruby parse tree tools: Project Info") and [Ruby2Ruby](http://seattlerb.rubyforge.org/ruby2ruby/ "seattlerb's ruby2ruby-1.2.1 Documentation") got some upgrades, Rewrite broke.

Expand All @@ -27,7 +27,7 @@ Whither Rewrite?

So, the Rewrite Gem broke when ParseTree and Ruby2Ruby changed some of their representations. I thought about either freezing the versions Rewrite needed or upgrading the gem, but then I had a remarkably stupid idea: Why not try to make it a little more useful than a proof-of-concept?

So, I started [RewriteRails](https://github.com/raganwald/rewrite_rails/tree). The idea is remarkably simple: You are writing a Rails project. You want to use things like [`andand`](http://weblog.raganwald.com/2008/01/objectandand-objectme-in-ruby.html "Object#andand & Object#me in Ruby") and [`String#to_proc`](http://weblog.raganwald.com/2007/10/stringtoproc.html "String#to_proc"). But you either have a fastidious disdain for opening core classes and slinging proxy objects around, a fanatical need for speed, or you want to be able to rip all that stuff out if you grow bored with it.
So, I started [RewriteRails](https://github.com/raganwald-deprecated/rewrite_rails/tree). The idea is remarkably simple: You are writing a Rails project. You want to use things like [`andand`](http://weblog.raganwald.com/2008/01/objectandand-objectme-in-ruby.html "Object#andand & Object#me in Ruby") and [`String#to_proc`](http://weblog.raganwald.com/2007/10/stringtoproc.html "String#to_proc"). But you either have a fastidious disdain for opening core classes and slinging proxy objects around, a fanatical need for speed, or you want to be able to rip all that stuff out if you grow bored with it.

RewriteRails solves all of these problems I invented that nobody is complaining about.

Expand Down
2 changes: 1 addition & 1 deletion 2009-01-06/rewrite_rails.md
@@ -1,7 +1,7 @@
RewriteRails
===

A few days ago I wrote about [RewriteRails](http://github.com/raganwald/rewrite_rails/tree/master "raganwald's rewrite_rails at master — GitHub"). I have written up some documentation and as of now, I am asking absolutely everyone--this means you--to install it into your project. The best way to move it--and Ruby as a whole--forward is to make this bullet-proof.
A few days ago I wrote about [RewriteRails](http://github.com/raganwald-deprecated/rewrite_rails/tree/master "raganwald's rewrite_rails at master — GitHub"). I have written up some documentation and as of now, I am asking absolutely everyone--this means you--to install it into your project. The best way to move it--and Ruby as a whole--forward is to make this bullet-proof.

Now, RewriteRails is not for everyone. Kindly pass this message on to some more deserving soul if you:

Expand Down
2 changes: 1 addition & 1 deletion 2009-01-12/mundane.md
Expand Up @@ -5,7 +5,7 @@ A thought crossed my mind: Many people complain about [Ruby on Rails](http://rub

Consider model classes. A few declarations... `acts_as_inscrutable`, `acts_as_magical`... And the model class gains a whole bunch of class and instance methods, plus often a whole bunch of `method_missing` behaviours that "behave like" methods. Some people complain it is hard to figure out what methods a model really has.

What if [RewriteRails](http://github.com/raganwald/rewrite_rails "raganwald's rewrite_rails at master — GitHub") were to rewrite ActiveRecord model class declarations to "mundane-ify" these magical methods? In other words, after a class has been loaded and all of the magic performed, RewriteRails writes out a `.rb` file that has the source code for all of the magic methods as if the programmer had written them in by hand.
What if [RewriteRails](http://github.com/raganwald-deprecated/rewrite_rails "raganwald's rewrite_rails at master — GitHub") were to rewrite ActiveRecord model class declarations to "mundane-ify" these magical methods? In other words, after a class has been loaded and all of the magic performed, RewriteRails writes out a `.rb` file that has the source code for all of the magic methods as if the programmer had written them in by hand.

This `.rb` file can be placed somewhere that Rails can't find it, this is a case of documentation. Now a programmer can read the mundane-ified `.rb` file to get an idea of what methods the model class actually has.

Expand Down
2 changes: 1 addition & 1 deletion 2009-04-08/sick.md
Expand Up @@ -15,7 +15,7 @@ The problem here, the thing that irritates me, is that we are using these mediev

Likewise over in La-la-lisp land we have moved from naked recursion to recursive combinators. Combinators make our programs easier to understand and reason about. Naked recursion is GOTO dressed up in a scholar's mortar and gown. Likewise naked monkey-patching is GOTO dressed up in... Well, it isn't really dressed up, it's more baggy pants performing a frontside grab.

[Metaprogramming is beautiful.](http://weblog.raganwald.com/2008/07/my-analyst-warned-me-but.html "My analyst warned me, but metaprogramming was so beautiful I got another analyst") Now that we have embraced its beauty, let's invest some time and energy taking it to the next level, finding ways to apply abstractions and constraints to it so that we can benefit from it without falling into these entirely avoidable contretemps. I've taken one swing at the bat: I think many of the extensions people have added to core classes (including #andand) ought to be syntactic abstractions rather than methods, so I wrote [RewriteRails](http://github.com/raganwald/rewrite_rails).
[Metaprogramming is beautiful.](http://weblog.raganwald.com/2008/07/my-analyst-warned-me-but.html "My analyst warned me, but metaprogramming was so beautiful I got another analyst") Now that we have embraced its beauty, let's invest some time and energy taking it to the next level, finding ways to apply abstractions and constraints to it so that we can benefit from it without falling into these entirely avoidable contretemps. I've taken one swing at the bat: I think many of the extensions people have added to core classes (including #andand) ought to be syntactic abstractions rather than methods, so I wrote [RewriteRails](http://github.com/raganwald-deprecated/rewrite_rails).

Now its your turn. Dazzle me.

Expand Down
2 changes: 1 addition & 1 deletion 2009-04-28/extension_methods.md
@@ -1,7 +1,7 @@
My Objection to Extension Methods
===

The other day I pushed an update to Rewrite Rails. The new functionality supports writing [extension methods](http://en.wikipedia.org/wiki/Extension_method "Extension method - Wikipedia, the free encyclopedia") in your Ruby on Rails projects ([documentation here](http://github.com/raganwald/rewrite_rails/blob/master/doc/extension_methods.md#readme "Extension Methods in Rewrite Rails")). To grossly oversimplify, let's say you are writing some sort of scuba dive planning program, and you want to write things like:
The other day I pushed an update to Rewrite Rails. The new functionality supports writing [extension methods](http://en.wikipedia.org/wiki/Extension_method "Extension method - Wikipedia, the free encyclopedia") in your Ruby on Rails projects ([documentation here](http://github.com/raganwald-deprecated/rewrite_rails/blob/master/doc/extension_methods.md#readme "Extension Methods in Rewrite Rails")). To grossly oversimplify, let's say you are writing some sort of scuba dive planning program, and you want to write things like:

33.fsw.in_ata
(4.5).ata.in_fsw
Expand Down
2 changes: 1 addition & 1 deletion 2009-05-25/rubyjobfair.md
@@ -1,7 +1,7 @@
Ruby Job Fair
===

I will be "presenting myself" at Unspace's [Ruby Job Fair](http://rubyjobfair.ca/) on June 6, 2009. No, I am not on my knees begging anyone for employment, nor am I looking to hire a Sith Apprentice to initiate into the dark side of the [Ruby Rewriting](http://github.com/raganwald/rewrite_rails/tree/master "Rewrite Rails") arts. I have a completely different motivation.
I will be "presenting myself" at Unspace's [Ruby Job Fair](http://rubyjobfair.ca/) on June 6, 2009. No, I am not on my knees begging anyone for employment, nor am I looking to hire a Sith Apprentice to initiate into the dark side of the [Ruby Rewriting](http://github.com/raganwald-deprecated/rewrite_rails/tree/master "Rewrite Rails") arts. I have a completely different motivation.

The Ruby Job Fair format is like a science fair: You have a "poster" to display your work, and absolutely no computers are allowed. This can be intimidating to people. What do you put on the poster? Let's read this famous story about Richard Hamming:

Expand Down
6 changes: 3 additions & 3 deletions 2009-08-29/returning.md
Expand Up @@ -103,7 +103,7 @@ So I did.

**Rewriting #returning**

The [RewriteRails](http://github.com/raganwald/rewrite_rails/tree/master) plug-in adds syntactic abstractions like [Andand](http://github.com/raganwald/rewrite_rails/tree/master/doc/andand.textile "") and [String to Block](http://github.com/raganwald/rewrite_rails/tree/master/doc/string_to_block.md#readme "") to Rails projects [without monkey-patching](http://avdi.org/devblog/2008/02/23/why-monkeypatching-is-destroying-ruby/ "Monkeypatching is Destroying Ruby"). RewriteRails now includes its own version of #returning that overrides the #returning shipping with Rails.
The [RewriteRails](http://github.com/raganwald-deprecated/rewrite_rails/tree/master) plug-in adds syntactic abstractions like [Andand](http://github.com/raganwald-deprecated/rewrite_rails/tree/master/doc/andand.textile "") and [String to Block](http://github.com/raganwald-deprecated/rewrite_rails/tree/master/doc/string_to_block.md#readme "") to Rails projects [without monkey-patching](http://avdi.org/devblog/2008/02/23/why-monkeypatching-is-destroying-ruby/ "Monkeypatching is Destroying Ruby"). RewriteRails now includes its own version of #returning that overrides the #returning shipping with Rails.

When RewriteRails is processing source code, it turns code like this:

Expand Down Expand Up @@ -144,8 +144,8 @@ Curiosity. It's easy to dismiss programmers who accidentally misuse features lik

**More**

* [RewriteRails](http://github.com/raganwald/rewrite_rails/tree/master/README.md)
* [returning.rb](http://github.com/raganwald/rewrite_rails/tree/master/lib/rewrite_rails/returning.rb "")
* [RewriteRails](http://github.com/raganwald-deprecated/rewrite_rails/tree/master/README.md)
* [returning.rb](http://github.com/raganwald-deprecated/rewrite_rails/tree/master/lib/rewrite_rails/returning.rb "")

---

Expand Down
6 changes: 3 additions & 3 deletions 2009-09-22/anaphora.md
Expand Up @@ -77,7 +77,7 @@ So while String#to\_proc allows you to write things like `(1..10).map(&'1 + it *

**UPDATE: Block anaphora in rewrite_rails**

[rewrite_rails](http://github.com/raganwald/rewrite_rails "raganwald's rewrite_rails at master - GitHub") supports `it`, `its`, or `_` as block anaphora for blocks taking one argument. Similarly to Methodphitamine, you can write:
[rewrite_rails](http://github.com/raganwald-deprecated/rewrite_rails "raganwald's rewrite_rails at master - GitHub") supports `it`, `its`, or `_` as block anaphora for blocks taking one argument. Similarly to Methodphitamine, you can write:

(1..10).map{ it * 2 + 1 } # => [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]

Expand Down Expand Up @@ -127,7 +127,7 @@ Reading about Lisp's anaphoric macros made me wonder whether anaphora for condit

if big_long_calculation(): it.foo end

This is relatively easy to accomplish using [rewrite_rails](http://github.com/raganwald/rewrite_rails "raganwald's rewrite_rails at master - GitHub"). In the most naïve case, you want to rewrite all of your if statements such that:
This is relatively easy to accomplish using [rewrite_rails](http://github.com/raganwald-deprecated/rewrite_rails "raganwald's rewrite_rails at master - GitHub"). In the most naïve case, you want to rewrite all of your if statements such that:

if big_long_calculation()
it.foo
Expand Down Expand Up @@ -232,7 +232,7 @@ Anaphora allow us to abbreviate code, hiding parameters and temporary variables
* [String#to\_proc](http://github.com/raganwald/homoiconic/blob/master/2008-11-28/you_cant_be_serious.md "You can't be serious!?") and its original [blog post](http://weblog.raganwald.com/2007/10/stringtoproc.html "String#to_proc").
* [Methodphitamine](http://github.com/jicksta/methodphitamine "jicksta's methodphitamine at master - GitHub") and its original [blog post](http://jicksta.com/posts/the-methodphitamine "The Methodphitamine at Adhearsion Blog by Jay Phillips")
* [Anaphoric macros](http://www.bookshelf.jp/texi/onlisp/onlisp_15.html "Onlisp: Anaphoric Macros")
* [rewrite_rails](http://github.com/raganwald/rewrite_rails "raganwald's rewrite_rails at master - GitHub") contains an improved implementation of String#to\_proc.
* [rewrite_rails](http://github.com/raganwald-deprecated/rewrite_rails "raganwald's rewrite_rails at master - GitHub") contains an improved implementation of String#to\_proc.
* A [usenet discussion](http://groups.google.com/group/ruby-talk-google/browse_thread/thread/26445dcef22f5a5/1772d0c487d4c570?hl=en&lnk=ol& "Introducing the "it" keyword") about anaphora in Ruby.
* [@RobertFischer](http://twitter.com/RobertFischer "Robert Fischer") pointed out that Groovy implements Block Anaphora using exactly the same syntax as rewrite\_rails, as well as mentioning that Groovy provides a special operator, `?.`, for the Maybe Monad.
* Perl has some [anaphora of its own](http://www.wellho.net/mouth/969_Perl-and-.html "Perl - $_ and @_").
Expand Down

0 comments on commit 582168b

Please sign in to comment.