Ben Giddings wrote:

> itsme213 wrote:
>> Not built into Ruby, true. But an app might have its own meta-data,
>> possibly domain-specific. Perhaps things like param types, or data about
>> how parameters are interpreted by a method (e.g. "either a list of dates,
>> or a start date and a list of durations "), etc. A domain-specific Ruby
>> could add Class#methods to declare such things.
> 
> This naturally makes me think of:
> 
> def read_dat_file(filename):
> """ReadCodeComposerdatafile
> 
> Fileformat:ASCII,optionalheaderlinefollowedbydata,oneword
> per line
> 
> filename--nameofdatfiletoread
> 
> Returnslistofdatavalues.
> """
> f=open(filename,'r')
> lines=f.readlines()
> f.close()
> 
> ...
> 
> AKA Python's docstring inside a function.
> 
> I think it would be amazing if a docstring like that were available in
> Ruby, and if it were available via reflection.Itcouldbeusedinall
> kinds of ways: from within IRB sessions, as part of error messages, as a
> "service discovery" kind of tool...
> 

That reminds me a bit of C# attributes. Attributes are
available to reflection and can be attached to methods, classes
and other type definitions.

So one can write:
[ConditionalAttribute("DEBUG")]
void debug_method(string msg)
{
....
}

to tell the compiler, development tools and other
developers that this method is intended for debugging.
(One effect of the example above is, that the C# compiler
compiles the method only if the DEBUG symbol is set.)

New attributes can be defined like classes, so you
can attach any meta data you like to classes, methods etc.

I think this could be useful for Ruby too.

-- 
Stefan