>> I do not completely agree with you on this one (but you already now it). The
>> thing is that if we use integers then the user will have to constantly ask
>> which enum value should I pass here...
>
> The idea is to not expose enum values to user at all.
> Sometimes it easily doable, sometimes not.. it depends , of course..
> But ideally, there should be only messages.
>
Just to elaborate a bit, here the real example
AthensCairoPaintMode
cairo has a function
void cairo_set_operator (AthensCairoCanvas canvas, cairo_operator_t
aCairoOperatorT) )
to set a composition operator (porter-duff one).
The cairo_operator_t is indeed enum there.
So, if i would use enums, users would need to tell:
canvas setPaintMode: enumValue
instead, the syntax to say that is following:
canvas paintMode enumValueName
in that way i deal with two problems:
- users don't have to use shared pools in their code, more than
that, it is impossible to pass some invalid value to the function.
- since Athens can use multiple backends, using backend-specific
enumeration values
would immediately render application tightly coupled with specific backend.
To avoid that, i would be needing to define own backend-neutral
enumeration and then
map it to backend-specific one.. This is stinks a lot to my taste..
Instead, a backend-specific AthensPaintMode subclass simply implements
own method per each
enumValueName for example:
overlay
^ self setOperator: CAIRO_OPERATOR_OVERLAY
--
Best regards,
Igor Stasenko.