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

Username:   Password: 
 RegisterRegister   
 Why can't class subprograms be subprogram variables?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Mackie




PostPosted: Thu Mar 27, 2008 5:17 pm   Post subject: Why can't class subprograms be subprogram variables?

Turing:
proc foo (run : proc _)
    run
end foo

class bar

    import foo

    proc foobaz
        put "FizzBiz"
    end foobaz

    foo (foobaz)

end bar


Here is a very simple example of my problem, I planned out a whole new version of my file browser around being able to do this, assuming I was able to. But, I can't so is there some way around this, or does anyone have any suggestions for an alternative method?
Sponsor
Sponsor
Sponsor
sponsor
Saad




PostPosted: Thu Mar 27, 2008 5:53 pm   Post subject: Re: Why can't class subprograms be subprogram variables?

Classes are supposed to be blue prints for objects, consequently when you try calling foo (foobaz), it doesn't occur since your calling foo with a foobaz that belongs to an object of that class.

Although it is possible to create a variable for a procedure.

Turing:

proc foo (run : proc _)
    run
end foo

class bar
    import foo
    var bodyFunction : proc _ ()

    %% This call works because we know that it belongs to the instance of bar
    foo (bodyFunction)

end bar
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  [ 2 Posts ]
Jump to:   


Style:  
Search: