Ruby and Expect/Tcl

Hi,

I am new to ruby, and I would like to know whether there is something
for Ruby that can help me interact with/automate other programs like
Expect for Tcl?

Thanks in advance

MT

Hello,

Some time ago I started a module to use libexpect from ruby but I finished
the project that was using it and discontinued to support it. If you or any
other wants to continue it I can help a bit.

This is the RAA link → http://www.ruby-lang.org/en/raa-list.rhtml?id=470

Bye

···

On Wed 27 Nov 2002 08:29, Minh Tang wrote:

Hi,

I am new to ruby, and I would like to know whether there is something
for Ruby that can help me interact with/automate other programs like
Expect for Tcl?

Thanks in advance

MT


Javier Fontan Muiños
jfontan@cesga.es
CESGA, Galicia Supercomputing Center

Minh Tang wrote:

Hi,

I am new to ruby, and I would like to know whether there is something
for Ruby that can help me interact with/automate other programs like
Expect for Tcl?

Thanks in advance

MT

There is an expect module out on the RAA (www.ruby-lang.org/en/raa.html)
if that helps.

Regards,

Dan

Hi all,

I got burned by this mistake:

3…5.times{ puts “yo” } -> what do you think this will do?

Only the -w flag warns me that I might be doing something wrong here.

The questions I have are:

  1. Should ‘times’ be modified to support ranges?
  2. If not, should it raise a NameError exception?

Regards,

Dan

1) Should 'times' be modified to support ranges?

Well, you want #upto no ?

2) If not, should it raise a NameError exception?

I've not understood why you want a NameError, #times return its argument

Guy Decoux

3…5.times{ puts “yo” } → what do you think this will do?

I think that it will be parsed as

3…(5.times{ puts “yo” })

That is, Ruby will do ‘5.times{ puts “yo” }’, then it will return 5
(that’s what 5.times returns), and use that 5 to do a ‘3…5’. since
that 3…5 is not doing anything, you would not notice it.

This might illustrate what you ean.

( 3…5.times{ puts “yo” } ).to_a.each { |n| puts n}

Prints:
yo
yo
yo
yo
yo
3
4
5

Hello,

You should put the range inside ().

(3…5).times { puts “yo” }

I think that rubi first evaluates 5.times { puts “yo” } before the range so
the range is 3…(5.times {puts “yo”}) and so the error.

Bye

···

On Wed 27 Nov 2002 16:38, Daniel Berger wrote:

Hi all,

I got burned by this mistake:

3…5.times{ puts “yo” } → what do you think this will do?

Only the -w flag warns me that I might be doing something wrong here.

The questions I have are:

  1. Should ‘times’ be modified to support ranges?
  2. If not, should it raise a NameError exception?

Regards,

Dan


Javier Fontan Muiños
jfontan@cesga.es
CESGA, Galicia Supercomputing Center

Hi,

Thanks alot for the info.

Javier Fontan wrote:

···

Hello,

Some time ago I started a module to use libexpect from ruby but I finished
the project that was using it and discontinued to support it. If you or any
other wants to continue it I can help a bit.

This is the RAA link → http://www.ruby-lang.org/en/raa-list.rhtml?id=470

Bye

On Wed 27 Nov 2002 08:29, Minh Tang wrote:

Hi,

I am new to ruby, and I would like to know whether there is something
for Ruby that can help me interact with/automate other programs like
Expect for Tcl?

Thanks in advance

MT

I've not understood why you want a NameError, #times return its argument

                                                         ^^^^^^^^^^^^^^^^^^^
                                                         return self

Sorry,

Guy Decoux

ts wrote:

  1. Should ‘times’ be modified to support ranges?

Well, you want #upto no ?

Yes, I realize that. I was just making a point. :slight_smile:

  1. If not, should it raise a NameError exception?

I’ve not understood why you want a NameError, #times return its argument

Guy Decoux

Because ‘times’ should fail when called by an invalid type (in this case a
Range object). Ruby doesn’t parse it that way it seems - I just thought it
should.

To answer you and the others who posted: I understand why it’s doing what
it does - I’m just wondering if the behavior should (or could) be changed.

Javier Fontan wrote:
(3…5).times { puts “yo” }

Actually, this syntactic approach does cause a NameError. :slight_smile:

Regards,

Dan

Because 'times' should fail when called by an invalid type (in this case a
Range object). Ruby doesn't parse it that way it seems - I just thought it
should.

You want an error, with this

   3..5*3

Guy Decoux

ts wrote:

Because ‘times’ should fail when called by an invalid type (in this case a
Range object). Ruby doesn’t parse it that way it seems - I just thought it
should.

You want an error, with this

3…5*3

Guy Decoux

Is that a terse way of telling me it’s a precedence issue? :wink:

To be honest, I wasn’t sure what to expect with that code, but I understand the
result.

Ok, then. What about allowing Ranges to be used with ‘times’?

(3…5).times{…} → alias for 3.upto(5){…}

I’m not really pushing for this - just curious what you think. Horrible idea?

Regards,

Dan

Ok, then. What about allowing Ranges to be used with 'times'?
(3..5).times{...} -> alias for 3.upto(5){...}

Well, actually #upto is defined only for Integer and String (I
think). Range can be constructed with any types, this mean that in this
case #upto will be defined for any object, no ?

Guy Decoux

There’s always each - (3…5).each {|i| p i}

‘times’ doesn’t sound like it iterates over the range. If I had to
define it it’d pick a random number from the range and iterate that many
times :slight_smile:

martin

···

Daniel Berger djberge@qwest.com wrote:

Ok, then. What about allowing Ranges to be used with ‘times’?

(3…5).times{…} → alias for 3.upto(5){…}

I’m not really pushing for this - just curious what you think.
Horrible idea?