Ruby wish-list

> If I wanted something "intuitive",
>
> /*
> I'd probably prefer something like this,
> */
>
> since that's what I'm used to for multiline comments. On the

other

> hand,
>
> =begin
> this seems a lot more Ruby-idiomatic to me,
> =end
>
> so I like it just fine.

Yeah /* comments */ would be sweet. Then you could also have

'inline'

comments, like
a = [8..9 /* bread id's */, 900..990 /* butter id's */]

Which would be awesome in some instances. Obviously these

are poor

examples, but with some it would be nice.
-R

a = [ 8..9, #ids pan
900..990 ] #ids mantequilla

···

On Wednesday 25 June 2008 18:00:54 Roger Pack wrote:
--
Universidad del Norte

Yeah /* comments */ would be sweet. Then you could also have 'inline'
comments, like
a = [8..9 /* bread id's */, 900..990 /* butter id's */]

Déjà vu?
a = [ 8..9 || "bread id's", 900..990 || "butter id's"]

Which would be awesome in some instances. Obviously these are poor
examples, but with some it would be nice.

And my technique just makes it clear how poor they are IMHO.
Robert

···

On Thu, Jun 26, 2008 at 1:00 AM, Roger Pack <rogerpack2005@gmail.com> wrote:

--
http://ruby-smalltalk.blogspot.com/

There's no one thing that's true. It's all true.
--
Ernest Hemingway

> Assuming you mean Range#to_a (i.e. an instance rather that class
> method) I don't think it's becoming obsolete.

It throws warnings as deprecated, for some reason.

I don't think so:

shadowfax:~/Documents/terralien/dltsolutions/enrollnow rick$ ruby1.9 -v
ruby 1.9.0 (2007-10-25 patchlevel 0) [i686-darwin8.10.2]
shadowfax:~/Documents/terralien/dltsolutions/enrollnow rick$ ruby1.9
-we '(1..3).to_a'

Ahh I get it. Odd

S.find 1..6.to_a

