5 ms·
I'm still waiting (4 years now) for method#to_source. sigh http://bugs.ruby-lang.org/issues/2080 http://bugs.ruby-lang.org/issues/2080
by twelvechairs 13y ago
I'm still waiting (4 years now) for method#to_source. sigh
http://bugs.ruby-lang.org/issues/2080 http://bugs.ruby-lang.org/issues/2080
- ksec 13y agoIt changed from 2.0.0 to next minor. And this is 2.1 already. What is the course of this delay?
- steveklabnik 13y ago> What is the course of this delay? Is there a patch?
- transfire 13y agoHa! I have you beat! I've been waiting 7 years for to be able override autoload's require. https://bugs.ruby-lang.org/issues/7716 https://bugs.ruby-lang.org/issues/7716 In fact, after 10 years of dedication, b/c of this and a few other issues (and attitudes) I don't use Ruby any more.
- virtualwhys 13y agoWhat language(s) did you move on to?
- transfire 13y agoI am not 100% settled yet. I am evaluating Elixir and Go right now. There are things I like and don't like about both. I gave Haskell a shot but rejected it altogether --I have better things to do then stare at my monadic navel. But all those aside, I've concluded that the ultimate fallback is simply Javascript/Coffeescript --the syntax isn't as nice as Ruby, but you can't go wrong for interoperability. Oh, also [Crystal](https://github.com/manastech/crystal https://github.com/manastech/crystal) looks very promising, but it's too immature as of yet. Beyond that I've decide it's also time to step up work on my own language. Something I've always wanted to do for a while.
- virtualwhys 13y agoHaskell does indeed look not at all like a language that one "gets" right off the bat, although statically typed monadic operations are, for me, a must have now -- transitioned from Groovy, a poor man's Ruby (as far as MOP is concerned), to Scala a couple of years ago. Crystal looks pretty interesting, statically typed Ruby with extreme type inference. Of course that begs the question, why not JRuby? As for JS/CS, I love me some coffeescript, just a drag to debug the fat fingered typos, indentation mishaps, etc. wtf is going on moments. A TypeScript/Coffeescript hybrid would be truly awesome.
- vorg 13y ago> Groovy, a poor man's Ruby (as far as MOP is concerned) ...and as far as its static typed mode introduced in version 2, written by only one person but bundled with the dynamic compiler as if it was part of the same software. is concerned. Grales doesnt use any of it and Gradle still ships with Groovy 1.x. ...and as far as a lot of other stuff about Groovy such as its lexer/parser imlemented in Antlr 2.7, two major releases behind Antlr 4, the latest version. is concerned.
- virtualwhys 13y agoI spent the better part of 6 months in pure Groovy, getting my feet wet on the JVM, was quite enjoyable to hack around in, the syntax is nicely terse. The lack of static typing became an issue when I spent 6 months in the underworld (aka Grails in the v1.3 days) attempting to decipher voluminous stack traces whose origins lay somewhere deep in 10 layers of Grails MOP, far from one's reach. Anyway, I was frustrated with Grails, deeply so; one day on the Grails user group someone mentioned Scala. Had no idea what that was, checked it out, bought the stairway book, started hacking around in the REPL and was quickly sold.
- transfire 13y agoYou know what put me over the edge with Haskell? Monads were difficult enough, but one of the first things I wanted to do was randomly shuffle a list. That led me to this: http://www.haskell.org/haskellwiki/Random_shuffle http://www.haskell.org/haskellwiki/Random_shuffle. I knew right then that this was not the kind of language I was interested in. As for JRuby, fair point, but I'd rather steer clear of Java as much as possible. I have to use Java for Android development and it makes me cry big hippo tears every day.
- lectrick 13y agoAutoload is fundamentally broken because it makes your app state nondeterministic by making state loading and logic interdependent. I work on a large Ruby software project and we've had to move away from any autoload except for very specific cases for this reason- troubleshooting autoload bugs are the WORST. Maybe this is the reason it hasn't been looked at.
- transfire 13y agoI wish. There was a window of time when Matz said autoload would be deprecated. But he took that back after Yahuda (I think) addressed some threading issue. I agree with your assessment, but too many big names project use it --RubyGems, Psych, Rails, etc. I wrote my one load system but have never been able to use it 100% with other projects b/c I could not override autoload require. Though I've begged for years Matz just keeps blowing it off.
- MrBra 13y agoWhat have you used Ruby for in these 10 years?
- transfire 13y agoAmong other things http://github.com/rubyworks http://github.com/rubyworks.
- lectrick 13y agoHow about method(:methodname) returning the actual method object instead of a newly instantiated wrapper class containing the method metadata?
- zimbatm 13y agoirb(main):001:0> RUBY_VERSION => "2.0.0" irb(main):002:0> class Foo; def hello; puts "hello"; end; end => nil irb(main):003:0> X = Foo.new.method(:hello) => #<Method: Foo#hello> irb(main):004:0> X.class => Method irb(main):005:0> class Bar; define_method(:hello, &X); end => #<Proc:0x007f93d087a2d8 (lambda)> irb(main):006:0> Bar.new.hello hello => nil
- cronin101 13y agoI feel your pain, I (part)implemented a lambda parser that will spit out C-style expressions when given basic mathematical ruby expressions if that helps you: https://github.com/cronin101/HaDope/blob/master/lib/parsing/lambda_bytecode_parser.rb https://github.com/cronin101/HaDope/blob/master/lib/parsing/... E.g. calling with ->(i){ i * (2 + i / 4) } returns 'x * (2 + (x / 4))'
- dkubb 13y agoIt's not perfect, but I've used sourcify [1] to get Proc#to_source. I would much rather see this built into ruby itself, since there are a bunch of tools I would build with it available, but this works fairly well in practice. [1] https://github.com/ngty/sourcify https://github.com/ngty/sourcify
- cheald 13y agoFor what it's worth, if you're just looking to get at the innards of a method, Pry does this job admirably. https://gist.github.com/cheald/6674718 https://gist.github.com/cheald/6674718 https://github.com/pry/pry/wiki/Source-browsing https://github.com/pry/pry/wiki/Source-browsing Or to get the source as a string: > require 'pry' > Nokogiri.method(:HTML).source => " def HTML thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block\n Nokogiri::HTML::Document.parse(thing, url, encoding, options, &block)\n end\n"
- VeejayRampay 13y agoPry is awesome. You can even navigate your source shell-style and do all sorts of fancy things with it. Great little gem.