42.type and TypeError or 42.class and ClassError

A

Ara.T.Howard

why has #type been deprecated? i don't really like using Object#class since
it always conflicts with the keyword 'class'; eg. you have to

self.class.method

instead of the cleaner

type.method

also, having #class prefered over #type, but TypeError as the error definitely
violated POLS. we should at least have ClassError if #class is the way to go.

personally i don't see the problem with type even if it isn't _totally_ in
line with the 'ruby way' of thinking - it's meaning is perfectly clear in code
IMHO.

-a
--

ATTN: please update your address books with address below!

===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| STP :: http://www.ngdc.noaa.gov/stp/
| NGDC :: http://www.ngdc.noaa.gov/
| NESDIS :: http://www.nesdis.noaa.gov/
| NOAA :: http://www.noaa.gov/
| US DOC :: http://www.commerce.gov/
|
| The difference between art and science is that science is what we
| understand well enough to explain to a computer.
| Art is everything else.
| -- Donald Knuth, "Discover"
|
| /bin/sh -c 'for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done'
===============================================================================
 
J

Jamis Buck

Ara.T.Howard said:
personally i don't see the problem with type even if it isn't _totally_ in
line with the 'ruby way' of thinking - it's meaning is perfectly clear in code
IMHO.

I have no idea if this is one of the reasons #type has been deprecated,
but I've always disliked it because there have been many times that I
wanted to create a method of my own, called #type. In those cases, I
either had to alias the original #type method, or simply live without it.
 
Y

Yukihiro Matsumoto

Hi,

In message "42.type and TypeError or 42.class and ClassError"

|why has #type been deprecated?

Because type has broader meaning and tends to introduce confusion.
Besides I wanted to save the word "type" for something based on method
signature.

|also, having #class prefered over #type, but TypeError as the error definitely
|violated POLS. we should at least have ClassError if #class is the way to go.

Since type is broader concept that includes class, I think an error
caused by instances of wrong class is a part of type error.

matz.
 
J

Josef 'Jupp' SCHUGT

Hi!

* Ara.T.Howard; 2003-12-17, 19:21 UTC:
why has #type been deprecated?

That can be answered by quoting Gamma, Helm, Johnson Vilissides,
'Design Patterns - Elements of Reusable Object-Oriented Software',
page 16 (bottom):

It's important to understand the difference between an object's
/class/ and its /type/.

An object's class defines how the object is implemented. The
class defines the object's internal state and the implementation
of its operations. In contrast, an object's type only refers to
its interface---the set of requests to which it can respond. An
object can have many types, and objects of different classes can
have the same type.

I strongly recommend that book - it is great. It is worth its price
of 54.99 USD.

Josef 'Jupp' SCHUGT
 
R

Rasputin

* Zach Dennis said:
I feel bad for asking this question, but I am going to pull my hair out with
this. I recently got Ruby to run as a cgi under Apache2/Win2k combination.
Works great. I am now trying to do the same thing on Apache2/Redhat9 combo,
but to no avail. I keep getting the Server Error 500, premature end of
script headers.

Change to ' print "Content-type: text/html\n\n" '
print "<html><body>Hello</body></html>"
I was having this problem on my windows box at first but then I changed the
first line to read:
#! ruby
and it has worked ever since. However I have changed the first line on my
test.rb file on the Linux box to the following variations:
#! ruby
#!/usr/local/bin/ruby
#!/bin/ruby
#!/bin/env ruby
#! /bin/env ruby

Run 'which ruby' in a shell and set the path in the shebang line
(the #! line above to whatever you get back).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

[RCR] Kernel#hostname 0
tk file dialog and directories 3
flock vs fcntl and nfs 0
ruby advocacy 3
pp equiv of #inspect 1
[BUG] greedy gsub 1
puts(derived_from_array) 0
make MISSING=flock.o 0

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top