Hi, This is a generic question about the way code is written in prototype and scriptaculous libraries. Inside every object, we find functions that begin with "_". How are these methods/functions different from the rest? eg _text, _attributes, _each... Please let me know. Thank you, Mandy.
Abdur-Rahman Advany
2005-Dec-15 11:43 UTC
Re: Generic Question about the way code is written
Javascript does not have private functions, _ means its a private function, don''t tuch it ;) Maninder, Singh wrote:>Hi, > >This is a generic question about the way code is written in prototype and scriptaculous libraries. > >Inside every object, we find functions that begin with "_". > >How are these methods/functions different from the rest? > >eg _text, _attributes, _each... > >Please let me know. > >Thank you, >Mandy. >_______________________________________________ >Rails-spinoffs mailing list >Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >
I won''t touch it :) but I can call the method - right? Or is it used for some internal calculations? -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of Abdur-Rahman Advany Sent: Thursday, December 15, 2005 5:13 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] Generic Question about the way code is written Javascript does not have private functions, _ means its a private function, don''t tuch it ;) Maninder, Singh wrote:>Hi, > >This is a generic question about the way code is written in prototype and scriptaculous libraries. > >Inside every object, we find functions that begin with "_". > >How are these methods/functions different from the rest? > >eg _text, _attributes, _each... > >Please let me know. > >Thank you, >Mandy. >_______________________________________________ >Rails-spinoffs mailing list >Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On 12/15/05, Maninder, Singh <mandiv-W2hqgAdRMsX2eFz/2MeuCQ@public.gmane.org> wrote:> I won''t touch it :) but I can call the method - right? > > Or is it used for some internal calculations?You certainly can call it, but you probably shouldn''t. The ''_'' is used in many languages to imply privacy where privacy can''t be enforced. It''s a way for the creator of the app to tell users of it "don''t call this function directly". It''s usually done for some mix of the following reasons: The creator is thinking of renaming, removing, or drastically changing this function in a future version. Calling this function directly, instead of using the public api, can cause unexpected side effects and/or errors that may be incredibly tough to trace. HTH.> -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of > Abdur-Rahman Advany > Sent: Thursday, December 15, 2005 5:13 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] Generic Question about the way code is > written > > > Javascript does not have private functions, _ means its a private > function, don''t tuch it ;) > > Maninder, Singh wrote: > > >Hi, > > > >This is a generic question about the way code is written in prototype and scriptaculous libraries. > > > >Inside every object, we find functions that begin with "_". > > > >How are these methods/functions different from the rest? > > > >eg _text, _attributes, _each... > > > >Please let me know. > > > >Thank you, > >Mandy. > >_______________________________________________ > >Rails-spinoffs mailing list > >Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >-- Bill Guindon (aka aGorilla)