[#13436] Re: Using Antlr for Ruby? (was RE: Re: why won't "( a) = 1" parse?) — Christophe Broult <cbroult@...>
> -----Original Message-----
On Mon, 2 Apr 2001, Christophe Broult wrote:
On Mon, 02 Apr 2001 21:29:26 +0900, Robert Feldt wrote:
[#13450] Asking ruby to provide valid list of signals. — Lloyd Zusman <ljz@...>
Is it possible to somehow retrieve the names of all the signals that
[#13479] Method and Proc equality — Eric Crampton <EricCrampton@...>
I'm using ruby 1.6.3 (2001-03-19) [i686-linux]. Given the following
Eric Crampton <EricCrampton@worldnet.att.net> writes:
On Wed, 4 Apr 2001, Dave Thomas wrote:
Robert Feldt <feldt@ce.chalmers.se> writes:
[#13491] formatting source code — "Luthy Craig" <LuthyCraig@...>
Hi,
[#13500] Ruby web hosting requirements — james@... ("James Britt")
I've been looking for a web hosting company that provides Ruby (as well
[#13510] Re: BUG?: HP-UX 10.20 and IO#gets followed by IO#puts — ts <decoux@...>
>>>>> "S" == SHULTZ,BARRY (HP-Israel,ex1) <barry_shultz@hp.com> writes:
[#13553] array question — Tjabo Kloppenburg <tk@...>
hi,
[#13568] persistent ruby? — Phil Mitchell <philmi@...>
[#13570] ruby-talk volume info? — Robert Feldt <feldt@...>
Hi,
Robert Feldt wrote:
[#13571] basic UNIX command and Ruby — Yoshinari Fujino <y.fujino@...>
Dear Rubyists
[#13589] All In A Row? — "John Kaurin" <jkaurin@...>
I thought I saw something like this in my early readings on Ruby, but I
[#13618] Re: No such file to load -- net/ftp (LoadError) — ts <decoux@...>
>>>>> "J" == John Cook <john.cook@bjss.co.uk> writes:
[#13620] resolver class — meredith <msnomer@...>
Has anyone written one? If not, is anyone up to writing one? I've never
[#13646] Re: operator + — ts <decoux@...>
>>>>> "L" == Luigi Ballabio <luigi.ballabio@riskmap.net> writes:
[#13676] interating for separate values... — "Seo ji won" <skidrow@...>
I know that in ruby I can do this..
[#13703] Ruby on a JVM - good or bad idea? — Stefan Matthias Aust <sma@3plus4.de>
Hi!
On Monday 16 April 2001 10:11, Stefan Matthias Aust wrote:
[#13706] Re: methods and types — "Jish Karoshi" <karoshijish@...>
Bernd Lorbach wrote:
[#13716] Ruby threading implementation docs? — "Lyle Johnson" <ljohnson@...>
Has anything been written down (in English) about Ruby's threads
[#13735] RCR: trivial but useful add-ons — "Guy N. Hurst" <gnhurst@...>
Hi,
[#13775] Problems with racc rule definitions — Michael Neumann <neumann@...>
Hi,
Minero Aoki wrote:
Minero Aoki wrote:
Hi,
[#13784] Web Applications — "Erich Schubert" <newsgroups@...>
Has someone made a framework for web applications?
[#13811] Re: IOWA Re: Web Applications — "Benjamin J. Tilly" <ben_tilly@...>
>===== Original Message From Avi Bryant <avi@beta4.com> =====
> It depends very much on what your goals are. Yes, there is a need for
[#13812] Re: local vars in case — ts <decoux@...>
>>>>> "T" == Thomas Junier <tjunier@pcisrec-d402b.unil.ch> writes:
[#13818] Re: winoldap — "Conrad Schneiker" <schneik@...>
Jonathan Conway wrote,
[#13845] number to string to number — Robert Najlis <rnajlis@...>
Am I doing something wrong (maybe - I am pretty new to Ruby)? it seems
[#13849] BlackAdder for Ruby (scintilla rules) — Wyss Clemens <WYS@...>
Shawn,
[#13852] Re: Ruby on a JVM - good or bad idea? — ts <decoux@...>
>>>>> "M" == Mathieu Bouchard <matju@sympatico.ca> writes:
[#13860] use strict + nested data structures in Ruby — tarael200@... (Tarael200)
Hello,
[#13902] Ruby/GUI option: Ruby/Apollo (Delphi VCL) — "Conrad Schneiker" <schneik@...>
Some time ago, Hal Fulton had some good things to say about Apollo:
[#13911] Re: Net::HTTP basic authentication — ts <decoux@...>
>>>>> "d" == dsharp2@nc rr com <dsharp2@nc.rr.com> writes:
[#13921] File permissions — Farrel Lifson <flifson@...>
Hi all,
[#13934] [ANN] xmlrpc4r 1.6.1 — Michael Neumann <neumann@...>
[#13940] From Guido, with love... — Dave Thomas <Dave@...>
On Sun, 22 Apr 2001 04:38:04 +0900, "Mitch Vincent" <mitch@venux.net>
#
-----BEGIN PGP SIGNED MESSAGE-----
[#13953] regexp — James Ponder <james@...>
Hi, I'm new to ruby and am coming from a perl background - therefore I
I'm interrested in this question, too:
[#13957] Bug? retry not working properly in 1.6.3 — Truls Alexander Tangstad <trulsat@...>
From the example in "Ruby User's Guide", section 9, "Iterators", there is an
>>>>> "D" == Dave Thomas <Dave@PragmaticProgrammer.com> writes:
Hi,
I'm having a strange problem with Apache and some Ruby
[#14002] Visual SlickEdit — "John Kaurin" <jkaurin@...>
I have been using Visual SlickEdit (VSE) with Ruby since I began programming in Ruby
[#14033] Distributed Ruby and heterogeneous networks — harryo@... (Harry Ohlsen)
I wrote my first small distributed application yesterday and it worked
In article <3ae3323d.134494793@news-server>,
On Mon, 23 Apr 2001, Phil Tomson wrote:
[#14040] RCR: getClassFromString method — ptkwt@...1.aracnet.com (Phil Tomson)
It would be nice to have a function that returns a class type given a
On Sun, 22 Apr 2001 21:24:52 GMT, ptkwt@shell1.aracnet.com (Phil
In article <988034673.396094.26164.nullmailer@ev.netlab.zetabits.com>,
[#14052] OO — James Ponder <james@...>
I'm new to Ruby, and am just starting my first app - coming from a C and
[#14092] Ruby module for AOLserver. — Chiriac Petrica Clement <clement@...>
Hi,
[#14100] Re: RCR, strange things in $: — "Benjamin J. Tilly" <ben_tilly@...>
ts <decoux@moulon.inra.fr> wrote:
[#14101] I have crossed the Rubicon! — as646@... (John Robson)
[#14103] Re: Negative Reviews for Ruby and ProgrammingRuby — "Benjamin J. Tilly" <ben_tilly@...>
>===== Original Message From Paul Prescod <paulp@ActiveState.com> =====
[#14106] How does one interpret a RUBY.EXE.stackdump file? — ptkwt@...1.aracnet.com (Phil Tomson)
I got the following message running a ruby script on Win98:
> I got the following message running a ruby script on Win98:
In article <000101c0cc3d$74141b40$0201a8c0@NATHANIELS7500>,
[#14130] Re: Ruby mascot proposal — "Conrad Schneiker" <schneik@...>
Guy N. Hurst wrote:
On Tue, 24 Apr 2001, Conrad Schneiker wrote:
Hi,
On Tuesday 24 April 2001 23:02, Yukihiro Matsumoto wrote:
On Wed, 25 Apr 2001, W. Kent Starr wrote:
[#14138] Re: python on the smalltalk VM — Conrad Schneiker <schneik@...>
FYI: Thought this might be of interest to the JRuby and Ruby/GUI folks.
Conrad Schneiker <schneik@austin.ibm.com> writes:
Hello.
Ok, this may be a dumb question, but, is it possible to insert into an
Jim Freeze <jim@freeze.org> writes:
I have an array where I need to delete several entries.
At Wed, 25 Apr 2001 01:28:36 +0900,
Hi,
On Fri, Apr 27, 2001 at 11:26:37PM +0900, Yukihiro Matsumoto wrote:
Chris Moline wrote:
[#14187] Re: the alternative proposal is way cooler; — "Conrad Schneiker" <schneik@...>
I wrote:
[#14189] Re: Ruby mascot proposal — "Conrad Schneiker" <schneik@...>
Matz wrote:
Hi,
[#14221] An or in an if. — Tim Pettman <tjp@...>
Hi there,
On Wed, 25 Apr 2001, Tim Pettman wrote:
Why do I get the following output
Hi,
On Thu, Apr 26, 2001 at 01:13:47AM +0900, Yukihiro Matsumoto wrote:
[#14222] Re: Ruby mascot proposal — John Tobler <jtobler@...>
spwhite@chariot.net.au wrote:
[#14236] Ruby vs. Tcl input/output question — bw <donotreply@...>
[I am new to ruby]
[#14246] converting some 'eval's from perl — ptkwt@...1.aracnet.com (Phil Tomson)
[#14262] Ruby on Windows problem — Karl Lopes <karl_lopes@...>
Hello,
Hello Karl,
Yes, all those paths are set. When I try to start irb,
[#14266] how change instances class — "Henning VON ROSEN" <hvrosen@...>
Sorry, din't find it in pickaxe:
[#14267] Re: Ruby mascot proposal — "Conrad Schneiker" <schneik@...>
Danny van Bruggen,
My 2 cents:
[#14274] Re: Ruby mascot proposal — John Tobler <jtobler@...>
Phil (ptkwt@shell1.aracnet.com) wrote:
[#14281] basic socket question — "R. Mark Volkmann" <volkmann2@...>
This should be an easy one for anyone that has successfully used sockets in
[#14298] Re: Ruby mascot proposal. Will this end ? — "Conrad Schneiker" <schneik@...>
Q: "Ruby mascot proposal. Will this end?"
[#14330] The Ruby Programming Language Book by Matz — as646@... (John Robson)
[#14334] Immutable Arrays? — Johann Hibschman <johannh@...>
Hi folks,
[#14339] gtk and Float/to_f — Thomas Lundqvist <thomasl@...>
Hi! I experience the following strange behavior:
[#14341] array as index to array — jonas <jonas.bulow@...>
Hello list! :-)
[#14359] Where for art thou, rdtool for Win9x? — "J J" <jj5412@...>
Can anyone tell me where I can get a functional rdtool for Win9x? I scoured
[#14387] Re: Whither SmallScript? (was Re: Integer micro-benchmarks) — "David Simmons" <pulsar@...>
"Andrew Hunt" <andy@toolshed.com> wrote in message
[#14390] [REPOST] Retrieving current signal handler without altering it — Lloyd Zusman <ljz@...>
[ Note: I posted this question a couple weeks ago, but I'm not
[#14399] Ruby Conference T-shirt — "Guy N. Hurst" <gnhurst@...>
[#14417] Embedded Ruby w/ Apache: Forbidden error — "J J" <jj5412@...>
Hi,
[#14448] How to do it the Ruby-way 2 — Stefan Matthias Aust <sma@3plus4.de>
Hi again,
[#14452] How to do it the Ruby-way 3 — Stefan Matthias Aust <sma@3plus4.de>
First a question: Why is
Hi:
Hi:
Hi,
On Wed, 2 May 2001, Yukihiro Matsumoto wrote:
[ruby-talk:13469] Re: A subtle Hash bug
> From: Mathieu Bouchard [mailto:matju@sympatico.ca]
[..]
> I'm not proposing that +Infinity should be indistinguishable from
> -Infinity. I'm asking why is +Infinity == +Infinity and -Infinity ==
> -Infinity.
Well,
basically the Numeric class hierarchy puts a nice OO-rapper around
the native C types integer and double and adds Bignum to it and
for the most part this was very well done - the identity methods
seem the follow pattern
* x == y - if x,y are C-equal
* x.eql? y - if x,y are C-equal and no type conversion is necessary
* x.equal? y - if x,y are id-equal (this effects Float and Bignum)
Since C's double has the unique constants +/- Infinity and NaN you
need to guarantee that
1/0.0 == 1/0.0, 1/-0.0 == 1/-0.0,( 1/0.0) * 0 == (1/0.0) * 0 (== NaN)
otherwise you would break this pattern. Anthing else would make the
special value logic essentially unusable IMO.
This is not really relevant here but I sort believe that at least one
of Ruby's equal methods should have been a class method - something like
Float.identical?(1, 1.0) # => true
This would have eliminated the problematic asymmetry of methods receiver
versus method argument and it makes generally more sense anyway - the only
reason against this are the extra key strokes.
[...]
> > The exception raising behavior of zero-division and comparison
> > is type specific on the method receiver end
> > 2**29 <=> 1/0.0 # => -1 since 2**29 is a Fixnum
> > 2**33 <=> 1/0.0 # FloatDomainError: Infinity since 2**33 is Bignum
>
> this should return -1 since although +Infinity is not a precise number, it
> is greater than all other finite values and -Infinity. (it is however
> noncomparable to itself and to NaN)
I don't believe that this is such a good idea - you would get
10**400 > 1.0 # => true
10**400 + 10**400 > 1.0 + 10**400 # => false
since 1.0 + 10**400 is equal to Floats Infinity but the left hand side is
still an ordinary Bignum which amounts to the mathematical equivalent
of a containment breach during a nuclear reactor melt-down.
> > 1/ 0 # a ZeroDivisionError is raised for any Integer type
>
> This is ok, because the Integer domain has no equivalent of Infinities and
> NaNs.
Yes ..
> > I actually have a Ruby hack of logical +/- Infinity's constants.
> > The semantics is closer to +/- nil and but you can perform limited
> > Arithmetic on them - I made them instances of +/- Infinity Classes
> > sub-typed from Numeric but this is not really necessary. (the are
> > necessarily smaller/bigger then floats infinities).
>
> May I see that? Btw, what are +nil and -nil ???
I attached something below - the reason for calling them +/- nil is that
they could be the return values of [].min, [].man etc. which currently
return nil and if +/- Infinity would act as logical false values you
probably would not break any existing script.
> > methods input of any numeric object (except for Rational, which
> > is an eager beaver and tries to process input it does not
> > understand instead of calling coerce).
>
> Do you think Rational should be fixed to act, ehm, more rationally?
Don't know - the current behavior also breaks theoretical stuff like
integral or field extension of the Integer Class by ``adding sqrt(2)''
etc. but this is not that problematic IMO.
To beat a dead horse of mine what Ruby is really missing is support for
Modules (and consequently Classes) parameterized by Module constant
with a instantiation logic.
[...]
Christoph
---------------
Sorry this is quite longish - basically it was an exploration of the
Singleton class construction and I wanted to see on how far the poor
men's version of multi-dispatch (a.k.a. coerce) gets you - running
examples with +/-infty as input is quite usefully for debugging and
it is a better (that means fewer if-then-else constructs in your code)
return value for certain method then nil, -1 etc.
------------
require 'infinity'
module Enumerable
def max; inject(Infinity.minus) {|a,b| (a > b ) ? a : b } end
end
p [].max # => -infty
p [3,5,-9].max # => 5
class Someclass
Minimalvalue= Infinity.minus
# .....
def size
if empty?
Minimalvalue
else
something_else
end
end
end
------------
###### infinity.rb ############################
# Copyright (c) 2001 by Christoph Rippel
# Licensed under the same license as Ruby
###############################################
class Infinity < Numeric; end
###### Thread safety ########
unless Infinity.instance_eval { @__initialized__ }
Thread.critical = true
begin
class Numeric
# The finite?, infinite? methods and the Zero, One constants
# are nice but not necessary. Note that the Fixnums Zero, One
# constants are the Zero, One constants of the whole Numeric
# hierarchy - the OO-manifestation that a (commutative) ring
# is the same thing as a (commutative) algebra.
def finite?; true end
def infinite?; false end
Zero = 0
One = 1
end
class Float
Zero = 0.0
One = 1.0
end
module InfinityError
# The Error handling regime is probably brain dead ..
class AdditionError < TypeError; end
class SubtractionError < TypeError; end
class InfinityDivisionError < TypeError; end
class ZeroMultiplicationError < TypeError; end
class ZeroDivisionError < ZeroDivisionError; end
def addition; raise AdditionError end
def subtraction; raise SubtractionError end
def infinityDiv(other); raise InfinityDivisionError end
def zeroMul(other); raise ZeroMultiplicationError end
def zeroDiv(other); raise ZeroDivisionError end
def inspect; 'InfinityError handler' end
def to_s; 'InfinityError handler' end
end
class Infinity
# Common instances methods
def finite?; false end
def infinite?; true end
def integer?; false end
def succ; self end
def next; self end
def zero?; false end
# Utility methods to access the Instance and
# Error handling object - rarely used
def error_handler; type::Ehandler end
def instance; type::Instance end
# Thread safety
@__initialized__ = true
class << self
def minus; InfinityMinus::Instance end
def plus; InfinityPlus::Instance end
end
end
class InfinityMinus < Infinity
# It is faster to define the less commonly methods as
# instances methods - incidentally they are mostly
# shared between the Instance and its mirror.
Instance = self.new
Ehandler = Object.new.extend InfinityError
def inspect; ' -infty' end
def to_s; ' -infty' end
def sgn; -1 end
def times(&prog);
Instance
end
end
class InfinityPlus < Infinity
Instance = self.new
Ehandler = Object.new.extend InfinityError
def inspect; ' infty' end
def to_s; ' infty' end
def sgn; 1 end
def times(&prog)
prog.call(self) while true
Instance
end
end
class << Infinity.minus
# Defining the Mirror as a singleton constant is notably
# faster - the luxury of supporting infinite multiplication
# and division is expensive because we need to create a
# new coercion Array every time coerce is called.
Minus = Infinity.minus
Plus = Infinity.plus
Mirror = InfinityMinus.new
def coerce(other); [Mirror, other] end
def finite?; false end
def <(other); !(equal? other) end
def >(other); false end
def <=>(other); (equal? other) ? 0 : -1 end
# defining -@ is not necessary but more efficient
def -@; Plus end
def +(other); (other.equal? Plus) ? Ehandler.addition : Minus end
def -(other); (other.equal? Minus) ? Ehandler.subtraction : Minus end
def *(other);
return Plus if other < 0
return Minus if other > 0
return Ehandler.zeroMul(other)
end
def /(other)
return Ehandler.infinityDiv(other) unless other.finite?
return Plus if other < 0
return Minus if other > 0
return Ehandler.zeroDiv(other)
end
class << Mirror
Minus = Infinity.minus
Plus = Infinity.plus
def <(other); false end
def >(other); true end
def <=>(other); 1 end
def +(other); Minus end
def -(other); Plus end
def *(other)
return Plus if other > 0
return Minus if other < 0
return Ehandler.zeroMul(other)
end
def /(other) ; other.type::Zero end
def %(other) ; (other > 0 ) ? Minus : other end
# def remainder(other); other end
# Ruby ignores the previous line
end
end
class << Infinity.plus
Plus = Infinity.plus
Mirror = InfinityPlus.new
Minus = Infinity.minus
def coerce(other); [Mirror, other] end
def finite?; false end
def <(other); false end
def >(other); !(equal? other) end
def <=>(other); (equal? other) ? 0 : 1 end
def -@; Minus end
def +(other); (other.equal? Minus) ? Ehandler.addition : Plus end
def -(other); (other.equal? Plus) ? Ehandler.subtraction : Plus end
def *(other);
return Plus if other > 0
return Minus if other < 0
return Ehandler.zeroMul(other)
end
def /(other)
return Ehandler.infinityDiv(other) unless other.finite?
return Plus if other > 0
return Minus if other < 0
return Ehandler.zeroDiv(other)
end
class << Mirror
Plus = Infinity.plus
Minus = Infinity.minus
def <(other); true end
def >(other); false end
def <=>(other); -1 end
def +(other); Plus end
def -(other); Plus end
def *(other);
return Plus if other > 0
return Minus if other < 0
return Ehandler.zeroMul(other)
end
def /(other); (other.type)::Zero end
def %(other) ; (other < 0 ) ? Plus : other end
end
end
class << Infinity
undef_method :new
end
ensure
Thread.critical = false
end
end
def Infinity.leftlogic_initialize
Thread.critical = true
begin
::Infinity.class_eval (%{
def to_truth; false end
def &(other); ::NIL & other end
def ^ (other); ::NIL ^ other end
def | (other); ::NIL | other end
})
ensure
::Infinity.instance_eval (%{ def leftlogic_initialize; true end })
Thread.critical = false
end
true
end
------------
###### test.rb ################################
require 'infinity'
mi = Infinity.minus
pi = Infinity.plus
mi = Infinity.minus
pi = Infinity.plus
def p_ary (*ary); puts ary.join ", " end
x = mi
x -= 25
x *= -13.0
y = 344.9999
y /= pi
p_ary "simple test", x, y, 34**34 / mi
p_ary "x+ -infty", mi + mi, mi - pi, mi + 1, 1.0+ mi
p_ary "x+ infty", pi + pi, pi - mi, pi + 2.0, -3**24 + pi
p_ary "-infty <=> x", mi <=> mi, mi <=> 0, mi <=> pi
p_ary " x <=> - infty", 0 <=> mi, pi <=> mi
p_ary "infty <=> x", pi <=> mi, pi <=> 0, pi <=> pi
p_ary " x <=> infty", mi <=> pi, 31.3 <=> pi
p_ary "-infty < x", mi < mi, mi < 0, mi < pi
p_ary " x < - infty", 0 < mi, pi < mi
p_ary "infty < x", pi < mi, pi < 0, pi < pi
p_ary " x < infty", mi < pi, 31.3 < pi
p_ary "-infty > x", mi > mi, mi > 0, mi > pi
p_ary " x > - infty", 0 > mi, pi > mi
p_ary "infty > x", pi > mi, pi > 0, pi > pi
p_ary " x > infty", mi > pi, 31.3 > pi
p_ary "-infty == x", mi == mi, mi == 0, mi == pi
p_ary " x == - infty", 0 == mi, pi == mi
p_ary "infty == x", pi == mi, pi == 0, pi == pi
p_ary " x == infty", mi == pi, 31.3 == pi
p "test of Ehandlers and *,/ etc. "
p " An alternative for the normal error-raising behavior"
class << mi.error_handler
def zeroMul(other); -other.type::One end
def infinityDiv(other); -other.sgn end
def zeroDiv(other); Infinity.minus end
end
class << pi.error_handler
def zeroMul(other); other.type::One end
def infinityDiv(other); other.sgn end
def zeroDiv(other); Infinity.plus end
end
module InfinityError
def addition; 0 end
def subtraction; 0 end
end
p_ary "-infty*x", mi*mi, mi* (-1.0), mi* 0.0, mi * 23, mi*pi
p_ary "-infty/x", mi/mi, mi/ (-1.0), mi/ 0.0, mi/ 1, mi/ pi
p_ary "infty*x", pi*mi, pi* (-1.0), pi* 0.0, pi * 23, pi*pi
p_ary "infty/x", pi/mi, pi/ (-1.0), pi/ 0.0, pi/ 1, pi/ pi
p_ary "x*-infty*x", -2.3* mi,0.0 * mi, 23* mi
p_ary "x/ -infty", -3.5/ mi, 0.0 /mi, 1/ mi, mi/ 1, pi/ mi
p_ary "x*infty", -2.3* pi,0.0 * mi, 23* mi
p_ary "x/ infty", mi/ - pi, 0.0 /pi, 1/ pi, pi/ pi
p_ary "add", mi - mi, pi - pi, mi + pi, pi + mi
Infinity.leftlogic_initialize
p "left-logic test"
p_ary pi ^ mi, pi & 64, mi | false