Re: Fallbacks in Euphoria

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

Definitely interesting. The delete_routine() is a bit like that, being only called when the reference count drops to 0.

I should have mentioned that Lua has a gc fallback, too. That might actually be very useful when trying to wrap objects from other libraries.

One difference is that you can deliberately keep a table empty of key values in Lua, so you can force indexing to happen. In Euphoria, it's not quite the same because indexing is done via a numeric value, not a key/value pair.

So you could start with an empty sequence in Euphoria, and something like:

s = foo[1] 

would fail the first time, calling the fallback. But as soon as you stored a value in the sequence,

s = foo[1] 

would trigger correctly, which is a bit of a conundrum. So... what to do?

One option would be to allow access to the sequence that holds the fallback list, calling it meta. You could do anything you'd want with that sequence - even store data in it.

Of course, you couldn't access it directly, so you'd need some way to get and set the meta sequence.

- David

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

Search



Quick Links

User menu

Not signed in.

Misc Menu