Re: Fallbacks in Euphoria

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

It seems to me fallbacks are an exceptional case handling mechanism. Errors that don't happen often enough that they are not returned as an error code and handled but they still happen. If you want to change the behavior of [] for a class of sequences, you really want Operator Overloading. Something that is permanent for a given type.

I have come to think that a type, or class using parlance from another language here, has three optionally overloaded methods: One a validation method, this is our type-check routine, that has been around forever. Another is the Delete Routine, useful for sockets and file handles. if you need to return from a routine but have file handles and sockets that need to be closed? No problem. Use delete_routine. The last one is that we can overload how a constant is displayed using the alternative literals mechanism.

Of course there are two kinds of methods. In EUPHORIA, the validation routine is a non-virtual method where as the delete routine is a virtual method. Non-virtual methods are associated by the language front end and called according to the variable. Virtual method associates methods in the meta data of the object itself and must be carried by each object.

Shawn

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

Search



Quick Links

User menu

Not signed in.

Misc Menu