Fallbacks in Euphoria

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

Lua has something called a fallback, which is a powerful way of extending the functionality of Lua tables.

I think they could potentially map very closely to Euphoria's sequences. One of the reasons they are compelling is because they are only called on an error condition.

This means that there's essentially no runtime cost to adding them to the language.

From a coding point of view, it would mean adding a pointer to the sequence data structure. But since most cases would have a null for the pointer, it would just be the cost of checking the pointer, so there wouldn't be much impact. (Easy for me to say, I know. blink)

Now, imagine you wanted to a sequence to behave like a hash table:

person["name"] = "me" 
sequence s = person["name"] 

To get this to work with fallbacks, you would have to set the settable and index handlers for the fallbacks in the person sequence.

Similarly, this mechanism could be used to simulate structures, and even classes with inheritance.

Lua has a function handler, which obviously doesn't exist in Euphoria:

-- call the method bar in sequence the foo 
foo.bar() 

Again, it seems that this sort of functionality could be added to Euphoria without impacting the existing language negatively, but get a huge gain in language extensibility.

Thoughts?

- David

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

Search



Quick Links

User menu

Not signed in.

Misc Menu