[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: ANN: MetaTags 1.0

Richard Kilmer

9/11/2003 3:04:00 AM


On Wednesday, September 10, 2003, at 06:15 PM, Hal Fulton wrote:

> Chad Fowler wrote:
>> On Thu, 11 Sep 2003, Austin Ziegler wrote:
>> # On Thu, 11 Sep 2003 04:05:26 +0900, Ben Giddings wrote:
>> # > Richard Kilmer wrote:
>> # >> Then:
>> # >> class String
>> # >> def &(klass)
>> # >> klass.from_str(self)
>> # >> end
>> # >> end
>> # >> then you can do:
>> # >> c = "one hump or two" & Caml
>> # > I like this better than Dave's suggestion of the Caml() function,
>> but it
>> # > is somewhat confusing. Since the "&" is already used, I thought
>> maybe
>> # > another operator might make more sense, but I discovered that
>> there is
>> # > only a small set of operators that seem to be overloadable. Is
>> there a
>> # > complete list somewhere of overloadable operators?
>> # # irb(main):001:0> "a" & "b"
>> # NoMethodError: undefined method `&' for "a":String
>> # from (irb):1
>> # irb(main):002:0> VERSION
>> # => "1.8.0"
>> # Did you miss the part that said class String
>> def &(klass)
>> ....etc.
>> ?
>
> I think he was responding to the part that said, "Since & is already
> used..."
>
> To play mediator and clear up any confusion (if I can get my
> attributions straight!):
>
> Someone defined an & operator.

That was me (rich), and it was a method, not operator.

> Rich wanted something other than &.

I wanted & (or something available for implementation)...I REALLY
REALLY like Dave's suggestion of >>

> I *think* Ben thought that Rich was saying the String#& was already
> defined; so he tried to correct him

Ben said & was already used, but its not for the class String. I added
the & method to String...that's the 'magic'

> You (Chad) thought that Ben had failed to see the definition of
> String#&

Chad wondered weather Ben saw my definition in the String class

>
> Now in (partial) answer to the question of what's overloadable:
> 1. You can only overload genuine operators/methods; not assignment,
> not dot, not ::, etc. I can't remember the full list.
> 2. You can never overload something that is not already recognized by
> the parser as an operator -- e.g. you can't create your own operators
> using arbitrary punctation as in (I think) SNOBOL.
>
> Cheers,
> Hal
>
>
>
>