Chad Perrin | 1 Mar 2007 01:04
Gravatar

Re: Functional programming in Ruby

On Thu, Mar 01, 2007 at 07:20:28AM +0900, Brian Candler wrote:
> Not a question or anything... I just wanted to share this snippet with
> any non-computer-scientist who thinks this is cool :-)
> 
> I come from very much an imperative programming background - originally
> machine code. Computer science books tend to use LISP, and I find anything
> other than the simplest example to be impenetrable. However, translating
> them to Ruby makes it much clearer to me what's going on.

If you want to play with a more "functional" language than Ruby, you
might try ML (or OCaml), Haskell, or UCBLogo.  The first of these is
pretty accessible to someone coming from an imperative and OOP
background because it is not *just* a functional language -- it also
provides integral OOP and imperative constructs.  The second can be
pretty impenetrable to someone not already familiar with functional
programming, but it is about as "pure" an FP language as you're likely
to find.  UCBLogo is like readable Lisp (complete with macros), and
there's a trilogy of college programming and CompSci textbooks available
for free online for it.  Roughly open source implementations of all
three languages are available (I say "roughly" because the OCaml license
only allows you to distribute alterations to the "official" codebase via
patches).

Of course, Ruby's good for learning functional programming concepts, up
to a point, too.  I, for one, am using Ruby more for enhancing my OOP
skills.  I'll be using the other three languages I mentioned for my
further FP investigations, I'm sure.  Of the two, I've already started
playing with OCaml and UCBLogo over the course of the last year, and
found a lot to like about both.

(Continue reading)

Mauricio Fernandez | 1 Mar 2007 01:16
Picon
Favicon

Re: rcov 0.8.0: new output modes, fix for RSpec woes, superi

On Thu, Mar 01, 2007 at 07:22:34AM +0900, Faisal N Jawdat wrote:
> On Feb 28, 2007, at 3:16 PM, Mauricio Fernandez wrote:
> >I finally decided to leave 0.8.1 for later, but I applied the patch to
> >0.8.0.2, available in tarball and gem formats.
> 
> What does that do to the version on RubyForge?

The version on Rubyforge is 0.8.0.2; both the gem and the tarball for 0.8.0.2
are available in the file area of the 'rcov' project. If you're using 1.8.5,
0.8.0 and 0.8.0.2 will behave identically. The only differences are the patch
I posted before and a similar modification in the same file that makes it work
with ruby <1.8.5.

--

-- 
Mauricio Fernandez  -   http://eigenclass.org   -  singular Ruby
                        ** Latest postings **
More logical programming in Ruby: solving Einstein's riddle (Zebra puzzle)
  http://eigenclass.org/hiki.rb?einstein-riddle-solved-in-ruby
Bounded space memoization, another new twist
  http://eigenclass.org/hiki.rb?bounded-space-memoization

Eric Hodel | 1 Mar 2007 01:22
Favicon
Gravatar

Re: tinderbox with unpublished gem

On Feb 28, 2007, at 06:14, David Chelimsky wrote:
> On 2/27/07, Eric Hodel <drbrain <at> segment7.net> wrote:
>> > Here's the output. If anything strikes you off the bat, please  
>> help.
>> > If not, I'll keep digging.
>> >
>> > $ tinderbox_gem_build rspec 0.8.0
>> > /usr/local/lib/ruby/site_ruby/1.8/rubygems/open-uri.rb:7: warning:
>> > discarding old open_uri_original_open
>>
>> Revert to rubygems 0.9.1.  0.9.2 reintroduced breakage when open-uri
>> is required.
>
> OK - I reverted to 0.9.1 and now I get something different. I placed
> the gem in tinderbox/cache, per Ryan's suggestion. I ran
> "tinderbox_gem_build rspec '0.8.0'", got an error AND discovered that
> the process had actually removed the gem from tinderbox/cache. Session
> below.
>
> Looking at gem_runner.rb, it uses a Gem::RemoteInstaller, which
> (logically) appears to only work from a remote location. So I think
> that this will need to be addressed explicitly to get it to work.

Hrm, I probably punted on this since RubyGems doesn't have a unified  
installer and I didn't want to duplicate work.  (The "install stuff"  
code is now three months old, so the details are hazy.)

> Unless there's a way I can trick rubygems into believing my local box
> is a remote repository. Can anybody help me to do that?

(Continue reading)

Eric Hodel | 1 Mar 2007 01:24
Favicon
Gravatar

Re: Rubygems Weirdness

On Feb 28, 2007, at 11:52, Steven Hansen wrote:

> Ok, I figured out the problem, I just had to setup an environment  
> variable:
>
> RUBYLIB=:/path/to/my/home/lib/ruby/site_ruby/1.8
>
> That fixed it.
>
> Oddly enough, I don't see this information anywhere on the rubygems  
> manual page:
> http://rubygems.org/read/chapter/3#page83