(irb):19: warning: default `to_a' will be obsolete

I was confusing that for

S.find (1..6).to_a

which works as expected. Thanks for helping me figure that out. I have
no idea why 1..6.to_a doesn't raise an exception. Oh well.
Thanks.
-=R

···

--
Posted via http://www.ruby-forum.com/\.

  * real keyword arguments in 2.0

:slight_smile:

Not sure what those are.

My latest wish, oh wishing star...

(I think something in osx does this)

begin_funcion_name param1 keep_going_function_name param2 end

# so you can have your function calls read really like English

run_if_queue_below 24 every 24 seconds

yeah :slight_smile:
Stay well.
-Roger

···

--
Posted via http://www.ruby-forum.com/\.

Marc Heiler wrote:

(By the way, an accessor_read that can query variables with ? on the end
would be nice in std ruby too... I am not complaining at all, ruby is so
flexible, I already use this for my code and i love it, like @file.readable?
that queries a "special" reader accessor... i think it reads nicer than
@file.readable but this is just my opinion)

Do you mean that attr_accessor treats symbols with a question mark
differently by creating a "symbol_without_question=" writer method and a
"symbol_with_question" reader method? For example:

  class Foo
    attr_acessor :readable? # defines Foo#readable= and Foo#readable?
  end

  f = Foo.new
  f.readable? #=> nil
  f.readable = 99
  f.readable? #=> 99

This would be very useful, because it would make the following
workaround obsolete:

  class Foo
    attr_writer :readable # only defines Foo#readable=

    def readable?
      @readable
    end
  end

Oh wishing star, here is another wish for you! :slight_smile:
Thanks for your consideration.

···

--
Posted via http://www.ruby-forum.com/\.

I personally hate elsif [as opposed to elseif or else if]. I imagine it
comes from some lesser language. Come on, is 'e' so damn hard to type?

···

--
Posted via http://www.ruby-forum.com/.

See Facets Kernel#as.

  http://facets.rubyforge.org

T.

Wow facets looks really nice! It even has the multi-hash that was a
wish a few posts ago, plus some other utilities that I've had to write
from scratch before [but not anymore]. Rock on.
-R

···

--
Posted via http://www.ruby-forum.com/\.

a = [ 8..9, #ids pan
900..990 ] #ids mantequilla

That would work, but forces you to insert line breaks per comment, which
is livable, but exactly the reason for my wish :slight_smile:
-R

···

--
Posted via http://www.ruby-forum.com/\.

Roger Pack wrote:

  * real keyword arguments in 2.0

:slight_smile:

and the ability to parse .25 as a float, instead of 0.25 :slight_smile:

···

--
Posted via http://www.ruby-forum.com/\.

I would think that you would want to maintain the ? behavior across
the board. In other words, it should return TrueClass or FalseClass
objects.

Todd

···

On Nov 15, 2007 11:48 AM, Suraj Kurapati <snk@gna.org> wrote:

Marc Heiler wrote:
> (By the way, an accessor_read that can query variables with ? on the end
> would be nice in std ruby too... I am not complaining at all, ruby is so
> flexible, I already use this for my code and i love it, like @file.readable?
> that queries a "special" reader accessor... i think it reads nicer than
> @file.readable but this is just my opinion)

Do you mean that attr_accessor treats symbols with a question mark
differently by creating a "symbol_without_question=" writer method and a
"symbol_with_question" reader method? For example:

  class Foo
    attr_acessor :readable? # defines Foo#readable= and Foo#readable?
  end

  f = Foo.new
  f.readable? #=> nil
  f.readable = 99
  f.readable? #=> 99

This would be very useful, because it would make the following
workaround obsolete:

  class Foo
    attr_writer :readable # only defines Foo#readable=

    def readable?
      @readable
    end
  end

Oh wishing star, here is another wish for you! :slight_smile:
Thanks for your consideration.

def begin_funcion_name( param1, qualifier1, param2, qualifier1) {
}

run_if_queue_below 24, :every, 24, :seconds

···

On Fri, 16 Nov 2007, Roger Pack wrote:

My latest wish, oh wishing star...

(I think something in osx does this)

begin_funcion_name param1 keep_going_function_name param2 end

# so you can have your function calls read really like English

run_if_queue_below 24 every 24 seconds

--
-----------------------------------------------------------
   Tomas Pospisek
   http://sourcepole.com - Linux & Open Source Solutions
-----------------------------------------------------------

Here you go (wouldn't use it myself though):

class Module
  # get a unique alias
  method_name = '__attr_accessor__#{rand(123456789)}__#{Time.now.to_i}'
  alias_method method_name, :attr_accessor

  define_method :attr_accessor do |name|
    name = name.to_s
    if name[-1] == ??
      sname = name[0..-2]
      attr_writer sname
      define_method "#{name}" do
        instance_variable_get "@#{sname}"
      end
    else
      send(method_name, name)
    end
  end
end

class Foo
  attr_accessor :readable?
  attr_accessor :bar
end

f = Foo.new
f.readable? # => nil
f.readable = 99 # => 99
f.readable? # => 99

f.bar = 42 # => 42

Regards,
Sean

···

On Nov 15, 2007 5:48 PM, Suraj Kurapati <snk@gna.org> wrote:

Marc Heiler wrote:
> (By the way, an accessor_read that can query variables with ? on the end
> would be nice in std ruby too... I am not complaining at all, ruby is so
> flexible, I already use this for my code and i love it, like @file.readable?
> that queries a "special" reader accessor... i think it reads nicer than
> @file.readable but this is just my opinion)

Do you mean that attr_accessor treats symbols with a question mark
differently by creating a "symbol_without_question=" writer method and a
"symbol_with_question" reader method? For example:

  class Foo
    attr_acessor :readable? # defines Foo#readable= and Foo#readable?
  end

  f = Foo.new
  f.readable? #=> nil
  f.readable = 99
  f.readable? #=> 99

This would be very useful, because it would make the following
workaround obsolete:

  class Foo
    attr_writer :readable # only defines Foo#readable=

    def readable?
      @readable
    end
  end

Oh wishing star, here is another wish for you! :slight_smile:
Thanks for your consideration.

My latest wish--a GC that actually worked, instead of mongrel processes
that take 600MB and growing :slight_smile:
lol

···

--
Posted via http://www.ruby-forum.com/.

Next wish :slight_smile:
I wish you could have distinguishable separatable name-spaces, something
along the lines of

class Abc
end
namespace one
class Abc
   def func1
   end
end
end

namespace two
# class Abc will NOT have func1, right here
end

ok maybe it wouldn't be all that widespread used, but somewhat useful
for keeping code nice and separate.
Thanks for reading :slight_smile:
-R

···

--
Posted via http://www.ruby-forum.com/.

I wish that backtraces had more information, and could also display
variables and bindings, etc.

ex:
Thread.current.backtrace_bindings or $!.bindings

and outputs like

NameError: undefined local variable or method `abc' for main:Object
  from
