Say goodbye to vars

49 views
Skip to first unread message

Ben Hoskings

unread,
Jan 31, 2013, 7:47:22 AM1/31/13
to babush...@googlegroups.com
Hi all,

Another removal, this one a long time coming :) I deprecated vars about 8 months ago, and now it's time to get rid of 'em.

I've merged a branch on 'next' that removes vars, with an upgrade helper message (using #removed!) when var-related methods are called. If you have a chance, could you give it a go and let me know if any of your deps break? I'd be happy to help you convert any old deps to use parameters.

The short version is, this old code:

dep 'psql' do
  met? { in_path?("psql >= #{var(:version, :default => '9.2')}") }
  meet { install_psql(var(:version)) }
end

Should be replaced with this:

dep 'psql', :version do
  version.default!('9.2')
  met? { in_path?("psql >= #{version}") }
  meet { install_psql(version) }
end


[ In which I ramble about the good old days ]

Vars were a really early part of the design, my first go at passing data between deps. I tried really hard to build a system that was quick to use, but in my inexperience I mistook easy for simple. I thought I had built a simple var system, but it was actually just an exercise in coupling.

(I shudder to admit that there was actually an even earlier design that employed #method_missing, before I understood why it was such a bad idea to use it. We were all young once. :) )

There was no need to declare vars; you just used them like var(:username), and away you went. But they were shared across all loaded deps, i.e. they were global state, i.e. they were doomed from the start.

There were name collisions (what does var(:version) refer to?) so vars often had unexpected values, or suddenly had their value changed halfway through a dep tree, and it was really hard to track down what was causing those changes. All in all, a bit of a catastrophe. I'm happy to say that dep parameters have solved this problem completely and vars have been unneeded for some time now.

I'm in no rush to push next to master but barring any unforeseen issues, I'll probably do so within about a week.

Cheers,
Ben

Torsten Curdt

unread,
Feb 2, 2013, 2:32:47 AM2/2/13
to babush...@googlegroups.com
I didn't even know they exist ;)

+1 on the removal

cheers,
Torsten


--
--
To post, email babush...@googlegroups.com
To unsubscribe, email babushka_app...@googlegroups.com
~
http://babushka.me
http://github.com/benhoskings/babushka
http://groups.google.com/group/babushka_app
 
---
You received this message because you are subscribed to the Google Groups "babushka_app" group.
To unsubscribe from this group and stop receiving emails from it, send an email to babushka_app...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages