From: Quinn Dunkan Date: 2000-03-16T16:38:10-08:00 Subject: [ruby-talk:01941] Re: ruby <=> python > I think a byte is a integer in range between 0 and 255, Ruby does give > you a integer from 0 to 255 by [], although it does not provide the > special type for the range. Do you mean there's need for a integer > type to represent a byte only? > > If so, what characteristics a byte type should have? What is the > difference between signed int and byte. Actually, on second thought, I conceed that Fixnum makes a perfectly good byte (since all types are probably boxed in ruby anyway, size difference is hardly relevant... I think). As far as characteristics go: Char + String -> String Char + Fixnum -> TypeError Char#inspect -> 'x' or '\0xyz' if not in "normal ascii range" But I'm probably being ascii-latin1-biased by assuming there's a such thing as "normal ascii range" that makes sense for evenyone. > I'm not sure I understand your point, mostly because my English skill. > `::' is needed for nested constant access. Its syntax is > > A::F It is (needed)? Why wouldn't A.F work? Oh wait, I see... methods can be capitalized. > There are other combinations like: > > A::F() > A::f > A::f() > > I made these method invocation to allow programmer to add optional > information to show the receiver is a class. This is not enforced by > the language, just as a optional variation. I think you understood ok: My point was that if `::' can behave as a `.', you can't look for class methods by looking for `::'s, because many people will use `.' for that, and some people might even use `::' for instance methods. I think your point was that it's ``optional documentation'' like arg names in declarations in C, which I also understand. Just a difference of opinion, then. That paragraph about ``optional information to show receiver is a class'' is good documentation. The whole constant-access thing must be ``one of those C++ things''... > |> `false' is a boolean value, `nil' is a out-of-range value. You know I mean? > |> I'm considering make 0 false, but not positively. > | > |Uh oh, does that mean only -0 is false? My head hurts. > > NO. I mean I had considered to make 0 falise; I haven't refused it > yet, but not eager to adpot. `positively' did not mean number > positiveness. I know, I was just trying to be cute... sorry for any confusnion :) (but confusion is so much fun!) [parallel iteration] > You can solve this by defining external iterator. > > class ArrayIterator > def initialize(ary) > @ary = ary > @index = 0 > end > def next > if @index >= @ary.size > raise IndexError, "index out of range" > end > value = @ary[@index] > @index += 1 > value > end > end > > def zip(*args) > r = [] > iter = args.collect{|i|ArrayIterator::new(i)} > begin > loop do > r.push iter.collect{|i|i.next} > end > rescue IndexError > end > r > end Interesting... I should try to think in iterators/generators for a bit..