Inform6: Object routine names and non-object routine names

Hello fine people!

I have a puzzling situation. I have an object that has routine on it named HandleEvent. I also have a routine named HandleEvent that’s not on an object.

It seems that’s not acceptable to Inform as I get the error

Error:  Expected routine name but found HandleEvent

If I rename the non-object routine to something else (e.g. ProcessEvent), the error disappears.
Is this really not allowed in Inform or have I misunderstood the cause of the error?

Thank you!

It’s not allowed. If you write

 Object obj with HandleEvent [; ... ];

then HandleEvent is defined as a property ID. It’s not a function. This particular object has a function as its obj.HandleEvent value, but some other object might have a string or something. You can’t call HandleEvent() on its own.

Fie! It’d be nice if it distinguished. No worries, though, I can rename the routines.

Any possibility of the error message output being clarified?

What are you hoping it to say?

“[routine name] already defined as property in object [object name]” or the like.

Yes, that makes sense. Thanks.

The compiler should be able to find all that information when printing that error, yes. I’ll give it a shot.

I’ve submitted a change which will generate this error:

line 9: Error: “HandleEvent” is a name already in use and may not be used as a routine name too (Individual property “HandleEvent” was defined at line 6)

Or, depending on what order you put things in, you might get:

line 9: Error: “HandleEvent” is a name already in use and may not be used as a property name too (Routine “HandleEvent” was defined at line 6)

(The compiler already had one of these set up, turns out. I added the other case. I also set up the same error when defining attributes, globals, arrays, objects, and classes.)

3 Likes