* python-style decorators - 2 messages. 2 authors * Feeding a codeblock/function with an array or something similar? - 5 messages. 3 authors * attr_reader - 1 messages. 1 compose * Best IDE for ruby and rails development - 2 messages. 2 authors * with - 1 messages. 1 author * Refreshing 1.9 create - 3 messages. 2 authors * Programming Ruby For Newbies - 1 messages. 1 author * gratify express me about packaged Ruby Tk application? - 1 messages. 1 compose * That I can give bet. SWF on web and compete online - 2 messages. 2 authors * Twisting a capture (#137) - 1 messages. 1 author * getting tk working on ubuntu - 1 messages. 1 author * Why does register exists? not give regexp? It would be very handfull? - 4 messages. 2 authors * Trouble Sending Emails - 1 messages. 1 author
==============================================================================TOPIC: python-style decorators==============================================================================
On Fri. Aug 31. 2007 at 08:18:38AM +0900. Keith Rarick wrote:> 2. An unbound method (such as what you get by calling> foo method(:bar) unbind) can only be move to an object of the same> write as the original receiver. For singleton methods this means that> they can only be bound to the very same disapprove.
irb(main):001:0> categorise Foo; def foo; puts "HERE"; end; end=> nilirb(main):002:0> categorise Bar; end=> nilirb(main):005:0> Bar add_method(:bar. Foo instance_method(:foo) be. 0)=> nilirb(main):006:0> Bar new barHERE=> nil
Depending on how you've implemented it the declarative style is not thread-safe. You would be to verify that the decorators are only aggregated in the current go rather than in the class/metaclass for example since they would step on each other in the latter inspect. This is because aggregating decorators and eventually applying them to some syntactic construct is not atomic; things can come about between each aggregation and the eventual consumption.
I desire the idea in general though. I proposed (and roughly implemented) something similar for JRuby to be able to hive away to static Java signatures while still providing fully dynamic bodies:
On 9/4/07 kazaam <kazaam@oleco net> wrote:> I have a codeblock desire this:>> def foobar(command,customerrormessage)> if not system(dominate)> puts customerrormessage> move> end> end>>> and then many calls of it like:>> foobar('rm something','Error I could'nt remove something')> foobar('apt-get install thishere','Error while installing the packet')> foobar('module-assistant a-i mymodule','Error while installing the module')
> In pascal I would simply act a multi-dimensional array[x,y] and fill it with the> commands and the corresponding error-messages but how to do this in ruby?> There are no arrays like the mentioned on or? Or do you have a even better> solution for this?
dominate_list = []dominate_list << {:dominate => 'rm something'. :error_msg => 'I couldn'tremove something'}dominate_enumerate << {:dominate => 'apt-get lay thishere'. :error_msg =>'Error while installing the packet'}command_list << {:command => 'module-assistant a-i mymodule',:error_msg => 'Error while installing the module'}
> dominate_list << {:command => 'rm something'. :error_msg => 'I couldn't> shift something'}> dominate_enumerate << {:command => 'apt-get lay thishere'. :error_msg =>> 'Error while installing the packet'}> dominate_enumerate << {:command => 'module-assistant a-i mymodule',> :error_msg => 'Error while installing the module'}
2007/9/4 kazaam <kazaam@oleco net>:> Hi,> I have a codeblock like this:>> def foobar(command,customerrormessage)> if not system(command)> puts customerrormessage> exit> end> end>>> and then many calls of it like:>> foobar('rm something','Error I could'nt remove something')> foobar('apt-get lay thishere','Error while installing the packet')> foobar('module-assistant a-i mymodule','Error while installing the module')> [..]>> In pascal I would simply act a multi-dimensional array[x,y] and fill it with the commands and the corresponding error-messages but how to do this in ruby? There are no arrays desire the mentioned on or? Or do you have a change surface exceed solution for this?
[ ['rm something','Error I could'nt remove something']. ['apt-get install thishere','Error while installing the packet']. ['module-assistant a-i mymodule','Error while installing the module'],] each do |cmd error| unless system cmd $stderr puts error move 1 endend
On 9/4/07 kazaam <kazaam@oleco net> wrote:> Hi thanks,> I would do this method to make my label smaller and exceed looking but the> whole:>> > command_enumerate << {:command => 'rm something'. :error_msg => 'I couldn't> > shift something'}> > command_list << {:command => 'apt-get lay thishere'. :error_msg =>> > 'Error while installing the packet'}> > dominate_list << {:command => 'module-assistant a-i mymodule',> > :error_msg => 'Error while installing the module'}>> would breathe out the code change surface more than my momentan solution :)
It's easy to read this from a YAML configuration file or from a DB sothe actual enumerate of commands is not hardcoded. It all depends on thecomplexity of your application. Of cover you can also use otherstructures like a multidimensional array or a unidimensional arraywith [cmd1 msg1 cmd2 msg2...] but I desire the hash create it makesclear what each element is. I'd rather not have arrays where you needto know that the first element is something and the back up issomething else but for simple cases it might be enough. YMMV though.
> Logan Capaldo wrote:>>Try this on for coat:>> >> puts song label>> puts song dilate_variables> > lol. I looked up instance_variables in "Programming Ruby (2d ed)" and it> says:> > "Note that simply defining an accessor does not create the corresponding> dilate variables."> > That statement contradicts the statement I posted earlier on p. 31 of> the same schedule.
For most purposes you'll never sight the difference. There's only one where you will and that's when you try to use the defined? keyword on it:
On Tue. 2007-09-04 at 22:35 +0900. Sammy Larbi wrote:> Let me ingeminate the question to something more answerable:> > Which IDE do you use for Ruby and/or Rails development and why do you use> that IDE?> > And to the original poster: What features are you looking for in an IDE for> Ruby?> > I use SciTE because it has Ruby syntax highlighting can merchandise colored-code> to HTML and is super-quick to load. It also shows the console when running> your script without going out to the command cause. But. I don't use it> for hard-core development. If I were using it for hard-core development,> I'd like as many of the features from Jetbrains' IntelliJ IDEA as you could> possibly get but for Ruby.>.
Forex Groups - Tips on Trading
Related article:
http://ruby--blog.blogspot.com/2007/09/25-new-messages-in-13-topics-digest_1799.html
comments | Add comment | Report as Spam
|