[#89088] More questions about =~ — GGarramuno@... (GGarramuno)

irb(main):006:1* class String

14 messages 2004/01/01

[#89119] Loop/Iterator questions — GGarramuno@... (GGarramuno)

1) Is there anything like Perl's continue block available? This is

15 messages 2004/01/02

[#89189] Best way to send mail in ruby — Bauduin Raphael <rb@...>

Hi,

11 messages 2004/01/03

[#89193] Simple Ruby DB apps/programs ... — Useko Netsumi <usenets@...>

I was wondering if there are some example of small Ruby(1.8.1) Database

14 messages 2004/01/03

[#89261] class Time doesn't pass year 2038? — Jean-Baptiste <temuphaey0@...>

15 messages 2004/01/05

[#89339] Compression (besides Huffman) and Ruby — "Josef 'Jupp' SCHUGT" <jupp@...>

Hi!

14 messages 2004/01/07

[#89367] Database applications and OOness — Tim Bates <tim@...>

People,

63 messages 2004/01/07
[#89455] Re: Database applications and OOness — "dhtapp" <dhtapp@...> 2004/01/08

I've been watching this thread with a great deal of interest. I'm

[#89456] block delimiting — Pete Yadlowsky <pmy@...> 2004/01/08

[#89465] Re: block delimiting — Austin Ziegler <austin@...> 2004/01/08

On Fri, 9 Jan 2004 04:33:15 +0900, Pete y wrote:

[#89453] ruby 1.8.1 windows installer — KONTRA Gergely <kgergely@...>

Hi!

26 messages 2004/01/08
[#89716] Re: ruby 1.8.1 windows installer — intc_ctor@... (Phil Tomson) 2004/01/12

>

[#89860] Re: ruby 1.8.1 windows installer — Alan Davies <NOSPAMcs96and@...> 2004/01/14

> Since the first edition of the Pickaxe book didn't exactly fly off the

[#89460] Re: block delimiting — "Mike Wilson" <wmwilson01@...>

21 messages 2004/01/08

[#89590] regex to NOT match? — Ruby Baby <ruby@...>

Sorry it seems like the smallest thing, but I'm stuck on this.

16 messages 2004/01/10

[#89611] Converting a string to an array of tokens — "John W. Long" <ws@...>

Is there a fast way to convert a string into a list of tokens?

17 messages 2004/01/11

[#89672] faster integer arithmetics & arbitrary precision floating number — David Garamond <lists@...6.isreserved.com>

1. Is there a way in Ruby to speed up 32bit integer arithmetics (only

43 messages 2004/01/12
[#89686] Re: faster integer arithmetics & arbitrary precision floating number — Ara.T.Howard@... 2004/01/12

On Tue, 13 Jan 2004, David Garamond wrote:

[#89709] Re: faster integer arithmetics & arbitrary precision floating number — Charles Mills <boson@...> 2004/01/12

What abouts Rubys design would make integer arithmetic slower than integer

[#89710] Re: faster integer arithmetics & arbitrary precision floating number — Dave Thomas <dave@...> 2004/01/12

[#89711] Re: faster integer arithmetics & arbitrary precision floating number — Charles Mills <boson@...> 2004/01/12

On Tue, 13 Jan 2004, Dave Thomas wrote:

[#89718] Getting the tail of a list? — Carsten Eckelmann <careck@...42.com>

Hi everybody,

19 messages 2004/01/12

[#89796] Ruby OS mentioned on /. — intc_ctor@... (Phil Tomson)

http://developers.slashdot.org/developers/04/01/13/0123250.shtml?tid=185&tid=190

20 messages 2004/01/13
[#89805] Re: Ruby OS mentioned on /. — Paul William <maillist@...> 2004/01/13

./ normally does not have vaporware... are a bunch of ruby (a very high

[#89806] Re: Ruby OS mentioned on /. — "Zach Dennis" <zdennis@...> 2004/01/13

Somehow i have this strange feeling that not all ruby peeps are strictly

[#89975] drb, firewall, ssh tunneling, and yield — Joel VanderWerf <vjoel@...>

14 messages 2004/01/16
[#89976] Re: drb, firewall, ssh tunneling, and yield — Nathaniel Talbott <nathaniel@...> 2004/01/16

On Jan 15, 2004, at 19:10, Joel VanderWerf wrote:

[#90013] Fighting Ruby's bad fame — gabriele renzi <surrender_it@...1.vip.ukl.yahoo.com>

Hi gurus and nubys,

42 messages 2004/01/16
[#90097] Re: Fighting Ruby's bad fame — ptkwt@... (Phil Tomson) 2004/01/18

In article <af53b0ba.0401171921.7cf9b9b7@posting.google.com>,

[#90023] Installing a program Unix-like — Malte Milatz <malteDELETETHIS@...>

Users of Linux, FreeBSD etc. are used to downloading an archive,

13 messages 2004/01/16

[#90077] long expression syntax — rick.hu@... (Rick Hu)

why do I get a syntax error for

13 messages 2004/01/17

[#90086] is Ruby the right language for these projects? — Ruby Baby <ruby@...>

Please forgive my self-centered question. I've been learning all about Ruby

16 messages 2004/01/18

[#90139] segfaults on mandrake... — Ferenc Engard <ferenc@...>

Hello,

16 messages 2004/01/18

[#90200] regex help — Chris Morris <chrismo@...>

I need a re such that:

18 messages 2004/01/19

[#90228] Re: New to Python: my impression v. Perl/Ruby — ptkwt@... (Phil Tomson)

In article <mailman.493.1074484056.12720.python-list@python.org>,

36 messages 2004/01/20
[#90292] Re: New to Python: my impression v. Perl/Ruby — Ville Vainio <ville.spamstermeister.vainio@...> 2004/01/20

>>>>> "Phil" == Phil Tomson <ptkwt@aracnet.com> writes:

[#90294] Re: New to Python: my impression v. Perl/Ruby — "Zach Dennis" <zdennis@...> 2004/01/20

Ville>Though "sending messages" to int literals is a syntax error.

[#90332] Re: New to Python: my impression v. Perl/Ruby — GGarramuno@... (GGarramuno) 2004/01/21

"Zach Dennis" <zdennis@mktec.com> wrote in message news:<AKEKIKLMCFIHPEAHKAAICEOHHFAA.zdennis@mktec.com>...

[#90333] Re: New to Python: my impression v. Perl/Ruby — Gregory Millam <walker@...> 2004/01/21

Received: Wed, 21 Jan 2004 16:59:59 +0900

[#90317] Re: Proposal for programming language of the year — "Volkmann, Mark" <Mark.Volkmann@...>

I think one of the main points of learning a new language each year is that

18 messages 2004/01/21

[#90354] Modules as namespace — gm@... (George Moschovitis)

Hello everyone,

16 messages 2004/01/21

[#90405] Very basic Ruby docs/books/tutorial? — Robert Feldt <feldt@...>

Hello,

12 messages 2004/01/22

[#90472] Ruby/Extensions v0.3 released — Gavin Sinclair <gsinclair@...>

A new version of Ruby/Extensions, a suite of useful methods added to

17 messages 2004/01/23

[#90505] Why is to_a going to be obsolete? — Patrick Bennett <patrick.bennett@...>

I find it immensely useful when dealing with arrays to be able to

25 messages 2004/01/23
[#90507] Re: Why is to_a going to be obsolete? — Gennady <gfb@...> 2004/01/23

Patrick Bennett wrote:

[#90510] Re: Why is to_a going to be obsolete? — Patrick Bennett <patrick.bennett@...> 2004/01/23

Hmmm, thanks, but it's a bit 'non-obvious' to casual Ruby programmers

[#90512] Re: Why is to_a going to be obsolete? — Gennady <gfb@...> 2004/01/23

[#90524] Re: Why is to_a going to be obsolete? — "T. Onoma" <transami@...> 2004/01/23

On Friday 23 January 2004 06:43 pm, Gennady wrote:

[#90598] perl bug File::Basename and Perl's nature — xah@... (Xah Lee)

Just bumped into another irresponsibility in perl.

19 messages 2004/01/25

[#90667] ruby-math and "why is ** not abelian?" — vanjac12@... (Van Jacques)

I was reading the 1st thread in the ruby-math discussion at

11 messages 2004/01/26

[#90750] choosing ruby? — Piergiuliano Bossi <p_bossi_AGAINST_SPAM@...>

We are on the way to start a new project, a web application with a bunch

20 messages 2004/01/27

[#90756] Editor — Safran von Twesla <me@...>

Hi,

20 messages 2004/01/27

[#90770] newbee question about "missing" hash methods +, += and << — benny <linux@...>

Hi,

25 messages 2004/01/27

[#90913] vimrc for Ruby or rubytidy — Theodore Knab <tjk@...>

Does someone have a '.vimrc' file they will share

17 messages 2004/01/29
[#90914] Re: vimrc for Ruby or rubytidy — "Gavin Sinclair" <gsinclair@...> 2004/01/29

> Does someone have a '.vimrc' file they will share

[#90971] time comparison — tony summerfelt <snowzone5@...>

i want to parse and trim a log file. the date format log file looks like:

13 messages 2004/01/29

[#91005] Ruby and Perl Integration — "John W. Long" <ws@...>

All this talk about RJNI has gotten me thinking. Has anyone attempted to

17 messages 2004/01/30
[#91007] Re: Ruby and Perl Integration — Thomas Adam <thomas_adam16@...> 2004/01/30

--- "John W. Long" <ws@johnwlong.com> wrote:

[#91056] principle of most suprise — tony summerfelt <snowzone5@...>

gah, ruby is doing it to me again:

31 messages 2004/01/30

[#91071] Accesing to private attributes — "Imobach =?iso-8859-15?q?Gonz=E1lez_Sosa?=" <imodev@...>

Hi all,

14 messages 2004/01/30

[#91088] flip flop operator and assignment — ptkwt@... (Phil Tomson)

I'm working on the pattern matching section for

25 messages 2004/01/31

[#91089] No difference between .. and ... flip/flop operators? — ptkwt@... (Phil Tomson)

50 messages 2004/01/31

[#91099] Ruby 1.8.1 REXML performance — Steven Jenkins <steven.jenkins@...>

I have a script that uses REXML to stream parse an XML file and load a

27 messages 2004/01/31

[#91104] graphics lib? — Alwin Blok <alwinblok@...>

Hello,

38 messages 2004/01/31
[#91262] Re: graphics lib? — Simon Strandgaard <neoneye@...> 2004/02/02

On Sun, 01 Feb 2004 16:18:50 -0600, Charles Comstock wrote:

[#91362] Re: graphics lib? — Charles Comstock <cc1@...> 2004/02/03

Simon Strandgaard wrote:

Re: Fighting Ruby's bad fame

From: GGarramuno@... (GGarramuno)
Date: 2004-01-19 19:45:01 UTC
List: ruby-talk #90201
Gavin Sinclair <gsinclair@soyabean.com.au> wrote in message news:<33606556942.20040120002034@soyabean.com.au>...
> On Monday, January 19, 2004, 1:05:02 PM, GGarramuno wrote:
> 
> > I've been using ruby for about 1 week & 1/2 and already run into that.  I
> > created String#expand_tabs() function in a module of mine only to find a
> > similar (but less efficient implementation) of that function in another popular
> > ruby library.
> 
> Could you send me the efficient implementation? :)
> 

Sure, here it is.  This implementation will perform a tiny bit slower
on short documents that are mainly separated by a single tab, but it
should perform dramatically faster in longer documents, specially
those with multiple contiguous tabs (last test, being the most
pathologial one).  Of course, the best thing would be to move these
methods from ruby onto C, if you ask me:


require "benchmark"

class String

  # Return new string with all tabs set to spaces
  def new_expand_tabs(n=8)
    n = n.to_int
    raise ArgumentError, "n must be >= 0" if n < 0
    return gsub(/\t/, '') if n == 0
    return gsub(/\t/, ' ') if n == 1
    h = self.dup
    while h.gsub!(/^([^\t\n]*)(\t+)/) { |f|
	val = ( n * $2.size - ($1.size % n) )
	$1 << (' ' * val)
      }
    end
    h
  end



  def old_expand_tabs(n=8)
    n = n.to_int
    raise ArgumentError, "n must be >= 0" if n < 0
    return gsub(/\t/, "") if n == 0
    return gsub(/\t/, " ") if n == 1
    str = self.dup
    while str =~ /\t/
      str.gsub!(/(^.*?)\t/) { |s|
	# Our match starts at the beginning of a line, so we count the
	# characters before the tab, and expand the tab to the next multiple
	# of N spaces.
	width = $1.size
	gap = n - (width % n)
	# Replace the tab with 'gap' spaces.
	$1 + (" " * gap)
      }
    end
    str
  end
  
  
end


### Dummy tests
n = 100000
s1 = "\t\t\t\t\t\tadssaa\t\t\t\t\t" * 1000
s2 = "\t\t\t\t\t\tadssaa\t\t\t\t\t\n\n\t\t\n" * n
s3 = "adssaa\t\t\t\t\t\nxxxxxxx\t\t\nyy\n" * n
s4 = "adssaa\t\t\t\t\txxxxxxx\n" * n
s5 = "\na\ta\t\a\ta\t\a\n" * n
s6 = "\na\tthis\t\is\ta\t\test\tof\thow\tgood\ttabulation\tis.\n" * n

t1 = ''
t3 = ''

Benchmark.bm { |x|
  x.report("n    ")  { t3 = s2.new_expand_tabs(); }
  x.report("o    ")  { t1 = s2.old_expand_tabs(); }  
}

if  ( t3 != t1 )
  t3.gsub!(/\t/,'-')
  t1.gsub!(/\t/,'-')
  puts "new error!",t3,".",t1 
end

Benchmark.bm { |x|
  x.report("n    ")  { t3 = s3.new_expand_tabs(); }
  x.report("o    ")  { t1 = s3.old_expand_tabs(); }  
}

puts "new error!" if  ( t3 != t1 )

Benchmark.bm { |x|
  x.report("n    ")  { t3 = s4.new_expand_tabs(); }
  x.report("o    ")  { t1 = s4.old_expand_tabs(); }  
}

puts "new error!" if  ( t3 != t1 )

Benchmark.bm { |x|
  x.report("n    ")  { t3 = s5.new_expand_tabs(); }
  x.report("o    ")  { t1 = s5.old_expand_tabs(); } 
} 

puts "new error!" if  ( t3 != t1 )

Benchmark.bm { |x|
  x.report("n    ")  { t3 = s6.new_expand_tabs(); }
  x.report("o    ")  { t1 = s6.old_expand_tabs(); } 
} 

puts "new error!" if  ( t3 != t1 )

Benchmark.bm { |x|
  x.report("n    ")  { t3 = s1.new_expand_tabs(); }
  x.report("o    ")  { t1 = s1.old_expand_tabs(); } 
} 

puts "new error!" if  ( t3 != t1 )

On my system:


      user     system      total        real
n      8.422000   0.080000   8.502000 (  8.602000)
o     53.096000   0.420000  53.516000 ( 53.858000)
      user     system      total        real
n      4.807000   0.050000   4.857000 (  4.887000)
o     20.560000   0.151000  20.711000 ( 20.830000)
      user     system      total        real
n      2.423000   0.050000   2.473000 (  2.483000)
o     13.049000   0.080000  13.129000 ( 13.270000)
      user     system      total        real
n      9.293000   0.060000   9.353000 (  9.403000)
o      9.324000   0.080000   9.404000 (  9.434000)
      user     system      total        real
n     26.097000   0.250000  26.347000 ( 26.498000)
o     40.969000   0.391000  41.360000 ( 41.529000)
      user     system      total        real
n     14.721000   5.678000  20.399000 ( 20.570000)
o    228.529000   3.365000 231.894000 (235.588000)



> What's so bad about name clashes?  

Nothing much.  Just that it is something I wouldn't be giving any
thought with python or perl, but that you tell me I may have to watch
out it for in ruby.

>  And,
> short of clashing with a library whose explicit purpose is to extend
> the built-in classes, I bet you don't even find any name clashes. :)
> 

Not sure I agree.  Do you know how many vector, matrix and so forth
libraries are out there?  All of them more or less incompatible with
each other?

> I don't like the sound of that "feature".  A well-designed library
> should be loaded in full.  In OO languages especially, you either load
> a class or you don't; you don't pick and choose methods.
> 

Personally, I'm not too interested in choosing methods, but I am in
choosing classes.
Also, think of it negatively, as I do.  What if the library you have
to use was not well designed?  What if this is found out only in the
middle of the project?  What if the person maintaining the library has
no time on their hands to fix it (or worse, refuses to change it for
some other reason)?  Do I just hack into the library and start
maintaining my own incompatible version which I would then have to
keep updating every time a new update to the master library is
released?
Between being tied and just going on my own tangent, I'd rather take
the comprise of just picking and choosing what I want to use...
without hacking into the original code.
Will I'll be using that feature often?  Heck, I hope never!  But I'll
sleep well at nights knowing that if I ever HAVE to, that feature is
already there.

> > Personally I like this phisolophy of ruby, but I NEED to have the ability to
> > easily keep changes to base classes local to my class or in an easy way to
> > revert them.
> 
> At the risk of re-igniting an old flamewar, no you don't.  Not until
> you prove that you need it anyway.  At the moment it's mere paranoia.
> 

Paranoia is good in programming.  Keeps you sane later on.
And this fear must be a plague, as searching for solutions in the ruby
world, I've seen at least 3 or 4 proposals trying to address this same
issue, including:
- behaviors
- matz's namespaces
- profile method visibility

That tells me that: a) it is a problem already or b) it is enough of a
potential future problem to merit a solution.

Personally, I prefer the namespaces approach, but any of them standard
in the language would likely be better than having none if you ask me.

In This Thread