Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Anonamously referencing procedures within a class
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
TheOneTrueGod




PostPosted: Thu Jun 08, 2006 4:36 pm   Post subject: Anonamously referencing procedures within a class

I don't know if I used the terminology right there, but eh.

code:

class Stuff
export WriteThis

   procedure WriteThis (s : string)
      put s
   end WriteThis
   procedure WriteFirstCharacter (s : string)
      put s(1)
   end WriteFirstCharacter
end Stuff


Allright, now if I wanted to anonamously reference that procedure, is there any way to go about doing that?

code:

%Imaginary Syntax to show what I want to do
var q : array 1..2 of procedure p (s : string)
q(1) := Stuff.WriteThis
q(2) := Stuff.WriteFirstCharacter


Is there any possible way to do this? I've tried creating a pointer to the class, and assigning q to the procedure that way, but it didn't work...
Sponsor
Sponsor
Sponsor
sponsor
HellblazerX




PostPosted: Thu Jun 08, 2006 4:42 pm   Post subject: (No subject)

I understand what you're asking. I believe what you're looking for is an abstract class, or an abstract procedure, however, since I've never looked into Turing classes, I'm not sure if they exist in Turing.
Cervantes




PostPosted: Thu Jun 08, 2006 5:11 pm   Post subject: (No subject)

No, you can't do that. The reason being that those procedures only exist for instances of the Stuff class, not for the class itself.

What you're looking for is a module.
TheOneTrueGod




PostPosted: Thu Jun 08, 2006 5:48 pm   Post subject: (No subject)

Darn. Thanks for your help man. A module wouldn't be useful in the instance I was asking this about. (Unfortunately, I forgot the instance Embarassed I was trying to figure out a way around it for like a week, so I finally gave up and posted the question on here, for future reference, but I can't remember what the actual instance of it was...)
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: