Alice Community  

Go Back   Alice Community > Educators > Teaching with Alice

Reply
 
Thread Tools Display Modes
accessing class methods & vars
Old
mullins
Guest
 
Status:
Posts: n/a
Default accessing class methods & vars - 10-06-2007, 09:57 AM

I have looked in several books and tried various implementations without finding out for sure, so...

Is there an equivalent of the "part named" function to allow access to (custom) methods and/or class variables for an object that is a parameter or an item in a list?

Examples of what I am looking for (any combination):

item_from_boxes.new_custom_method
item_from_boxes method called new_custom_method
if formal_param.my_var ...
if formal_params property called my_var ...

Thanks in advance for any help.
   
Reply With Quote
clarification
Old
mullins
Guest
 
Status:
Posts: n/a
Default clarification - 10-13-2007, 03:37 PM

I failed to mention that finding a way to use the class function
object's variable named ___ of type ___
would be useful.

I can't seem to find the context in which Alice will allow that function to be used.
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 10-13-2007, 05:20 PM

Quote:
Originally Posted by mullins View Post
I failed to mention that finding a way to use the class function
object's variable named ___ of type ___
would be useful.

I can't seem to find the context in which Alice will allow that function to be used.
Take a look at the following to see if it contains the answer to your question.


See http://www.dickbaldwin.com/alice/Ali..._cast_operator

Also see "A serious restriction" at http://www.dickbaldwin.com/alice/Alice0145.htm

Dick Baldwin
http://www.dickbaldwin.com/toc.htm
http://www.dickbaldwin.com/tocalice.htm
   
Reply With Quote
Old
mullins
Guest
 
Status:
Posts: n/a
Default 10-22-2007, 02:48 PM

Quote:
Originally Posted by DickBaldwin View Post
Take a look at the following to see if it contains the answer to your question.
Actually, I had looked at your tutorials and several books previously. It's all still inconclusive, to me at least.

Any official word would still be appreciated.
   
Reply With Quote
I may have found a solution
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default I may have found a solution - 10-24-2007, 12:48 PM

I believe that I may have found a solution to some of the problems encountered when you need to call custom methods on objects stored as type Object.

It isn't very elegant. In fact, it is pretty ugly, but it doesn't offend my OOP sensibilities, so I would be willing to teach it to my students.

I am currently testing the approach to confirm that it really does work. I will be back in a couple of days to explain the approach, or to say that I was wrong and it really isn't a solution.

Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free programming tutorials: http://www.dickbaldwin.com/toc.htm

Last edited by DickBaldwin; 10-24-2007 at 12:48 PM. Reason: Correct spelling
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 10-25-2007, 06:33 PM

Quote:
Originally Posted by mullins View Post
I have looked in several books and tried various implementations without finding out for sure, so...

Is there an equivalent of the "part named" function to allow access to (custom) methods and/or class variables for an object that is a parameter or an item in a list?

Examples of what I am looking for (any combination):

item_from_boxes.new_custom_method
item_from_boxes method called new_custom_method
if formal_param.my_var ...
if formal_params property called my_var ...

Thanks in advance for any help.
Take a look at http://www.alice.org/community/showt...=3993#post3993 to see if it is of any help.

Dick Baldwin
Free Alice tutorials: http://www.dickbaldwin.com/tocalice.htm
Free programming tutorials: http://www.dickbaldwin.com/toc.htm
   
Reply With Quote
Old
mullins
Guest
 
Status:
Posts: n/a
Default 11-06-2007, 08:00 AM

I think I prefer to describe the inability to access user defined properties and methods as a weakness. How big a weakness it is depends on what you are doing, of course.

I have written several programs to test the boundaries of the language. One uses a large number of boxes to simulate heat diffusion in a thin metal bar. Not being able to access the "finite element" methods is quite a pain. But, I wouldn't want to search through all the elements to call the method directly.
Rather, it seems a good motovation for moving to another language.

Thanks for all your efforts, though! Truly appreciated.
   
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.