From: Matthias Lampert Date: 2001-08-17T22:36:54+09:00 Subject: [ruby-talk:19942] Hi, folks! It sounds like traveling to Rio via North and South Pole, I know, but ... has anyone of you ever tried to build the Mysql-extension for Ruby on cygwin? The trouble is, that the linker is unable to find the references for the MySQL C API. These are the first lines I get: dllwrap --target=cygwin --as=as --dlltool-name=dlltool --driver-name=gcc --export-all -s --def=mysql.def -L/usr/local/lib/ruby/1.6/i686-cygwin -L/usr/local/lib -o mysql.so mysql.o -L. -lcygwin-ruby16 -L/cygdrive/c/mysql/lib/opt -lmysqlclient mysql.o: In function `free_mysql': /cygdrive/c/upload/mysql-ruby-2.3.2a/mysql.c:61: undefined reference to `mysql_close' mysql.o: In function `free_mysqlres': /cygdrive/c/upload/mysql-ruby-2.3.2a/mysql.c:68: undefined reference to `mysql_free_result' mysql.o: In function `mysql_raise': /cygdrive/c/upload/mysql-ruby-2.3.2a/mysql.c:76: undefined reference to `mysql_error' > -----Original Message----- > From: Stephen White [mailto:spwhite@chariot.net.au] > Sent: Friday, August 17, 2001 3:01 PM > To: ruby-talk@ruby-lang.org > Subject: [ruby-talk:19939] Re: Why not?: Assigning to self > > > Pit Capitain wrote: > > Why not? In this class hierarchy each square is a (specialized) > > rectangle, so class Square also has a method #set_shape. If > > called with width != height, the Square instance would "become" a > > Rectangle instance. In a drawing program showing a square, why > > shouldn't it make sense to be able to drag one side or one hotspot > > in order to change the square into a rectangle? > > That would mean that #set_shape in Square would have to > handle all the > possible parameters for Rectangle, Circle, Ellipse, Triangle, > Star, and > so on. I don't like this degree of interdependence. > > You can implement this in Ruby with something like: > > class Square > def set_shape(x, y) # note the "y" only exists because > of Rectangle > if x != y > Rectangle.new(x,y) # Square knows about Rectangle, > bad coding! > else > @x, @y = x, y > self > end > end > end > > item = shape.set_shape(10, 10) > item = shape.set_shape(23, 45) > > It would be better to abstract this up a level, so a "Shapes" class > would know about all the possible shapes underneath it, and > thus has a > legitimate reason for knowing the different parameters. > > The bonus side of this is that you will no longer have any need for > "become". > > -- > spwhite@chariot.net.au >