[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Yadda yadda yadda operator

Trans

7/23/2006 6:43:00 PM


Son SonOfLilit wrote:
> Hello.
>
> I was reading about perl6 on wikipedia for amusement today and I came upon
> the "yadda yadda yadda" operator:
>
> <quote>
>
> if is_true() {
> for @array {
> ...
> }
> }
>
> The three dots above (...) are syntactically valid in Perl 6 and are called
> the "yadda-yadda operator". "..." can be used as a placeholder for code to
> be inserted later. If a running program attempts to *execute* "...",
> however, an exception <http://en.wikipedia.org/wiki/Exception_ha... is
> thrown. This operator is useful for abstract
> methods<http://en.wikipedia.org/wiki/Abstract_...,
> or for marking places where the programmer intends to insert code later.

Well, I guess the question is: how does one insert code later? If you
just have to redine it as one does now, why bother, just use raise
"dude, where's my code!". OTOH, if there some mean by which one inject
code into these locations, well, the use of this would be more
interesting. But I'm not sure how that's done if all you has to go on
is '...'. Also, implemenation might prove a little hairy.

T.


1 Answer

F. Senault

7/23/2006 11:06:00 PM

0

Le 23 juillet 2006 à 20:43, transfire@gmail.com a écrit :

> Well, I guess the question is: how does one insert code later? If you
> just have to redine it as one does now, why bother, just use raise
> "dude, where's my code!". OTOH, if there some mean by which one inject
> code into these locations, well, the use of this would be more
> interesting. But I'm not sure how that's done if all you has to go on
> is '...'. Also, implemenation might prove a little hairy.

Well, I'm sure it's possible to do something that would react like
this :

class Foo
abstract :bar, :baz
end

class Quux < Foo
def bar()
puts "Hello."
end
end

q = Quux.new()
q.bar
=> "Hello"
q.baz
=> exception "Baz must be implemented in child."

Now, is that useful, pretty, ruby'ish, and whatever, I don't know.

And it's limited to methods (and / or accessors ?).

Fred
--
If there were no desire to heal
The damaged and broken met along
This tedious path I've chosen here
I certainly would've walked away by now. (Tool, The Patient)