Markus Gaelli | 1 Sep 2006 01:16
Picon

Fwd: [Q] How would you do method extensions (sometimes called class extensions) in Ruby?

Begin forwarded message:

> From: Markus Gaelli <gaelli <at> emergent.de>
> Date: August 31, 2006 11:07:26 PM GMT+02:00
> To: ruby-core <at> ruby-lang.org
> Subject: [Q] How would you do method extensions (sometimes called  
> class extensions) in Ruby?
>
> Hi List,
>
> (1) The Problem: Bridge Gap between Tests and Documentation with  
> Executable Examples
> May I introduce myself shortly: I am a long-term OOer using mainly  
> Smalltalk until now [0] - and I am interested in bridging the gap  
> between documentation (static, bound (comments possible for classes  
> and methods), often outdated) and unit testing (dynamic, unbound  
> [2], up to date) by the metaphor of examples.
>
> (2) The Concept
> I'd like to be able to see exemplified calls for methods ("method  
> examples") - and compose new method examples using example  
> instances of classes - which in turn are created by "method  
> examples" [3]
>
> (3) The Proof of Concept
> I have some prototypes for "Eg" in Smalltalk [3], but wonder how it  
> would be possible to do something like this in Ruby.
>
> (4) My Approach in Smalltalk: Relying on Conventions and Method  
> Extensions
(Continue reading)

Markus Gaelli | 1 Sep 2006 01:16
Picon

Fwd: [Q] How would you do method extensions (sometimes called class extensions) in Ruby?


Begin forwarded message:

> From: Sam Roberts <sroberts <at> bycast.com>
> Date: August 31, 2006 11:44:20 PM GMT+02:00
> To: Markus Gaelli <gaelli <at> emergent.de>
> Subject: Re: [Q] How would you do method extensions (sometimes  
> called class extensions) in Ruby?
>
> On Fri, Sep 01, 2006 at 06:08:11AM +0900, Markus Gaelli wrote:
>> I am aware of Singleton Methods, but as they can extend instances,
>> (how) can I extend classes without changing their original class
>> definition in Ruby?
>
> This is probably best posted to ruby-talk, not ruby-core, folks would
> likely be quite interested.
>
> classes are "open" in ruby, you can add methods as you wish.
>
> irb(main):001:0> s = "hi"
> => "hi"
> irb(main):002:0> class String; def this(opt) puts(self+opt) end end
> => nil
> irb(main):003:0> s.this(" that")
> hi that
> => nil
> irb(main):004:0> "bye".this(" that")
> bye that
> => nil
>
(Continue reading)

Markus Gaelli | 1 Sep 2006 01:17
Picon

Fwd: [Q] How would you do method extensions (sometimes called class extensions) in Ruby?


Begin forwarded message:

> From: Markus Gaelli <gaelli <at> emergent.de>
> Date: September 1, 2006 1:04:50 AM GMT+02:00
> To: ruby-core <at> ruby-lang.org
> Subject: Re: [Q] How would you do method extensions (sometimes  
> called class extensions) in Ruby?
>
> Sam and Nicolas,
>
> thanks for your fast answers and pointers.
> Guess I have to subscribe to another list - which is a good thing!
> - Just wanted to be sure... ;-)
> (I therefore forward another mail which just happened to arrive in  
> this moment in my squeak mailbox)
>
> On Aug 31, 2006, at 11:44 PM, Sam Roberts wrote:
>
>> On Fri, Sep 01, 2006 at 06:08:11AM +0900, Markus Gaelli wrote:
>>> I am aware of Singleton Methods, but as they can extend instances,
>>> (how) can I extend classes without changing their original class
>>> definition in Ruby?
>>
>> This is probably best posted to ruby-talk, not ruby-core, folks would
>> likely be quite interested.
>>
>> classes are "open" in ruby, you can add methods as you wish.
>>
>> irb(main):001:0> s = "hi"
(Continue reading)

Markus Gaelli | 1 Sep 2006 01:17
Picon

Fwd: Footnote to Re: [Q] How would you do method extensions (sometimes called class extensions) in Ruby? (was: Fwd: Thoughts from an outsider)


