Re: An elegant, EUPHORIA solution

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

>You see? Euphoria is more than capable of handling these things in an
>"elegant" way. Yes, we still have to define constants for sequence index
>values, and yes, this *is* a pain, but we have now eliminated the need for
>big, ugly type-check functions.

Yes, you could even do this using 100% pure Euphoria:

include oop.e

new_class (EMPTY_CLASS) -- base upon empty class
constant
    SUIT = new_attribute (routine_id ("string_9"), repeat (' ', 9))
    VALUE = new_attribute (routine_id ("integer"), 0)

class my_class my_class = store_class ()

And this library I wrote, was available months ago.
Yet, I want structures implemented. What does this say you ?

>And we don't even have to introduce any new structure syntax to do it.

Well, no.
Issues with the above:
    - constants name can conflict
    - my_class is a sequence of one element longer, than what its
representing. (the last element is used to store the different routine-id's
of each type, for run-time type checking)
    - speed
    - you're forced to either work with it as an class or as a structure.
Conversion does not happen automatically. If I pass a normal sequence to a
place where a 'class' is suppose to be passed to, it will be an 'invalid'
class, and a type-check error will occur. I can thus not use sequences as
structures, and structures as a sequence. I could add some conversion
routine, but then I would need to keep track which structures are structures
and which are sequences. This means I need to use a handle. WHen I use a
handle, rather than the object itself to store the value in, the value isnt
freed when appropiate, and you'll need a call a procedure to 'free' the
variable at the end of, for example, a routine declaration. And even then,
you would still be forced to use a routine to convert the values.
    - The syntax is not euphorish.


So, I was already aware of that its 'almost' possible with Euphoria. Just
not good enough.
Also, I havent seen any one use my library. Not even from the win32 front,
so i'm assuming the routine based syntax is really hated. And without the
automatic conversion you either write everthing using structure or not using
them. They can't be mixed.

Ralf Nieuwenhuijsen

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

Search



Quick Links

User menu

Not signed in.

Misc Menu