Can you file a bug in the RubyGems tracker?  Otherwise nobody will  
remember to fix it.

Barry Walker | 1 Mar 2007 01:28
Picon

Win32OLE trouble (custom ocx)

I'm trying to make calls to an OCX we developed in house.  The OCX is an
interface to a FireWire network.  Currently we use this OCX mostly for
C# programs.  It's several years old and fairly stable.

I have been able to access this OCX from VBScript, so I think the OCX is
script ready.

I've tried the win32ole test scripts on Excel files and they work as
described, so I'm confident Ruby and win32ole are operational.

I can see the class, the methods, and the arguments when I run soleb.rb.

I ran olegen and it created a proper looking class with all the methods.

It seems the object is created properly when I call it (at least no
errors are reported).

When I call any of the methods using .invoke or ._invoke I get the same
error message.  This error is also the same if the method requires
arguments or not.

test.rb:6:in 'invoke':method_name (or '_invoke':_invoke)
(WIN32OLERuntimeError)
  OLE error code:0 in <Unknown>
   <No Description>
  HRESULT error code:0x8000ffff
   Catastrophic failure  from test.rb:6

Can anyone point me toward the problem?

(Continue reading)

Andreas S | 1 Mar 2007 01:35
Picon
Favicon

Re: How to check if child process is still alive?


>You have to call  Process.wait to reap the child process in order for the 
>child process to disappear  entirely.
>
>Gary Wright
>

I don't want to use Process.wait because it will block. I have a queue that 
I want to refill with the next job in line when a slot is available. I'm not 
gaining much from forking jobs like this but my main purpose is to emulate 
LSF queue on local machine, in case its down or something. By doing so, the 
rest of the code still sees a queue.

I tried Ara's suggestion, but it doesn't seem to throw exception.

Thanks for such prompt response and I love how Ara, even for merely showing 
example, gave
  alias alive? alive
:)

-andre

def alive pid
  pid = Integer("#{ pid }")
  begin
    Process::kill 0, pid
    true
  rescue Errno::ESRCH
    false
  end
(Continue reading)

Shugo Maeda | 1 Mar 2007 01:38
Favicon
Gravatar

[ANN] CVS services will be permanently unavailable

Hi,

CVS services (including CVSup and CVSweb) will be permanently
unavailable on Fri Mar 16 03:00 UTC 2007.  The source code
repositry has been moved to SVN.(*1)

If you require the CVS repositry, please get it by CVSup till
that day.

Shugo
*1: http://www.ruby-lang.org/en/news/2006/12/22/cvs-repository-moved-to-svn/

Daniel DeLorme | 1 Mar 2007 02:02

object_* and instance_* methods

A while back there was a proposal to use a standard naming scheme for 
meta-programming methods. It went like this:

   object_id
   object_class (instead of class)
   object_send (instead of send)
   object_method (instead of method)

Then for all the methods that bypass access restrictions:

   instance_send (instead of funcall)
   instance_eval
   instance_exec
   instance_variable_get
   instance_variable_set
   instance_variables

The discussion didn't go much farther then but I'd like to reignite the 
bikeshed. Personally I think it's a brilliant idea; sure the method 
names are longer but that seems perfectly acceptable to me since 
meta-programming should not be used that often. The naming is consistent 
and obvious, it avoids ugliness like __send__, it reduces chances of 
naming conflict (CgiRequest#method, Email#send), it allows a simple 
pattern match to recognize any meta-programming methods, and it's 
already half implemented. Are there any other people who support this idea?

Daniel

Daniel DeLorme | 1 Mar 2007 02:17

Re: How to check if child process is still alive?

Andreas S wrote:
> 
>> You have to call  Process.wait to reap the child process in order for 
>> the child process to disappear  entirely.
> 
> I don't want to use Process.wait because it will block.

Then you should use Process.detach(child_pid)

Daniel

Jeff | 1 Mar 2007 02:19
Picon

Re: Win32OLE trouble (custom ocx)

On Feb 28, 6:28 pm, Barry Walker <barr... <at> gmail.com> wrote:
> When I call any of the methods using .invoke or ._invoke I get the same
> error message.  This error is also the same if the method requires
> arguments or not.
>
> test.rb:6:in 'invoke':method_name (or '_invoke':_invoke)
> (WIN32OLERuntimeError)
>   OLE error code:0 in <Unknown>
>    <No Description>
>   HRESULT error code:0x8000ffff
>    Catastrophic failure  from test.rb:6
>
> Can anyone point me toward the problem?

I'm pretty sure that HRESULT indicates a null pointer error.  My guess
is it's expecting an argument that you're not passing, or something
like that.  What is on line 6 of your script?

Jeff
forum.softiesonrails.com


Gmane