Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Yadda yadda yadda operator
Mat Schaffer
7/23/2006 6:41:00 PM
On Jul 23, 2006, at 2:06 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...
> Exception_handling> is
> thrown. This operator is useful for abstract
> methods<
http://en.wikipedia...
Abstract_method>,
> or for marking places where the programmer intends to insert code
> later.
>
> </quote>
>
>
>
> This seemed so useful that I thought implementing it for Ruby and
> submitting
> a patch, but then caught myself and wrote:
>
> class Kernel
>
> def yadda
>
> raise "Yadda operator reached"
>
> end
>
> end
>
>
>
> How elegant Ruby is.
>
>
>
> Does anyone else think that this is Standard Library material in
> the making?
This strikes me as a little comical. I think the raise solution is
preferable cause then you can include human readable information
about why it's not implemented.
e.g.:
def foo
raise "Foo must be overridden in child classes"
end
def bar
raise "To be implemented in 1.2"
end
yadda, yadda.... :)
To me, this is much more useful than a message that's basically "Hey
it's broke. Deal with it."
If you find yourself using similar messages, then just implement the
kernel function like you did. But maybe make it something like
"raise_abstract" just to make it clear to the user what's happening.
-Mat
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Yadda yadda yadda operator
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password