Skip to content
Prev 180276 / 398513 Next

Object and Classes ?

In S3 you pass the object as the first argument of the method (rather than
prefixing the method with the object as is common in other languages).
When you call a method you write

method(obj, ...whatever...) # correct

and it automatically inspect the class of obj and if its class is Blah
then it dispatches the call to method.Blah for you.  You don't explicitly
refer to Blah in the call.  That is:

method.Blah(obj, ...whatever...) # wrong

If its the fact that method precedes the object rather than the object
preceding the method that's bothersome to you because you are
familiar with other languages then that is just how it is in S3.

The proto package does support a syntax in which the object prefaces
the method:
[1] 2
On Wed, May 13, 2009 at 7:01 PM, myshare <mraptor at gmail.com> wrote: