Re: Prototype-Based Programming

new topic     » goto parent     » topic index » view thread      » older message » newer message
jaygade said...

I'm skimming through the map info in the manual, do we have a good tutorial on using Euphoria's maps?

I don't think that we do. I think that they're mostly pretty straight forward. For most uses, new/put/get with default options will probably be enough.

jaygade said...

I think that it would tie into this very well.

Obviously, I agree. smile

jaygade said...

Question: would it be useful for each class file have its own map, or array of maps, or map of maps, to keep track of its own objects?

Or is each new map its own self-contained entity? (No, I haven't studied the code yet.)

If you're talking about "class" files, then you've left prototype based programming, where I think the answers are pretty simple and obvious: each object has its own map of properties and methods (this is pretty much what javascript objects are). In my library, objects are really just maps, along with some helper functions to make them nicer to work with. They're not as syntactically sweet as using typical dot notation.

One interesting thing about this is that a map is really an index (i.e., a pointer) so you aren't passing a map's data around, but passing a reference to the map's data. So a method could alter a map without you having to assign the result like you would if the object were a sequence. Also, different prototype objects could share references to prototype objects. This saves a lot on performance due to reduced copy on write operations that you'd need if you were passing sequences around and changing them. The map library goes to a lot of trouble to avoid copy on write where possible.

For a class based approach, you probably need to have each class with its own map, and objects keep a reference to their class type so that the framework can reference the map to get work done.

Matt

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu