Author Topic: Public Procedures  (Read 1396 times)

0 Members and 1 Guest are viewing this topic.

Offline Nostalgic

Public Procedures
« on: April 17, 2007, 02:40:32 PM »
The SCI Studio help mentions that a procedure can have "of <ClassName>" and I understand that this is so that a procedure can be designed "for use with a specific class." However, does that mean what it literally sounds like: that only a class or an instance of that class can call that procedure?

Is there a good reason as to why you might want to do this? It would seem that a generic procedure (not tied to a specific class) or a method (tied to a specific class) would handle what's needed in most cases.

(Incidentally, this post along with my post on "Public Instances" may seem like I'm not bothering to try to figure things out on my own. I actually am, I promise. However, I'm approaching a lot of this like a "newbie" --- which I sorta am --- and I'm trying not to wait until experience with the system helps me gloss over problems with current documentation.)

Offline lskovlun

Re: Public Procedures
« Reply #1 on: April 17, 2007, 03:21:39 PM »
This is because the self pointer works slightly differently than in C++. In C++, the address of the current object is passed to object methods as an implicit parameter (called 'this'). In SCI, the address of the currently executing object is a global variable and it remains set even if you call procedures. So in short, you can fetch properties of the most recently executing object and call methods on it. The 'procedure Foo of Bar' syntax provides the SCI compiler with information it needs to compile property fetches correctly (method calls don't need it).

Offline Nostalgic

Re: Public Procedures
« Reply #2 on: April 17, 2007, 04:33:48 PM »
Thanks ... this does make sense. (I realize I misnamed this thread a bit, since the "public" modifier is really not the focus.)

I do see that it's used in (script.985). The source says that the procedure CueClient is "of Timer." Another is the procedure GetCell being "of Extra" (in -- script.988).

Thanks again for your explanation.

SMF 2.0.14 | SMF © 2017, Simple Machines
Simple Audio Video Embedder

Page created in 0.092 seconds with 23 queries.