1. Re:Mike The Spike on 'type'
- Posted by joshua293 at EMAIL.COM Mar 17, 2001
- 394 views
- Last edited Mar 18, 2001
MTS says some really interesting things, here. Being a newbie to programming and Euphoria, I don't understand a lot of what he says (what's a 'CLASS'?) Even though his example code doesn't always work (i.e., try running his 'class' example) he seems to have insights missed by many others on this list. I'd really love to hear some comment and further discussion on MTS's ideas regarding 'type', especially from those who would really know (Rob Craig, David Cuny, Derek Parnell, and others of similar knowledge and experience). It may be that Euphoria is more powerful than anyone is letting on. Here's a little trick I fished up just now... You like VB huh? You like it when you can create a property, and set and get the status of a variable... Confused? No problem, Eu can do that too! Here it is... If you didn't know you could do this (people are afraid of using 'type' nowadays), you'll think how you could miss this cool feature of Eu's. Ok... What if you'd want a variable, that when assigned a value, it autmatically processes that data using your own specifc code? An example? Here ya go. type type_writer(sequence s) puts(1,s) return 1 end type Now simply say; type_writer echo echo = "Hello World!" What happens? "Hello World!" is printed to the screen. Also usefull for doing Memory Dumping. Keep track of each value assigned to a variable, by writing them to disk. Wouldn't it be cool to do 'classes' in Eu, FOR REAL? Well, you can! Like this; type class(sequence func) call_proc(func,func[2]) return 1 end type Now you can do this!; class myclass myclass = {"MyPuts","Hello World!"} After this assignement, routine 'MyPuts' is called with "Hello World!", thus writing this string to the screen (assuming that's what MyPuts does). That ain't all folks... There *LOADS* of things you can do with types... Go ahead! Try it! Classes, properties, debugging, resource tracking, ByRef passing (routine_id works on types aswell!!), etc... There's no limits, just your own imagination. So go ahead! Types won't bite! Mike The Spike PS. Don't forget to use 'without type_check' for extra speed boosts!