[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Complete set of callbacks

T. Onoma

11/15/2004 4:24:00 PM

Trying to put together a complete list of all potential callbacks:

Class creation Class#inherited (sort-of), or alias #new.
Class reopening/closing
Module creation
Module reopening/closing
Method definition Object#method_added
Singelton-Method definition Object#singleton_method_added
Constant assignment*
Global variable assignment Kernel#trace_var (sort_of)
Class variable assignment
Instance variable assignment
Local variable assignment
Module inclusion Module#included
Module extension Module#extend_object

*Constant assignment may include class and module creation.

See any anything I'm missing?

Thanks,
T.


9 Answers

Joel VanderWerf

11/15/2004 7:21:00 PM

0

trans. (T. Onoma) wrote:
> Trying to put together a complete list of all potential callbacks:
>
> Class creation Class#inherited (sort-of), or alias #new.
> Class reopening/closing
> Module creation
> Module reopening/closing
> Method definition Object#method_added
> Singelton-Method definition Object#singleton_method_added
> Constant assignment*
> Global variable assignment Kernel#trace_var (sort_of)
> Class variable assignment
> Instance variable assignment
> Local variable assignment
> Module inclusion Module#included
> Module extension Module#extend_object
>
> *Constant assignment may include class and module creation.
>
> See any anything I'm missing?

Module#append_features
Kernel#method_missing
Module#const_missing

Then there are things like at_exit and set_trace_func.


Peter

11/15/2004 11:35:00 PM

0

T. Onoma

11/17/2004 11:46:00 AM

0

Thanks Peter and Joel. Here's the rundown thus far.

Class creation Class#inherited, AClass#new
Class reopening/closing
Module creation
Module reopening/closing
Method definition Module#method_added
Method removal                 Module#method_removed
Method undef                   Module#method_undefined
Singelton-Method definition Object#singleton_method_added
Singleton-method deletion      Object#singelton_method_removed
Singelton-method undef         Object#singelton_method_undefined
Constant assignment*
Global variable assignment Kernel#trace_var**
Class variable assignment
Instance variable assignment
Local variable assignment
Module inclusion Module::included, Module#append_features
Module extension Module::extended, Module#extend_object
Missing Method Object#method_missing
Missing Constant Module#const_missing
Object Destruction ObjectSpace#*_finalizer
Program Termination Kernel#at_exit

* Constant assignment may encompass class and module creation (?)
** Actually a trace rather then a callback
++ set_trace_func is not included, it is a separate "universal" catch-all

Please help clarify which are instance methods (#) and which are class methods
(::). Are there any others, or does that cover the entire gambit?

Thanks,
T.



T. Onoma

11/17/2004 1:52:00 PM

0

On Wednesday 17 November 2004 06:45 am, trans. (T. Onoma) wrote:
| Please help clarify which are instance methods (#) and which are class
| methods (::).

I see why I'm confused now. Take this example:

--------------------------------------------------------- Marshal#dump

<snip>

o = Klass.new("hello\n")
data = Marshal.dump(o)
obj = Marshal.load(data)
obj.sayHello #=> "hello\n"


Dump is being used as module/class method so shouldn't it be 'Marshal::dump' ?
The documentation says they are instance methods, but you can't initialize a
Marshal. What gives?

(Is Marshal singleton, BTW?)

Thanks,
T.


Eric Hodel

11/17/2004 7:14:00 PM

0

On Nov 17, 2004, at 5:51 AM, trans. (T. Onoma) wrote:

> On Wednesday 17 November 2004 06:45 am, trans. (T. Onoma) wrote:
> | Please help clarify which are instance methods (#) and which are
> class
> | methods (::).
>
> I see why I'm confused now. Take this example:
>
> ---------------------------------------------------------
> Marshal#dump
>
> <snip>
>
> o = Klass.new("hello\n")
> data = Marshal.dump(o)
> obj = Marshal.load(data)
> obj.sayHello #=> "hello\n"
>
>
> Dump is being used as module/class method so shouldn't it be
> 'Marshal::dump' ?
> The documentation says they are instance methods, but you can't
> initialize a
> Marshal. What gives?

I've always used :: exclusively for constants, and . for methods.

I much prefer :: over . when referencing method names.



Eric Hodel

11/17/2004 8:42:00 PM

0

On Nov 17, 2004, at 11:14 AM, Eric Hodel wrote:

> I've always used :: exclusively for constants, and . for methods.
>
> I much prefer :: over . when referencing method names.

Er... I meant . (Class.class_method) over :: (Class::class_method())



T. Onoma

11/17/2004 10:45:00 PM

0

On Wednesday 17 November 2004 03:42 pm, Eric Hodel wrote:
| On Nov 17, 2004, at 11:14 AM, Eric Hodel wrote:
| > I've always used :: exclusively for constants, and . for methods.
| >
| > I much prefer :: over . when referencing method names.
|
| Er... I meant . (Class.class_method) over :: (Class::class_method())

Actually I knew what you meant b/c I agree. But that's something I've noticed
about Ruby, it tries to accommodate a lot of variant styles and tastes, like
{ ... } or do ... end, and the options to use parenthesis with methods or not
--many variations and ways to do the same things.

Nonetheless, I am still at a loss for what appears to me as documentation
errors in ri. I feel like I must be misunderstanding something, but I can't
see what it is.

T.


Hal E. Fulton

11/17/2004 11:10:00 PM

0

trans. (T. Onoma) wrote:
> Nonetheless, I am still at a loss for what appears to me as documentation
> errors in ri. I feel like I must be misunderstanding something, but I can't
> see what it is.

My impression is that there are probably numerous small errors in ri.

I'm sure Dave corrects them as he/we find them. I don't know whether
there's any official reporting mechanism for them.


Hal



T. Onoma

11/18/2004 3:58:00 AM

0

On Wednesday 17 November 2004 06:09 pm, Hal Fulton wrote:
| trans. (T. Onoma) wrote:
| > Nonetheless, I am still at a loss for what appears to me as documentation
| > errors in ri. I feel like I must be misunderstanding something, but I
| > can't see what it is.
|
| My impression is that there are probably numerous small errors in ri.
|
| I'm sure Dave corrects them as he/we find them. I don't know whether
| there's any official reporting mechanism for them.

Thanks Hal. Puts my mind a bit more at ease to know it's not just me and my
craziness.

T.