[#319108] Iterator objects and lazy evaluation — Yuh-Ruey Chen <maian330@...>

Two questions:

14 messages 2008/11/01

[#319117] Poor performance of Ruby 1.8.7 when installed with MacPorts — abc <arcadiorubiogarcia@...>

Hi,

15 messages 2008/11/01

[#319176] Ruby for Philosophers — Sebastian Torena <citizenkant@...>

Hi there,

14 messages 2008/11/02

[#319196] ruby1.9: lazy versions of Enumerator#select and friends? — Brian Candler <b.candler@...>

I've been having a play with Enumerators in ruby 1.9, in particular

12 messages 2008/11/02

[#319239] Rake task for building latex? — Stefano Crocco <stefano.crocco@...>

Does anyone know whether there's a rake task to build latex files, including

10 messages 2008/11/03

[#319319] Ruby's take on S.O.L.I.D. — Mike Lopke <reglopke@...>

I'm curious about everyone's take on Bob Martin's S.O.L.I.D. design

16 messages 2008/11/03

[#319401] Combination of numbers in an array that add up to x — Hae Lee <hae.lee.subscription@...>

Objective: Find list of values in an array that adds up to a specific

17 messages 2008/11/04

[#319404] Showing a spinner ? — Aldric Giacomoni <aldric@...>

How do I show a spinner on the command line interface when a ruby script

13 messages 2008/11/04

[#319440] What would you like to know about JRuby? — Charles Oliver Nutter <charles.nutter@...>

Tom Enebo and I are putting together our JRuby presentation for

22 messages 2008/11/04

[#319532] What's the Best Way to Mimic an HTTP Request? — Daniel Miessler <daniel@...>

I'm trying to write a tool that will take a domain as an argument and

10 messages 2008/11/05

[#319546] Ruby has a Face that it wears on its feet — "Jayson Williams" <williams.jayson@...>

In my opinion, Ruby's official face should be Shoes. Shoes gives Ruby

17 messages 2008/11/05
[#319553] Re: Ruby has a Face that it wears on its feet — "Martin DeMello" <martindemello@...> 2008/11/05

On Wed, Nov 5, 2008 at 11:17 AM, Jayson Williams

[#319576] how to quickly find a string towards the end of a large io object — bwv549 <jtprince@...>

How do I scan starting at the end of a big io object to find a string

12 messages 2008/11/06

[#319702] Sudoku Generator (#182) — Matthew Moss <matt@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

14 messages 2008/11/07

[#319769] implementing mvc - using observer pattern - beginner to OOP — Adam Akhtar <adamtemporary@...>

Hi I started making a simple command line todo list application as a way

10 messages 2008/11/08

[#319770] what's easiest way to compare a Float & BigDecimal (i.e. like a equals mechanism) — "Greg Hauptmann" <greg.hauptmann.ruby@...>

Hi,

8 messages 2008/11/08

[#319835] Moving large amount of files, 1.750.000+ — Sebastian Newstream <abeansits@...>

Hello fellow Rubyists!

15 messages 2008/11/09
[#319837] Re: Moving large amount of files, 1.750.000+ — Robert Klemme <shortcutter@...> 2008/11/09

On 09.11.2008 18:04, Sebastian Newstream wrote:

[#319861] Notepad++ (no debug output, using XP) — Ed Hardy <asm.sol@...>

Notepad++ seems to be a great editor for Ruby, in XP Windows. However,

13 messages 2008/11/10

[#319902] Problem with object methods? — Carter Davis <theshakrah@...>

I recently made an object for a game I'm making. It uses the constructor

16 messages 2008/11/10
[#319908] Re: Problem with object methods? — Hugh Sasse <hgs@...> 2008/11/10

[#319911] Re: Problem with object methods? — Carter Davis <theshakrah@...> 2008/11/10

Okay, I made an example.

[#320057] Convert text string i.e 'Peter' into integer ID — Justus Ohlhaver <ohlhaver@...>

Hello,

23 messages 2008/11/12

[#320101] Issue with block and getting to local variables — Tarek Other <cashew250@...>

Ok I'm new to ruby and want to do the following, I want to define a

12 messages 2008/11/12

[#320103] Need tutoring on using a path environment variable — dkmd_nielsen <donn@...>

I don't know what to do. I have an environment variable, PW_PATH,

11 messages 2008/11/12

[#320135] '#' characters are breaking my regexp — Max Williams <toastkid.williams@...>

I'm trying to build a regexp that includes music notes, eg Bb or C#.

14 messages 2008/11/13

[#320202] Highline - question with multiple choices — szimek <szimek@...>

Hi,

14 messages 2008/11/14
[#320208] Re: Highline - question with multiple choices — James Gray <james@...> 2008/11/14

On Nov 14, 2008, at 4:23 AM, szimek wrote:

[#320270] Re: Highline - question with multiple choices — szimek <szimek@...> 2008/11/15

On 14 Lis, 14:52, James Gray <ja...@grayproductions.net> wrote:

[#320213] Unit Conversion (#183) — Matthew Moss <matt@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

37 messages 2008/11/14

[#320280] IO#lineno= doesn't work the way I expected — Chad Perrin <perrin@...>

I'm working on something that operates on each line of a file

22 messages 2008/11/15
[#320283] Re: IO#lineno= doesn't work the way I expected — Tim Hunter <TimHunter@...> 2008/11/15

Chad Perrin wrote:

[#320286] Re: IO#lineno= doesn't work the way I expected — Chad Perrin <perrin@...> 2008/11/15

On Sun, Nov 16, 2008 at 02:27:45AM +0900, Tim Hunter wrote:

[#320287] Re: IO#lineno= doesn't work the way I expected — "Michael Guterl" <mguterl@...> 2008/11/15

On Sat, Nov 15, 2008 at 2:08 PM, Chad Perrin <perrin@apotheon.com> wrote:

[#320288] Re: IO#lineno= doesn't work the way I expected — "Michael Guterl" <mguterl@...> 2008/11/15

On Sat, Nov 15, 2008 at 2:54 PM, Michael Guterl <mguterl@gmail.com> wrote:

[#320359] Why does tmail stop my CGI script form working? — Chad Perrin <perrin@...>

I decided to try TMail for the back end of a new contact page on a

14 messages 2008/11/17

[#320370] How can I overload a method in Ruby — Zhao Yi <youhaodeyi@...>

This is my class definition:

19 messages 2008/11/17
[#320374] Re: How can I overload a method in Ruby — Einar Magn俍 Boson <einarmagnus@...> 2008/11/17

there is no overloading, only overriding.

[#320417] How to extract links of a particular class type — "Sita Rami Reddy" <sitaramireddy@...>

I have a web page which has n number of links.

11 messages 2008/11/17

[#320446] function to select only certain key/value pairs from hash? — Aryk Grosz <tennisbum2002@...>

Whenever Im coding I usually come across having to create a new hash

14 messages 2008/11/17

[#320482] I don't like specs, should I change my point of view ? — Zouplaz <user@...>

Hello, I'm not trolling. I don't like specs (RSpec) : everytime I had a

18 messages 2008/11/18

[#320500] Should is the new Must? — Trans <transfire@...>

Why did 'should' become the going nomenclature of BDD framworks?

21 messages 2008/11/18

[#320553] Syntax question from a newbie to Ruby — David Spitzer <davidspitzer@...>

I am just learning Ruby and I can not seem to see why the first example

12 messages 2008/11/18

[#320655] build hash by iterating — Jason Lillywhite <jason.lillywhite@...>

I am building a hash this way:

15 messages 2008/11/19

[#320665] Question about host, gethostbyname and getaddress — Vladimir Fekete <fekete@...>

Hi *,

11 messages 2008/11/19

[#320709] ANN: One-Click Ruby Installer 186-27 Release Candidate 2 — Luis Lavena <luislavena@...>

Hello Ruby for Windows users!

11 messages 2008/11/19

[#320811] Found a ruby bug in the URI class, what do I do? — Ben Johnson <bjohnson@...>

I'm pretty sure this is a bug, and it seem so obvious that I'm thinking

9 messages 2008/11/20

[#320908] Befunge (#184) — Matthew Moss <matt@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

28 messages 2008/11/22
[#321031] Re: [QUIZ] Befunge (#184) — Matthew Moss <matt@...> 2008/11/24

Hopefully the quiz isn't intimidating... It's a fairly simple language

[#321006] Can you run a command line script with arguments, without typing 'ruby' first? — "Jayson Williams" <williams.jayson@...>

Hi All,

29 messages 2008/11/24
[#321008] Re: Can you run a command line script with arguments, without typing 'ruby' first? — "Diogo Lisboa" <diogoslisboa@...> 2008/11/24

chmod a+x my_script (restrict permissions if you want)

[#321022] Re: Can you run a command line script with arguments, without typing 'ruby' first? — "Jayson Williams" <williams.jayson@...> 2008/11/24

I am using win os, so the shabang thing isn't an option for me. I put

[#321023] Re: Can you run a command line script with arguments, without typing 'ruby' first? — "Glen Holcomb" <damnbigman@...> 2008/11/24

On Mon, Nov 24, 2008 at 2:12 PM, Jayson Williams

[#321024] Re: Can you run a command line script with arguments, without typing 'ruby' first? — "Glen Holcomb" <damnbigman@...> 2008/11/24

On Mon, Nov 24, 2008 at 2:21 PM, Glen Holcomb <damnbigman@gmail.com> wrote:

[#321027] Re: Can you run a command line script with arguments, without typing 'ruby' first? — "Jayson Williams" <williams.jayson@...> 2008/11/24

The associations are correct. I reset them just to be sure though. I

[#321095] Re: Can you run a command line script with arguments, without typing 'ruby' first? — Daniel Schömer <daniel.schoemer@...> 2008/11/25

Jayson Williams wrote:

[#321037] Chris Pine tutorial assistance chapter 7 sort data without use of .sort method — jgheal@...

I'm learning to progam and came accross Chris Pine's Ruby Tutorial.

12 messages 2008/11/24

[#321039] Good math/stats libraries for Ruby? — Kenneth McDonald <kenneth.m.mcdonald@...>

There seem to be lots of small stats/math libraries for Ruby, but none

10 messages 2008/11/24

[#321166] time to back peddle? (Ruby 1.8.7) — Trans <transfire@...>

I just updated my Ubuntu system and was a bit surprised to find:

16 messages 2008/11/26

[#321179] How to get a reference to a block (when no explicit block parameter is used?) — Kenneth McDonald <kenneth.m.mcdonald@...>

In a function, I can find out if a block was given using block_given?,

8 messages 2008/11/26

[#321246] Performance issues with large files -- ruby vs. python :) — sa 125 <s_ayalon@...>

Hi all -

16 messages 2008/11/27
[#321248] Re: Performance issues with large files -- ruby vs. python :) — Florian Gilcher <flo@...> 2008/11/27

>

[#321271] Ruby's duck typing — "stephan.zimmer" <stephan.zimmer@...>

I would like to represent certain data by a list; to this end I let

17 messages 2008/11/27

[#321287] Programming Noob Chris Pine Tutorial sorting without use of array.sort method — whisperjim <jgheal@...>

I'm working through the following tutorial http://pine.fm/LearnToProgram/

10 messages 2008/11/27

[#321297] eRuby/erb outside of Rails — Jonny Noog <jonnynoog@...>

Hello,

18 messages 2008/11/28

[#321387] best gui toolkit — Warren Dulnuan <rr3800@...>

What is the best GUI toolkit for Ruby?

32 messages 2008/11/29
[#321397] Re: best gui toolkit — Vladimir Fekete <fekete@...> 2008/11/29

[#321421] Anyone scraping dynamic AJAX sites? — Becca Girl <cschall@...>

Hello.

12 messages 2008/11/30

[#321428] Enumerable#select used to return actual values — Mike Austin <"mike[nospam]"@...>

I'm pretty sure select used to use the actual value of the called block,

36 messages 2008/11/30
[#321432] Re: Enumerable#select used to return actual values — Robert Klemme <shortcutter@...> 2008/11/30

On 30.11.2008 04:46, Mike Austin wrote:

[#321906] Re: Enumerable#select used to return actual values — Mark Thomas <mark@...> 2008/12/04

On Nov 29, 10:46=A0pm, Mike Austin <"mike[nospam]"@mike-austin.com>

[#321912] Re: Enumerable#select used to return actual values — Trans <transfire@...> 2008/12/04

Re: IO#lineno= doesn't work the way I expected

From: Chad Perrin <perrin@...>
Date: 2008-11-17 17:23:11 UTC
List: ruby-talk #320411
On Mon, Nov 17, 2008 at 10:27:07PM +0900, Robert Klemme wrote:
> 2008/11/16 Chad Perrin <perrin@apotheon.com>:
> > On Sun, Nov 16, 2008 at 08:36:50PM +0900, Robert Klemme wrote:
> >> On 15.11.2008 20:51, Michael Guterl wrote:
> >> >On Sat, Nov 15, 2008 at 2:08 PM, Chad Perrin <perrin@apotheon.com> wr=
ote:
>=20
> >> >------------------------------------------------------------- IO#line=
no=3D
> >> >     ios.lineno =3D integer    =3D> integer
> >> >---------------------------------------------------------------------=
---
> >> >     Manually sets the current line number to the given value. +$.+ is
> >> >     updated only on the next read.
> >>
> >> There is no talk about read position in the file - just about "current
> >> line number".  Also:
> >
> > . . . which, to someone who isn't assuming "line number" is just a
> > magical number plucked out of the air, makes it sound like it moves the
> > read position to a line whose ordinal position is that of the specified
> > line number.  In other words, that's how it "sounded" to me.
>=20
> Yes, but the example makes it pretty clear that this is not the way it is:

Only if you didn't read what I just said, and thus still think everyone
in the world made the same assumption you did.


>=20
> >> >        f =3D File.new("testfile")
> >> >        f.gets                     #=3D> "This is line one\n"
> >> >        $.                         #=3D> 1
> >> >        f.lineno =3D 1000
> >> >        f.lineno                   #=3D> 1000
> >> >        $. # lineno of last read   #=3D> 1
> >> >        f.gets                     #=3D> "This is line two\n"
> >> >        $. # lineno of last read   #=3D> 1001
> >>
> >> The sample makes it very clear that the read position is not affected =
by
> >> lineno=3D because file reading obviously continues at the position whe=
re
> >> it was before.
> >
> > It only makes that clear if you assume a lot of things about what's in
> > the file in question.  I can see now, in retrospect, how you came to th=
at
> > conclusion -- but the fact that the second use of `f.gets` returns "This
> > is line two\n" doesn't *necessarily* mean that the return value is from
> > the second line of the file.
>=20
> Of course not.  But what sense would it make to create a file with a
> different content that would return "This is line two\n" when
> explaining how lineno=3D works?  The most obvious explanation is that
> someone created a file where "This is line two" is actually placed in
> the second line to demonstrate the non effect on file position.

If the point of the example was to demonstrate that, in order to get
"line two" of the output you want from line 1000 of the document, it
makes *perfect* sense.  The most obvious explanation seems to me to be
the one that supports IO#lineno=3D actually being a needed method rather
than . . . whatever the hell it actually is.


>=20
> >  I read it, initially, as meaning that
> > whatever line of the file it was, it just happened to say "This is line
> > two\n" because that made for some convenient text to have in the exampl=
e.
>=20
> Actually I believe the other interpretation is much more
> straightforward and reasonable.

Clearly, you believe that.  I believe reasonable people can come to
different conclusions about what that meant.  In other words, I believe
it's ambiguous.  The fact you cannot imagine a different interpretation
than what immediately occurred to you is a failure of your imagination,
not mine.  It seems to me that no matter how many times you look at it
you still cannot imagine how, with a different set of perfectly
reasonable starting assumptions, it means something different than you
initially thought it must mean is a result of confirmation bias rather
than a sign that I'm stupid -- especially since, as I've pointed out, I
can understand where you got your interpretation *and* where I got mine.


>=20
> > Since the contents of the file were not made clear in advance, the
> > assumption that only the second line of the file can possibly say "This
> > is line two\n" does not clarify anything for the reader except by
> > accident.  It could just mean "This is the second line of output from
> > this code."
>=20
> See above.  IMHO only a bit application of common sense will show you
> that your reasoning goes a bit astray here - although from a formal
> point of view you are right.

In my humble opinion, an application of "common sense" yields different
results based on different reasonable starting assumptions, and that you
believe my reasoning has gone a bit astray only because you are incapable
of understanding how someone can reasonably disagree with you about
initial assumptions.

You seem very invested in proving me "wrong" about the ambiguity of the
example.  Do you feel insulted somehow because you wrote the example, and
thus interpret what I'm saying as an attack?


>=20
> >> >I would think if it had the behavior you described, the second time
> >> >f.gets is called, we would see: "This is line one thousand and one\n"
> >> >not "This is line two\n"
> >>
> >> Right (if by "you" you do not mean Tim, somehow part of the thread is
> >> missing in Usenet).
> >
> > I don't see why everyone has to assume that the second line of the file
> > necessarily contains the text "This is line two\n".  It's really very
> > ambiguous.
>=20
> ... for you.

Indeed.  It's not ambiguous for you because your initial assumption
turned out to be the same as that of the example's author.  It's nice how
that works for you.

I'm not the only person who thinks the example is ambiguous as written.
In fact, I'm not even the first person in this thread who said so.  I
only said so when I realized how an alternate set of initial assumptions
led to the alternate interpretation to which you subscribe.


>=20
> > If you want a program that outputs "This is line one\nThis is
> > line two\n", and for some reason lines 0 and 1000 of the file contain
> > "This is line one\n" and "This is line two\n" respectively, the alterna=
te
> > interpretation of the way the method works makes *perfect* sense.
>=20
> Formally speaking yes, with a bit of common sense, no.

There you go again.  Apparently, "common sense" means "agrees with me" in
your little world.  Thus, when I disagree with you, I lack "common
sense".  I find that perspective somewhat limiting and egocentric, but I
guess it must reassure your self image somehow.


>=20
> > What *doesn't* make any sense to me is the idea that, for some reason,
> > it's important and common enough an operation to misnumber line numbers
> > that there has to be a `lineno=3D` method that counterfeits line number=
s.
> > What the hell is the point of that?  Please explain that to me.
>=20
> I do not know this.  IO#lineno=3D can help implementing ARGF although it
> is not needed.  Maybe ARGF is completely implemented in Ruby and
> delegates to C code for the IO handling - including line counting. In
> that case it's handy to have this setter so you can offset the line
> number of the next opened file.

Wouldn't it be even more handy, in the general case, to be able to set
the offset in the file ahead a few hundred or thousand lines of text?  It
certainly would have been more handy for me, especially since there does
not appear to be any way at all to do so in Ruby from what I've seen
without actually *reading* those lines from the IO stream, whereas what
you're talking about (implementing ARGF) is a one-time task that doesn't
actually need the existing IO#lineno=3D method at all.

--=20
Chad Perrin [ content licensed PDL: http://pdl.apotheon.org ]
Quoth H. L. Mencken: "Democracy is the theory that the common people
know what they want and deserve to get it good and hard."

In This Thread