1. Object Oriented Programming and Euphoria
- Posted by Caracatsanis Pty Ltd <sunpsych at VIC.OZLAND.NET.AU> Aug 12, 2000
- 444 views
- Last edited Aug 13, 2000
>From my reading I've gained the impression that routine_id() facilitates OOP. I'm fairly new to programming, but would appreciate a simple understanding of the way OOP may be achieved in Euphoria. I've read about routine_id() in the documentation, and can see what it does, but not how it relates to OOP. For example suppose I define a general class called "Shape". Suppose I declare its (private) data members to be "length", "height", and "area". Suppose I declare its (public) member functions to be "CalculateArea" and "ShowResult". I then create a constructor to allow me to put data into "length" and "height". I define "CalculateArea" such that: area = length * height. And I define "ShowResult" using an appropriate output statement. I call a specific instance of "Shape" - let's say "Square" - input specific values for "length" (eg 3) and "height" (eg 4), return a value of 12 from "CalculateArea", and display it on screen using "ShowResult". Is it possible to use this trivial example to demonstrate how the OOP concept can be handled by Euphoria? Thank you Alex Caracatsanis
2. Re: Object Oriented Programming and Euphoria
- Posted by Undetermined origin c/o LISTSERV administrator Aug 12, 2000
- 445 views
Caracatsanis Pty Ltd wrote: > >From my reading I've gained the impression that routine_id() facilitates > OOP. I'm fairly new to programming, but would appreciate a simple > understanding of the way OOP may be achieved in Euphoria. I've read about > routine_id() in the documentation, and can see what it does, but not how it > relates to OOP. > > For example suppose I define a general class called "Shape". Suppose I > declare its (private) data members to be "length", "height", and "area". > Suppose I declare its (public) member functions to be "CalculateArea" and > "ShowResult". I then create a constructor to allow me to put data into > "length" and "height". I define "CalculateArea" such that: area = length * > height. And I define "ShowResult" using an appropriate output statement. I > call a specific instance of "Shape" - let's say "Square" - input specific > values for "length" (eg 3) and "height" (eg 4), return a value of 12 from > "CalculateArea", and display it on screen using "ShowResult". > > Is it possible to use this trivial example to demonstrate how the OOP > concept can be handled by Euphoria? > > Thank you > > Alex Caracatsanis Euphoria doesn't have any built-in OOP syntax, and routine_id isn't directly related to OOP. routine_id is simply a way of getting a pointer to a function (then you can use call_proc or call_func to call it). There are several libraries which allow you to do OOP in Euphoria, but their use of routine_id is simply for dynamic calls - it is not related to OOP. Jeff Fielding