Begin forwarded message:

> From: Markus Gaelli <gaelli <at> emergent.de>
> Date: September 1, 2006 1:06:32 AM GMT+02:00
> To: ruby-core <at> ruby-lang.org
> Subject: Footnote to Re: [Q] How would you do method extensions  
> (sometimes called class extensions) in Ruby? (was: Fwd: Thoughts  
> from an outsider)
>
> Begin forwarded message:
>
>> From: Marcel Weiher <marcel <at> metaobject.com>
>> Date: September 1, 2006 12:11:52 AM GMT+02:00
>> To: The general-purpose Squeak developers list <squeak- 
>> dev <at> lists.squeakfoundation.org>
>> Subject: Re: Thoughts from an outsider
>> Reply-To: The general-purpose Squeak developers list <squeak- 
>> dev <at> lists.squeakfoundation.org>
>>
>>
>> On Aug 30, 2006, at 15:38 , tim Rowledge wrote:
>>>>> And dont go down the road that "smalltalk is simple so the
>>>>> code documents itself".  The code NEVER documents itself,
>>>>> that is a cop-out and a bold face lie.
>>>
>>> Well I have bit of experience in Smalltalk and I find myself  
>>> substantially in agreement with JJ here. Sure, senders and  
>>> implementors are fabulous tools to have but they offer nothing to  
>>> help understand what is likely to happen with exceptions and very  
(Continue reading)

Daniel Martin | 1 Sep 2006 01:20
X-Face
Favicon
Gravatar

Re: Test::Unit gotcha

Eric Hodel <drbrain <at> segment7.net> writes:

> On Aug 30, 2006, at 6:16 PM, Morton Goldberg wrote:
>> If I were implementing something like Test::Unit, as an application
>> of principle of least surprise, I would want to ensure Test::Unit
>> preserved the order in which the programmer defined the tests.
>
> An object's methods don't have an order.

Although I agree with the principle that unit tests shouldn't depend
on the order they're executed in (I actually think that Test::Unit
should sort the methods randomly to enforce this), the order that
methods are defined can actually be recorded in Ruby:

irb(main):001:0> class Foo
irb(main):002:1>   def Foo.method_added(r);  <at> meth ||= [];  <at> meth << r; end
irb(main):003:1>   def Foo.get_meths;  <at> meth; end
irb(main):004:1> end
=> nil
irb(main):005:0>
irb(main):006:0* class FooDescendant < Foo
irb(main):007:1>   def h;1;end
irb(main):008:1>   def e;1;end
irb(main):009:1>   def ll;1;end
irb(main):010:1>   def o;1;end
irb(main):011:1> end
=> nil
irb(main):012:0> FooDescendant.get_meths
=> [:h, :e, :ll, :o]

(Continue reading)

Trans | 1 Sep 2006 01:40
Picon
Gravatar

Re: Ruby program installed via RPM


Joe Van Dyk wrote:
> On 8/31/06, Austin Ziegler <halostatue <at> gmail.com> wrote:
> > On 8/31/06, Joe Van Dyk <joevandyk <at> gmail.com> wrote:
> > > RubyGems is not authorized for use.
> >
> > And ... what's the reasoning for this? I'm genuinely curious.
>
> Our company has rather strict policies on software.  One of the
> hazards of being a government contractor, I suppose.
>
> > In answer to your question, I would  follow the guidelines of setup.rb
> > and use setup.rb itself (see PDF::Writer for how setup.rb can be
> > extended to include non-Ruby files like your .glade files). Then I'd
> > wrap that in your RPM and cause "ruby setup.rb install" to be called
> > by the install script inside of the RPM.
> >
> > However the hell you do that. ;)
>
> Thanks, I'll look into that.

I've been _slowly_ working on one. Currently the system can generate a
basic .deb package and I have most of the code written for generating
an .rpm package too, but it's not quite done yet.

If you'd like to work together on it, let me know.

T.

(Continue reading)

Floyd L. Davidson | 1 Sep 2006 01:40
Favicon

Re: How to spy on the Japanese Rubists

