[cairo] [rcairo][RFC] 1.0 road map

mental at rydia.net mental at rydia.net
Thu Sep 29 09:33:14 PDT 2005


Quoting Kouhei Sutou <kou at cozmixng.org>:

> Hi,
>
> I want to hear pippin's comments for my plan for releasing
> rcairo 1.0:

Well, I'm not pippin, but I am the author of what became the current
rcairo.. :)

>   * implement all functions and conform to 'Appendix
>     A. Creating a language binding for cairo'(*2).

Sounds good -- as long as Ruby idioms are preserved.  For example (I
assume pippin has retained this sort of thing; I've not looked):

 path = cr.copy_path
 path.each { |type, *coords|
   other_cr.send(type, *coords)
 }

or more concisely/efficiently:

 path = cr.copy_path
 path.each &other_cr.method(:send)

i.e. the values exposed by the path iterator are precisely the
method calls (symbol + arguments) necessary to draw that path in a
context -- e.g. [ :move_to, 1, 2 ] becomes .move_to(1,2).

Clever uses like that aside, I think it also makes the code clearer
in other cases as it doesn't require intermediate "path element"
objects.

compare the suggested:

 cr.copy_path.each { |element|
   if element.type == Cairo::PathElement::MOVE_TO
     (x, y) = element.point(0)
     do_move_to(x, y)
   end
 }

with:

 cr.copy_path.each { |type, *coords|
   do_move_to(*coords) if type == :move_to
 }

Which one is more Ruby-esque?

>   * change indentation style of cairo.rb to ruby-mode.el's
>     default style:

>     - module Cairo
>         ...
>         class ...
>         ...
>         end
>         ...
>       end

I've never liked this style myself because it introduces too much
extra indention when one is using nested modules as simple
namespaces.  I do think other uses of modules should indent,
though.

-mental


More information about the cairo mailing list