/Users/rogerpack/dev/ruby-roger-useful-functions/irb_lookup.rb:40:in
`method_missing('abc', 34)'
  from (irb):12

Also displaying the line of code that crashed you would be sweet, a la
NameError: undefined local variable or method `abc' for main:Object
        print abc # the line in question
  from
/Users/rogerpack/dev/ruby-roger-useful-functions/irb_lookup.rb:40:in
`method_missing('abc', 34)'
  from (irb):12

Though I suppose this is indeed possible in Ruby as it currently is ex:
[1]'s source_extract function

Take care.
-R
[1]

···

--
Posted via http://www.ruby-forum.com/.

Todd Benson wrote:

I would think that you would want to maintain the ? behavior across
the board. In other words, it should return TrueClass or FalseClass
objects.

Why? In Ruby, anything that is neither nil nor false is the same as
true... I cannot express how many thousands of times this convention
has simplified my code and eased my life! Furthermore, like method
aliases, this convention falls in line with Ruby's TIMTOWDI philosophy.

So, forcing question-mark methods to return only 'true' and 'false'
feels far too restrictive and seems to follow a
there's-only-one-way-to-do-it philosophy IMHO.

···

--
Posted via http://www.ruby-forum.com/\.

run_if_queue_below 24 every 24 seconds

def begin_funcion_name( param1, qualifier1, param2, qualifier1) {
}

run_if_queue_below 24, :every, 24, :seconds

--

Clever. I like it.
-Roger

···

--
Posted via http://www.ruby-forum.com/\.

You can't determine from the size of a process whether the GC is working or not since memory (even when freed by the GC) is never returned to the OS. So with a magic 100% perfect GC, the memory footprint of your process will always reflect its peak memory usage.

You also have to determine if the GC is failing to collect dead objects or if you simply have some obscure references that are keeping large groups of objects on life support.

Gary Wright

···

On Feb 13, 2008, at 11:36 PM, Roger Pack wrote:

My latest wish--a GC that actually worked, instead of mongrel processes
that take 600MB and growing :slight_smile:

Can you show a use case where using modules as namespaces isn't enough?

···

On Apr 12, 10:49 am, Roger Pack <rogerpack2...@gmail.com> wrote:

Next wish :slight_smile:
I wish you could have distinguishable separatable name-spaces, something
along the lines of

class Abc
end
namespace one
class Abc
   def func1
   end
end
end

namespace two
# class Abc will NOT have func1, right here
end

ok maybe it wouldn't be all that widespread used, but somewhat useful
for keeping code nice and separate.
Thanks for reading :slight_smile:
-R
--
Posted viahttp://www.ruby-forum.com/.

Roger Pack wrote:

I wish that backtraces had more information, and could also display
variables and bindings, etc.

another wish:
rescue => e
really should rescue the same as
rescue # nothing

and, IMHO, rescue # blank
should rescue Exception, not just StandardError--a point of confusion to
almost all newbies :slight_smile:
Take care!
-R

···

--
Posted via http://www.ruby-forum.com/\.