"Austin Ziegler" <halostatue <at> gmail.com> wrote:
>On 8/31/06, Floyd L. Davidson <floyd <at> apaflo.com> wrote:
>> There are two Eskimo languages, and each of them has just about
>> the same number of terms for snow that English does.  Swedish,
>> Norwegian, Danish and Russian all most certainly have an equal
>> number too.
>>
>> As for "Inuit", keep in mind that not all Eskimos are Inuit, and
>> the others (not to mention some who actually *are* Inuit),
>> distinctly do *not* like to be called Inuit.
>
>However, Eskimo *is* a derogatory term applied by other natives first.

There are two claimed etymologies that have a claim to being
valid.  One of the, which Canadian anthropologists Jose Mailhot
supports, is that came from words meaning "People who speak a
different language".  The other is from Ives Goddard (at the
Smithsonian Institute), who thinks it means "snowshoe netter".

The idea that it means "eaters of raw meat" is a bit silly,
since neither side would have considered that derogatory anyway.
It does fit European derived perceptions of a good insult
though, which suggests where the idea came from.

>> The Inuit in Canada and Greenland would prefer to be called
>> Inuit, and since there are no Yupik Eskimos there, it makes
>> sense.  But in Siberia all Eskimos are Yupik.  And in Alaska
>> there are both Inuit and Yupik, so we use the term Eskimo with
>> regularity.  In particular because the Inuit Eskimos in Alaska
>> do *not* like the term Inuit, and call themselves Inupiat!
(Continue reading)

Phrogz | 1 Sep 2006 01:40

Fun with XEXPR

Just sharing some fun code. I think I cranked this out in 30 minutes.
Ruby is so cool.
It's not a full specification of the XEXPR language
http://www.w3.org/TR/xexpr/, but at this point that's just a trivial
amount of additional work.

require 'rexml/document'
include REXML

class Element
  def self.handle_expression( expr_name, &eval_code )
    ( <at>  <at> expression_code ||= {})[ expr_name ] = eval_code
  end

  def run_expression
    unless proc =  <at>  <at> expression_code[ self.name ]
      raise "I don't know how to handle '#{self.name}' expressions yet"
    end
    proc.call( self )
  end

  def run_children
    last_value = nil
    self.elements.each{ |c|
      last_value = c.run_expression
    }
    last_value
  end
end

(Continue reading)

fizbin | 1 Sep 2006 01:40
Picon

Re: Duck typing alows true polymorfisim

Just a quick note in the midst of this:

The Ghost In The Machine wrote:
> Dynamic type creation.  I don't know if Java has this or not.
> One can of course attempt bytecode synthesis -- I think that's
> what BCEL uses -- but that's a bit of a hack.

Since no one has pointed this out, I should mention the oft-neglected
class java.lang.reflect.Proxy, which allows you to create at runtime a
class that implements a given set of interfaces and a single instance
of that class.  Methods are all handled in a manner similar to ruby's
method_missing - that is, a single method is passed the method (as a
Method object) and arguments (as Object[]).

Beanshell (http://www.beanshell.org/) uses this to allow dynamic,
scripted objects (created at runtime) to implement arbitrary Java
interfaces.  Reportedly, this greatly simplifies swing and AWT
programming, since one can ignore methods that are specified as part of
the interface but aren't actually used through the course of the
program.

Timothy Hunter | 1 Sep 2006 02:15
Picon

Re: One-Click Ruby Installer for Windows 1.8.5-21 released

Austin Ziegler wrote:
> On 8/31/06, Timothy Hunter <TimHunter <at> nc.rr.com> wrote:
>> Or you could just ask those who've done it. Kaspar Schiess did the Win32
>> versions of RMagick for several years. With practice he got it down to a
>> 2-day task. Brett DiFrischia did the latest version, 1.13.0. That one
>> took 6 weeks. One of the biggest problems (AFAIK) is RMagick's configure
>> script, which has easily over 100 feature tests and of course doesn't
>> work at all on Windows.
>
> Sorry; I was specifically referring to making it work with the freely
> downloadable VC++8.
>
> There are some ... changes there which aren't pleasant to deal with.
>
> -austin
Okay, I see.

Kaspar swears by mingw. Brett used VC++ 2003.


Gmane