> 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
(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
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
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
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
-----------------------------------------------------------
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
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
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
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.
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
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
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
-R
--
Posted viahttp://www.ruby-forum.com/.