[#72642] Advantages of Symbols over constants — Marek Janukowicz <childNOSPAM@...17.ds.pwr.wroc.pl>

11 messages 2003/06/01

[#72732] case of sub! not working — Ian Macdonald <ian@...>

Hi,

27 messages 2003/06/03
[#72734] Re: case of sub! not working — Joel VanderWerf <vjoel@...> 2003/06/03

Ian Macdonald wrote:

[#72744] Re: case of sub! not working — Ian Macdonald <ian@...> 2003/06/03

On Tue 03 Jun 2003 at 10:21:43 +0900, Joel VanderWerf wrote:

[#72769] Re: case of sub! not working — Michael Campbell <michael_s_campbell@...> 2003/06/03

[#72907] Syck 0.35 + YAML.rb 0.60 -- the 1st stable release — why the lucky stiff <ruby-talk@...>

Pleased to announce:

18 messages 2003/06/05
[#75182] Re: Syck 0.35 + YAML.rb 0.60 -- the 1st stable release — Richard Zidlicky <rz@...68k.org> 2003/07/04

On Fri, Jun 06, 2003 at 06:15:58AM +0900, why the lucky stiff wrote:

[#72908] Problem with "require" stmt in "test-first " tutorial — RLMuller@... (Richard)

Hi All,

27 messages 2003/06/05

[#72940] VAPOR 0.06, Transparent Persistence to PostgreSQL — "Oliver M. Bolzer" <oliver@...>

Hi!

22 messages 2003/06/06

[#72975] join block — "Simon Strandgaard" <0bz63fz3m1qt3001@...>

29 messages 2003/06/06

[#72986] multiple blocks or proc arguments to method — itsme213@... (you CAN teach an old dog ...)

I was trying to write a collect_if method:

11 messages 2003/06/07

[#73081] requiring standard libs with save level 1 — Eugene Scripnik <Eugene.Scripnik@...>

I've set up new version of Ruby from CVS and my programs failed to work.

13 messages 2003/06/09
[#73114] Re: requiring standard libs with save level 1 — matz@... (Yukihiro Matsumoto) 2003/06/09

Hi,

[#73134] tcltklib does not get compiled. — John Fletcher <J.P.Fletcher@...>

I have installed ruby 1.6.7 on two computers using Red Hat 8.0 Linux.

14 messages 2003/06/10

[#73148] OT: Regexp question — Dominik Werder <dwerder@...>

Hi all,

25 messages 2003/06/10

[#73215] Rubyx (provisionally named) linux distro. Made by and run by Ruby — Andrew Walrond <andrew@...>

I have developed a little script which creates a simple linux distro

38 messages 2003/06/11

[#73260] Multiple Initialize methods? — "Nick" <nick.robinson@...>

Hi,

21 messages 2003/06/11

[#73283] Ruby advantages over Perl — Marek Janukowicz <childNOSPAM@...17.ds.pwr.wroc.pl>

68 messages 2003/06/11
[#73374] Re: Ruby advantages over Perl — Jason Creighton <androflux@...> 2003/06/12

On Thu, 12 Jun 2003 17:56:02 +0900

[#73356] does each work on a copy? — Rasputin <rasputin@...>

17 messages 2003/06/12

[#73372] Reason for implicit block syntax ? — itsme213@... (you CAN teach an old dog ...)

What is the reason for the implicit block in Ruby invocations?

13 messages 2003/06/12

[#73463] Hispeed String concat — Dominik Werder <dwerder@...>

What is the fastest way to add many small Strings to a big buffer?

17 messages 2003/06/13

[#73503] RaaInstallInRuby petition — ptkwt@...1.aracnet.com (Phil Tomson)

18 messages 2003/06/13

[#73555] I need a code beautifier or formatter — joaopedrosa@... (Joao Pedrosa)

Hello,

13 messages 2003/06/14

[#73600] Get songtitle from Winamp — calvin8@... (Andi Scharfstein)

Hi,

26 messages 2003/06/15
[#73601] Re: Get songtitle from Winamp — Daniel Carrera <dcarrera@...> 2003/06/15

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

[#73602] Re: Get songtitle from Winamp — Chad Fowler <chadfowler@...> 2003/06/15

It's a Win32API convention meaning "Window Handle".

[#73603] Re: Get songtitle from Winamp — Daniel Carrera <dcarrera@...> 2003/06/15

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

[#73605] Re: Get songtitle from Winamp — Wesley J Landaker <wjl@...> 2003/06/15

On Sunday 15 June 2003 9:34 am, Daniel Carrera wrote:

[#73609] Re: Get songtitle from Winamp — Daniel Carrera <dcarrera@...> 2003/06/15

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

[#73640] Standardizing Installers — Tom Clarke <tom@...2i.com>

I was thinking about some of the issues raised involving ruby libraries

16 messages 2003/06/16

[#73663] /BEGIN/ .. /END/ file reading — Wild Karl-Heinz <kh.wild@...>

hello

15 messages 2003/06/16
[#73674] Re: /BEGIN/ .. /END/ file reading — "Robert Klemme" <bob.news@...> 2003/06/16

[#73677] Re: /BEGIN/ .. /END/ file reading — Michael Campbell <michael_s_campbell@...> 2003/06/16

> A range operator with a regexp works like a flip flop (bistable

[#73680] Multiline comments? — "Christoph Tapler" <christoph.tapler@...>

I'm new to Ruby and I'm wondering that there is no possibility to write

38 messages 2003/06/16

[#73781] editor / ide recommentation on Windows — itsme213@... (you CAN teach an old dog ...)

What editor / ide would you recommend for serious Ruby work on

20 messages 2003/06/17

[#73787] Array#push(empty array expanded) => no exception — "Simon Strandgaard" <0bz63fz3m1qt3001@...>

This strange behavier really surprised me..

13 messages 2003/06/17

[#73821] European Ruby Conference — "Hal E. Fulton" <hal9000@...>

I don't think I've mentioned this before, but I

15 messages 2003/06/17

[#73924] Re: TCP/IP protocol and Net::HTTP — "J.Hawkesworth" <J.Hawkesworth@...>

Works for me too.

13 messages 2003/06/19
[#73931] Re: TCP/IP protocol and Net::HTTP — Nigel Gilbert <n.gilbert@...> 2003/06/19

I am beginning to wonder if this problem arises from the MacOS X

[#73943] collect info about ruby-api — "Simon Strandgaard" <0bz63fz3m1qt3001@...>

I have long been longing for a good description of ruby C api.

35 messages 2003/06/19

[#74039] WxRuby status? — ptkwt@...1.aracnet.com (Phil Tomson)

14 messages 2003/06/20
[#74507] Re: WxRuby status? — Richard Kilmer <rich@...> 2003/06/26

Things are progressing great. Kevin Smith has taken the development

[#74070] How to test if a file exists? — Daniel Carrera <dcarrera@...>

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

12 messages 2003/06/21

[#74096] Exasperated with ruby/tk - anybody successfully using it? — "Richard Browne" <richb@...>

General question: Is ruby/tk still being maintained in 1.7/1.8 or is it

10 messages 2003/06/22

[#74104] String#decorate — martindemello@... (Martin DeMello)

When chaining methods, it'd be neat to have something that was passed

17 messages 2003/06/22

[#74156] Marshal bug? — Anders Borch <spam@...>

Hi!

15 messages 2003/06/23
[#74161] Re: Marshal bug? — Dave Thomas <dave@...> 2003/06/23

Anders Borch wrote:

[#74205] can't find appropriate regexp — "Patrick Zesar" <jonnypichler@...>

spamassassin blocked my previous post :-((((

17 messages 2003/06/23

[#74279] Ruby Developer's Guide - hurt book sale — dennis@... (Dennis Sutch)

Syngress Publishing is having a hurt book sale. Per Syngress

11 messages 2003/06/24

[#74379] protect parents from children — "Simon Strandgaard" <0bz63fz3m1qt3001@...>

I fell into these pitfalls yesterday.. that a child was modifying a parent!

27 messages 2003/06/25

[#74413] Ruby/Java integration through JNI: working implementation — Mauricio Fern疣dez <batsman.geo@...>

14 messages 2003/06/25
[#74436] Re: Ruby/Java integration through JNI: working implementation — D T <tran55555@...> 2003/06/25

Yet An other JRuby ?? :-)

[#74465] DBD for Oracle9i — Jim Cain <list@...>

Hi all. I was looking for a Ruby interface to 9i that would handle all

25 messages 2003/06/25

[#74478] RPM for 1.8.0 — John Carter <john.carter@...>

I would like to get / build a Mandrake 9.1 RPM for Ruby-1.8.0 Preview 3

17 messages 2003/06/26

[#74506] String#split(' ') and whitespace (perl user's surprise) — mike@... (Mike Stok)

I have to confess that I use a lot of Perl, and some of its idioms are

15 messages 2003/06/26

[#74573] Using & for arrays of objects — "Krishna Dole" <kpdole@...>

Hi,

39 messages 2003/06/27

[#74579] why can't I use $3somevar for global variable in ruby 1.8.0? — Donglai Gong <donglai@...>

Hi, I'm new to Ruby programming and I just upgraded from 1.6.8 to 1.8.0

10 messages 2003/06/27

[#74702] Slides from my talk are up on rubyhacker.com — "Hal E. Fulton" <hal9000@...>

I was pleased to attend the European Ruby Conference

25 messages 2003/06/29

[#74706] Help with UnboundMethod#bind error — gabriele renzi <surrender_it@...1.vip.lng.yahoo.com>

Hi gurus and nubys,

16 messages 2003/06/29
[#74708] Re: Help with UnboundMethod#bind error — nobu.nokada@... 2003/06/29

Hi,

[#74732] Re: Help with UnboundMethod#bind error — matz@... (Yukihiro Matsumoto) 2003/06/30

Hi,

[#74919] Re: Help with UnboundMethod#bind error — "Pit Capitain" <pit@...> 2003/07/02

On 30 Jun 2003 at 17:18, Yukihiro Matsumoto wrote:

[#74717] Re: Message catalogs (I18N) overnight hack... — "Hal E. Fulton" <hal9000@...>

----- Original Message -----

17 messages 2003/06/29

[#74747] Editor like Textpad on Linux? — Dominik Werder <dwerder@...>

Hello,

13 messages 2003/06/30

[#74768] dynamic object creation — Aryeh Friedman <aryeh@...>

If I have something like this:

15 messages 2003/06/30

Re: switching multiple interfaces of an object

From: Mauricio Fern疣dez <batsman.geo@...>
Date: 2003-06-18 20:11:01 UTC
List: ruby-talk #73875
On Thu, Jun 19, 2003 at 04:16:12AM +0900, ahoward wrote:
> On Thu, 19 Jun 2003, Mauricio [iso-8859-1] Fern疣dez wrote:
> 
> > > care to comment on the relative merits/drawbacks of these approaches?  i really
> > > do think something standard like this would be extremely useful.
> >
> > Ummm, your code is *way cleaner and simpler* :-)
> 
> lol.  that's a *first* for me on c.l.r.!  well - ts hasn't responded so
> perhaps i've spoken too soon...

:-D

Now, it's really no wonder: as I love toying with singleton classes,
class instance variables and such, I think I abuse them a little bit :)
So I tend to write baroque code when I do it for fun only, as in this
case at first.

> 
> > My code basically involves aliasing methods as needed to get the right
> > ones to have the required name.
> >
> > Cons: (w.r.t. delegation)
>          ^^^^^
>          ^^^^^
>          ^^^^^  ??

with regard to
(I thought this was a common abbreviation in English, but I'm no native
speaker...)

> >  * threading issues: the current interface used for one object must be
> >    the same in all threads (or non-interfering interfaces)
> >  * more complicated
> >  * uses 1 class instance variable (bad in the sense that if you mess
> >    with that it breaks :)
> 
> how about marshaling?  if you dynamically alias methods - can you marshal
> that?

The class or the object :-) ?

Objects should be easily 'marshallable', the only thing that needs to be
saved is the currently supported interface. Perhaps something like
  obj = Marshal.load(io)
  obj.setInterface(:foo)
would be necessary.

> > Pros: (ditto)
> > * in your code you have to create internal classes, whereas I am only
> >   adding methods and saying "methods foo, bar and baz as defined right
> >   now correspond to interface Babar". So I think although the
> >   implementation I did is more complicated, its use is actually easier.
> 
> but perhaps less safe.  the reason i have all the classes and interface defs
> as private is that, only the class designer should, really, know which

well, if you're messing with 
class SomeClass
  # stuff
end
(which is what you have to do to add new interfaces with my code)
you definitely have to know how the class works, so I don't see why
delegation would be safer on this very issue.

However, I have the feeling that method aliasing is easier to break if
you mess with its internals (class instance variables, etc)

> different interfaces are possible and what constraints there are (eg.  once
> you use interface 'x' the object may not ever be used via interface 'y' -
> these situation are not that hard to imagine...)  maybe this is just the evil
> c++ side of me coming out?

It's a little evil IMHO, yes :) If only the first interface that was used
is kept, and the client has to specify it, then you might as well directly
write 4 different classes that implement something in terms of another
and then let the client explicitly initialize whichever we wants. (I
know its only one case but I just couldn't help writing this :)

I mean, what's the difference between

class Implementation
#...
end

class SupportsInternface1
 # do things with implementation, perhaps using delegation or actually 
 # subclassing Implementation and aliasing methods as needed, etc
end

class Bla2
#ditto
end

# now the users chooses the "interface"
obj = Bla2.new
#from now on can only use the interface offered by Bla2 :-)

and delegation with "evil restrictions" ;) ?? 

Now seriously, IMHO interfaces should always be available because
otherwise this is not an Adaptor but a State pattern...

> > * this means your classes don't normally share state unless you do
> >   explicitly pass it around (which you do in your code), so it seems
> >   more difficult to do this "extend and define interface" thing and
> >   don't have direct access to instance vars
> 
> i see that.  however, my idea was simply to separate data from methods, and to
> let the methods be 'assign-able'.  eg. to switch interfaces.  kind of funny

One of my goals was allowing methods to be defined just the same way as
if you were implementing all these interfaces in separate classes. This
requires direct access to instance variables.

In other words, I only wanted to fix one problem, name clashes in
interfaces, without creating any other :)

> that oo programming talks about putting data and methods together and here we
> go separating them... ;-)  i guess i'm thinking that, although it is certainly
> possible to separate methods from data (as i did) there is still a potentailly
> *very* tight coupling between the two - thus the private inner class thing...

As there's so much coupling I believe it's better to offer direct access
to i.v. with @attr instead of accessors or anything else. After
all this is supposed to be one object offering different interfaces, not
several objects using services from a third.

> > * it can be made to work with singleton methods, so they get
> >   registered as part of the interface.
> 
> in my code, all that would be needed to do this is an
> 
>   attr :interface
> 
> in other words, you can do this if the interface class is publicly available:
> 
>   class << k.interface
>     def foo; 'foo'; end
>   end
> 
> you get the idea...

ummm, you add the method to the singleton of the class, but is it going
to work at all? I believe it should be
k.interface.class_eval <<-EOF
  def foo; 'foo' end
EOF

> > * therefore w/ your code interfaces and their implementations have to
> >   be known beforehand, whereas with mine it's easier to add them on the
> >   fly (Object#extend).
> 
> i wouldn't agree here, although it would make the code longer than 51 lines
> one could easily design

I guess it can be done, but then you'd lose one of the pros (clean and
short code :)

> > You can find the code at
> > http://www.rubygarden.org/ruby?AdaptorPattern/Generalized
> 
> i'll check it out.

it's quite a kludge now that I see it again, really.

> > If there's interest in a such a thing I have a couple ideas which should
> > work much better.
> 
> i, for one, like the idea alot.  yours may be alot better - i'm just
> brainstorming...

My code still has this hackish smell, but I have one idea that could be
much better.

-- 
 _           _                             
| |__   __ _| |_ ___ _ __ ___   __ _ _ __  
| '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
| |_) | (_| | |_\__ \ | | | | | (_| | | | |
|_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|
	Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

/*
 *     Please skip to the bottom of this file if you ate lunch recently
 *                             -- Alan
 */
	-- from Linux kernel pre-2.1.91-1


In This Thread

Prev Next