[#400858] Support for multiple Inheritance by classes — Ross Konsolebox <lists@...>

Will Ruby ever support multiple inheritance through classes instead of

23 messages 2012/11/03
[#400859] Re: Support for multiple Inheritance by classes — Arlen Cuss <ar@...> 2012/11/03

I think I can say "no" with a fair amount of confidence.

[#400902] Re: Support for multiple Inheritance by classes — Ross Konsolebox <lists@...> 2012/11/04

Arlen Cuss wrote in post #1082618:

[#400904] Re: Support for multiple Inheritance by classes — Peter Hickman <peterhickman386@...> 2012/11/04

Even though other languages handle multiple inheritance without any

[#400865] why does UnboundMethod need to remember the class it was retrieved from (not merely owner)? — "Mean L." <lists@...>

class Base; def foo; end end

17 messages 2012/11/03

[#400914] login web page using mechanize — john smith <lists@...>

new to ruby, love the language. read programmatic programmers guide to

25 messages 2012/11/04

[#400985] How to merge two or more hashes in to one? — "Jermaine O." <lists@...>

Hi everyone.

14 messages 2012/11/06

[#401026] Site down watir-webdriver — ajay paswan <lists@...>

Whenever a site is down it keeps on looking for it for sometime and

14 messages 2012/11/07

[#401027] Closing popups watir-webdriver — ajay paswan <lists@...>

Sometimes popup comes when a link is clicked, sometimes popup comes when

14 messages 2012/11/07

[#401125] Complete newbie — "Carlos A." <lists@...>

Hey guys!

14 messages 2012/11/10

[#401161] Convert date to string — Ferdous ara <lists@...>

Hi

12 messages 2012/11/11

[#401173] question on watir — Raj pal <lists@...>

I am automating Idit application using Ruby, at one screen I can't feed

233 messages 2012/11/12

[#401191] Extending Array instances — Charles Hixson <charleshixsn@...>

I'm trying to figure out a good way to extend an Array, when the items

17 messages 2012/11/12
[#401195] Re: Extending Array instances — Brian Candler <lists@...> 2012/11/12

Charles Hixson wrote in post #1084111:

[#401200] Efficient way for comparing records between 2 large files (16 million records) — Ruby Student <ruby.student@...>

Team,

9 messages 2012/11/12

[#401274] following along with "Beginning Ruby." — Al Baker <lists@...>

I'm having trouble following along with some of the examples in this

15 messages 2012/11/15

[#401279] Question on exceptions — Justin Gamble <lists@...>

Hello! I have a simple bank program where I have to have an exception

16 messages 2012/11/15
[#401281] Re: Question on exceptions — Justin Gamble <lists@...> 2012/11/15

What is the reason of doing the .new(...)in

[#401295] Re: Question on exceptions — Brian Candler <lists@...> 2012/11/16

Justin Gamble wrote in post #1084635:

[#401296] Re: Question on exceptions — tamouse mailing lists <tamouse.lists@...> 2012/11/16

On Fri, Nov 16, 2012 at 1:43 AM, Brian Candler <lists@ruby-forum.com> wrote:

[#401301] Alternatives to methods for large number of nested "ifs" — Philip Rhoades <phil@...>

People,

11 messages 2012/11/16

[#401336] Advice for simple client/server application — Panagiotis Atmatzidis <atma@...>

Hello,

12 messages 2012/11/17

[#401364] Metaprogramming — "Aurimas N." <lists@...>

Hello,

12 messages 2012/11/19

[#401404] "undefined method `synchronize' for #<Mutex:0xa0f5adc>" from embedded Ruby program — Graham Menhennitt <graham@...>

I'm writing a C++ program (on Centos 5 Linux) that embeds a Ruby 1.9.3

9 messages 2012/11/21

[#401422] how to increase variable inside the while loop — Ferdous ara <lists@...>

Hi, my question might be confusing as its hard for me to make it clear,

12 messages 2012/11/21

[#401451] Arrays with records as objects — Steve Tucknott <lists@...>

I am completely new to Ruby.

11 messages 2012/11/22

[#401458] working with mysql in ruby — john smith <lists@...>

i have been trying to successfully connect ruby with mysql. there are a

17 messages 2012/11/22

[#401567] click on link not working with ie #watir-webdriver — ajay paswan <lists@...>

Greetings,

12 messages 2012/11/26

[#401578] atomic statements in multithreading — ajay paswan <lists@...>

suppose I am working in multiple thread each thread runs following

10 messages 2012/11/26

[#401607] Novice: Understanding instance 'variables' and methods — Steve Tucknott <lists@...>

A question - or comment - on instance variables.

10 messages 2012/11/26

[#401644] Getting the smallest Items of an Array — "Ismail M." <lists@...>

Hello guys,

14 messages 2012/11/27

[#401655] gem problems(sigh) — Al Baker <lists@...>

i tried to make a gem and tried to build the spec file and this is what

10 messages 2012/11/28

[#401688] sorting data from a file — "Ismail M." <lists@...>

Hey guys,

16 messages 2012/11/28

[#401706] Newbie question: (free) on-line courses? — Ken D'Ambrosio <ken@...>

Hello, all. There's a bunch of free on-line training for Javascript,

11 messages 2012/11/28

Re: Extending Array instances

From: Charles Hixson <charleshixsn@...>
Date: 2012-11-14 20:48:45 UTC
List: ruby-talk #401258
Brian Candler wrote:
> Charles Hixson wrote in post #1084133:
>> Hashes are slow compared to direct indexing.
> Says who?
This is a commonly true statement for a wide variety of languages.  I am 
quite likely to be translating this work into another language.  In the 
other language I am certain that it is a true statement.  Unless Array 
access is significantly slower than Hash access (which I cannot believe) 
this is the way to proceed.
>
>> Push might be a good
>> answer, but not if it allocates storage item by item.
> It doesn't. Look at the MRI C implementation if you really care: the
> underlying array storage size is increased in chunks. Ditto for Strings.
That's ok.  push was the wrong answer anyway.  The right answer was that 
Arrays automatically extend to encompass the largest index that you use 
to store into them.
>
> void
> rb_ary_store(ary, idx, val)
> ...
>      if (idx>= RARRAY(ary)->aux.capa) {
>          long new_capa = RARRAY(ary)->aux.capa / 2;
>
>          if (new_capa<  ARY_DEFAULT_SIZE) {
>              new_capa = ARY_DEFAULT_SIZE;
>          }
>          if (new_capa>= ARY_MAX_SIZE - idx) {
>              new_capa = (ARY_MAX_SIZE - idx) / 2;
>          }
>          new_capa += idx;
>          REALLOC_N(RARRAY(ary)->ptr, VALUE, new_capa);
>          RARRAY(ary)->aux.capa = new_capa;
>      }
>
> [from ruby-1.8.7-p352/array.c]
Sorry, my C isn't that good, and there are a lot of undefined terms in 
that snippet.  I can't really say I understand it.  I can usually guess 
what's going on, but undefined macros make me quite unsure...and I try 
to avoid pointers when writing code, because I want to understand it 
later.  For that matter, I usually avoid macros, too.  I realize that 
this is a common C coding style, but it's one reason I dislike C.  I'd 
prefer D, FORTRAN, or even Ada or Eiffel.  (Yaa...the code is what it 
is.  But to me what it is is confusing.)
>
>> Allocation of memory is another expensive operation
> Says who? Expensive compared to all the other things going on in your
> program? Your program will probably be creating objects
> left-right-and-centre, and having them garbage collected too.
Among system calls, allocation of memory is one of the more expensive.  
OTOH, the comment earlier about Array automatically extending itself 
answers this as there are
steps automatically taken to minimize the number of allocations of 
memory.  I don't think that using push repeatedly is a good idea (and in 
any case, it doesn't fit with my logic, unless there is something about 
the system that demands that it be done that way, which there isn't).
>
> I think you are approaching this the wrong way. I suggest you first
> write some code that works, using the most simple and logical code.
> *Then* optimise it if required: and optimise by measuring. Even for
> experienced programmers, usually the hot-spot turns out not to be where
> they guess it might be. And as you have already implied, you might need
> to optimise for memory usage over speed.
If I design the basic framework of the application around a poor design, 
I'll have to rewrite the entire thing.  This is something to get right 
at the start.  It's not a premature optimization.  There are lots of 
places where I'm taking to "do enough and patch it later" approach.  The 
reason this isn't one, is because this needs to be handled now.
>
> > From a speed point of view, I'm pretty confident in saying that the
> implementation of Hash (in C) versus the implementation of Array (in C)
> is unlikely to be the bottleneck in your program. An Array may use less
> memory than a Hash - but since the Array or Hash holds only object
> references (essentially pointers), both may be small compared to the
> memory allocated to the objects you are holding within them.
>
OK.  If it's not the bottleneck, that will be very good.  Is there ANY 
reason that Hash is a better choice?  I don't believe that there is, but 
I could be wrong.  Certainly if they are the same speed, and use about 
the same amount of memory, I would prefer to use an Array.  My 
expectation is that Array will be faster as well as using significantly 
less RAM, but were they the same, I would still prefer to use an Array, 
as it will match more nearly the preferred order of I/O (among other 
reasons).  It is true that my reasons for preferring an Array are all 
minor, and if Array has some real drawback, then I would readily switch 
to Hash.  But I haven't heard of one.  I had some questions about how to 
use it, but those have, I believe, been answered.
P.S.:  I understand that if I use a Hash, item will be retrieved in the 
order entered when I iterate through them.  This isn't my desired 
result.  I want to retrieve them in index # order.  I'd rather not have 
to sort them.

P.P.S:  A part of my design is driven by my desire to have a language 
independent form of serialization...and YAML won't work for my 
purposes.  I may decide to have an isomorphic realization of this in a 
binary serialization that isn't language independent, but that WOULD be 
premature optimization.

In This Thread