[#11569] sprintf: Format specifier tokens aren't checked well enough — Florian Gross <florgro@...>

Hi,

12 messages 2007/07/01

[#11611] Import gem to Ruby 1.9 — SASADA Koichi <ko1@...>

Hi,

130 messages 2007/07/08
[#11625] Re: Import gem to Ruby 1.9 — Eric Hodel <drbrain@...7.net> 2007/07/09

On Jul 8, 2007, at 00:49, SASADA Koichi wrote:

[#11727] Re: Import gem to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/07/17

-----BEGIN PGP SIGNED MESSAGE-----

[#11738] Re: Import gem to Ruby 1.9 — Eric Hodel <drbrain@...7.net> 2007/07/17

On Jul 17, 2007, at 01:26, NAKAMURA, Hiroshi wrote:

[#11752] Re: Import gem to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/07/18

-----BEGIN PGP SIGNED MESSAGE-----

[#11794] Re: Import gem to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/07/24

-----BEGIN PGP SIGNED MESSAGE-----

[#11820] Re: Import gem to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/07/26

-----BEGIN PGP SIGNED MESSAGE-----

[#12323] Re: Import gem to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/01

-----BEGIN PGP SIGNED MESSAGE-----

[#12330] Re: Import gem to Ruby 1.9 — Eric Hodel <drbrain@...7.net> 2007/10/01

On Sep 30, 2007, at 22:56 , NAKAMURA, Hiroshi wrote:

[#12637] Re: Import gem to Ruby 1.9 — Eric Hodel <drbrain@...7.net> 2007/10/13

On Oct 1, 2007, at 09:57 , Eric Hodel wrote:

[#12642] Re: Import gem to Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/10/13

Hi,

[#12643] Re: Import gem to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/13

-----BEGIN PGP SIGNED MESSAGE-----

[#12645] Re: Import gem to Ruby 1.9 — Eric Hodel <drbrain@...7.net> 2007/10/13

On Oct 13, 2007, at 02:00 , NAKAMURA, Hiroshi wrote:

[#12652] Re: Import gem to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/13

-----BEGIN PGP SIGNED MESSAGE-----

[#12656] Re: Import gem to Ruby 1.9 — Eric Hodel <drbrain@...7.net> 2007/10/13

On Oct 13, 2007, at 08:00 , NAKAMURA, Hiroshi wrote:

[#12691] Re: Import gem to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/15

-----BEGIN PGP SIGNED MESSAGE-----

[#12712] Re: Import gem to Ruby 1.9 — Eric Hodel <drbrain@...7.net> 2007/10/16

On Oct 15, 2007, at 07:14 , NAKAMURA, Hiroshi wrote:

[#12717] Re: Import gem to Ruby 1.9 — "Leonard Chin" <l.g.chin@...> 2007/10/17

On 10/17/07, Eric Hodel <drbrain@segment7.net> wrote:

[#12729] Re: Import gem to Ruby 1.9 — Charles Oliver Nutter <charles.nutter@...> 2007/10/17

Leonard Chin wrote:

[#12766] Re: Import gem to Ruby 1.9 — Tanaka Akira <akr@...> 2007/10/19

In article <4710890A.3020009@sarion.co.jp>,

[#12768] Re: Import gem to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/19

-----BEGIN PGP SIGNED MESSAGE-----

[#12771] Re: Import gem to Ruby 1.9 — Tanaka Akira <akr@...> 2007/10/19

In article <4718708D.3050001@sarion.co.jp>,

[#12792] Re: Import gem to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/20

-----BEGIN PGP SIGNED MESSAGE-----

[#12798] Re: Import gem to Ruby 1.9 — Tanaka Akira <akr@...> 2007/10/21

In article <471A1720.4080606@sarion.co.jp>,

[#12827] Re: Import gem to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/22

-----BEGIN PGP SIGNED MESSAGE-----

[#12852] Re: Import gem to Ruby 1.9 — Tanaka Akira <akr@...> 2007/10/23

In article <471CAFE0.2070104@sarion.co.jp>,

[#12853] Re: Import gem to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/23

-----BEGIN PGP SIGNED MESSAGE-----

[#12854] Re: Import gem to Ruby 1.9 — Tanaka Akira <akr@...> 2007/10/23

In article <471D4D1F.5050006@sarion.co.jp>,

[#12857] Re: Import gem to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/23

-----BEGIN PGP SIGNED MESSAGE-----

[#12896] Re: Import gem to Ruby 1.9 — Tanaka Akira <akr@...> 2007/10/24

In article <471D5665.5040209@sarion.co.jp>,

[#12914] Re: Import gem to Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...> 2007/10/25

-----BEGIN PGP SIGNED MESSAGE-----

[#11642] Re: Proposal: runtime-modifying Kernel methods should be keywords — "Marcel Molina Jr." <marcel@...>

On Fri, Jul 13, 2007 at 03:02:06PM +0900, Charles Oliver Nutter wrote:

21 messages 2007/07/13
[#11671] Re: Proposal: runtime-modifying Kernel methods should be keywords — Ryan Davis <ryand-ruby@...> 2007/07/13

[#11645] Re: Proposal: runtime-modifying Kernel methods should be keywords — Charles Oliver Nutter <charles.nutter@...>

Charles Oliver Nutter wrote:

20 messages 2007/07/13
[#11646] Re: Proposal: runtime-modifying Kernel methods should be keywords — Yukihiro Matsumoto <matz@...> 2007/07/13

Hi,

[#11647] Re: Proposal: runtime-modifying Kernel methods should be keywords — Charles Oliver Nutter <charles.nutter@...> 2007/07/13

Yukihiro Matsumoto wrote:

[#11650] Re: Proposal: runtime-modifying Kernel methods should be keywords — Nobuyoshi Nakada <nobu@...> 2007/07/13

Hi,

[#11756] threads and heavy io on osx and linux — "ara.t.howard" <Ara.T.Howard@...>

15 messages 2007/07/18

[#11795] What libraries to be unbundled? — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

27 messages 2007/07/24
[#11797] Re: What libraries to be unbundled? — David Flanagan <david@...> 2007/07/24

I don't think that json should be unbundled. It is the interchange

Re: Inheritable mixin

From: TRANS <transfire@...>
Date: 2007-07-14 08:32:20 UTC
List: ruby-core #11689
On 7/13/07, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
> Hi,
>
> In message "Re: Inheritable mixin"
>     on Sat, 14 Jul 2007 05:14:02 +0900, TRANS <transfire@gmail.com> writes:
>
> |What do you think of making Class not inherit Module, but instead make
> |them separate classes that both mixin "Inheritable" (or whatever you'd
> |like to call it)?
>
> By separating modules and classes, we get class hierarchy design
> clarity at the cost of little bit language complexity.  Making
> mixin (modules) inheritable means introducing "full" multiple
> inheritance in the language.  I don't think it's worth changing the
> language we live happily without full MI.
>
> |The thought occurred to me while organizing Facets. I've been locking
> |at what methods might fit together into organization units, ie,
> |mixins, so far I've been able to successfully develop Indexable and
> |Stackable.
>
> More concrete example please?  I am not sure the benefit of having
>
>   module Indexable
>   end
>
>   class Whatever < Indexable
>   end
>
> over
>
>   class Whatever
>     include Indexable
>   end
>
>                                                         matz.
>

Okay, mind you this is in the context of Facets, where I'm inclinedto
add extra methods beyond the Ruby norm, and it's still a work in
progress, but so far....

#  Works off of #index, #slice, #splice and #size.
#  Where #splice is essentially #[]=, but if no value is given,
removes the index.

module Indexable

  # Like #first but returns the first element
  # in a new array.
  #
  #   [1,2,3].head  #=> [1]
  #
  def head
    slice(0,1)
  end

  # Returns an array from second element to last element.
  #
  #   [1,2,3].tail  #=> [2,3]
  #
  def tail
    slice(1,length-1)
  end

  # Like #last, returning the last element
  # in an array.
  #
  #   [1,2,3].foot  #=> [3]
  #
  def foot
    slice(-1,1)
  end

  # Returns an array of the first element upto,
  # but not including, the last element.
  #
  #   [1,2,3].body  #=> [1,2]
  #
  #--
  # Better name for this? (bulk, perhaps?)
  #++
  def body
    slice(0,size-1)
  end

  # Returns the middle element of an array, or the element offset
  # from middle if the parameter is given. Even-sized arrays,
  # not having an exact middle, return the middle-right element.
  #
  #   [1,2,3,4,5].mid        #=> 3
  #   [1,2,3,4,5,6].mid      #=> 4
  #   [1,2,3,4,5,6].mid(-1)  #=> 3
  #   [1,2,3,4,5,6].mid(-2)  #=> 2
  #   [1,2,3,4,5,6].mid(1)   #=> 5
  #
  # In other words, If there are an even number of elements the
  # higher-indexed of the two center elements is indexed as
  # orgin (0).
  def mid(offset=0)
    #at((size / 2) + offset)
    slice((size / 2) + offset, 1)
  end

  # Returns the middle element(s) of an array. Even-sized arrays,
  # not having an exact middle, returns a two-element array
  # of the two middle elements.
  #
  #   [1,2,3,4,5].mid        #=> 3
  #   [1,2,3,4,5,6].mid      #=> [3,4]
  #
  # In contrast to #mid which utilizes an offset.
  def middle
    if size % 2 == 0
      #[at((size/2)-1), at(size/2)]
     [slice((size / 2) - 1, 1), slice(size / 2, 1)]
    else
      #at(size/2)
      slice(size / 2, 1)
    end
  end

  # Fetch values from a start index thru an end index.
  #
  #   [1,2,3,4,5].thru(0,2)  #=> [1,2,3]
  #   [1,2,3,4,5].thru(2,4)  #=> [3,4,5]
  #
  def thru(from, to)
    a = []
    i = from
    while i <= to
      a << slice(i, 1)
      i += 1
    end
    a
  end

  # Returns first _n_ elements.
  #
  #   "Hello World".first(3)  #=> "Hel"
  #
  def first(n=1)
    slice(0, n.to_i)
  end

  # Returns last _n_ elements.
  #
  #   "Hello World".last(3)  #=> "rld"
  #
  def last(n=1)
    n = n.to_i
    return self if n > size
    slice(-n, n) #slice(-n..-1)
  end

  # Change the first element.
  #
  #   a = ["a","y","z"]
  #   a.first = "x"
  #   p a           #=> ["x","y","z"]
  #
  def first=(x)
    splice(0,x)
  end

  # Change the last element.
  #
  #   a = [1,2,5]
  #   a.last = 3
  #   p a           #=> [1,2,3]
  #
  def last=(x)
    splice(-1,x)
  end

  # Remove and return the first element.
  #
  def first!
    splice(0)
  end

  # Remove and return the last element.
  #
  def last!
    splice(-1)
  end

  # A shorting of "ends at", returns the
  # last index of the indexable object.
  # Returns nil if there are no elements.
  #
  #   [1,2,3,4,5].ends  #=> 4
  #
  # This nearly equivalent to +size - 1+.
  def ends
    return nil if size == 0
    size - 1
  end

  # Returns the positive ordinal index given
  # a cardinal position, 1 to n or -n to -1.
  #
  #   [1,2,3,4,5].pos(1)   #=> 0
  #   [1,2,3,4,5].pos(-1)  #=> 4
  #
  def pos(i)
    if i > 0
      return i - 1
    else
      size + i
    end
  end

  # TODO Remove Array#index_of when future Ruby adds block to #index.

  # Allows block usage with index.

  def index_of(obj=nil,&blk)
    return index(obj) unless block_given?
    i=0; i+=1 until yield(self[i])
    return i
  end

  # TODO Maybe #range could use a little error catch code.

  # Returns the index range between two elements.
  # If no elements are given, returns the range
  # from first to last.
  #
  #   ['a','b','c','d'].range            #=> 0..3
  #   ['a','b','c','d'].range('b','d')   #=> 1..2
  #
  def range(a=nil,z=nil)
    if !a
      0..(size-1)
    else
      index(a)..index(z)
    end
  end

end

In This Thread