Re: [AD] Function parameter ordering conventions

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Thu, 21 Jun 2007 11:33:01 +0300, Evert Glebbeek <eglebbk@xxxxxxxxxx> wrote:

Eh, this is just asking for trouble! You want an interface to be
consistent: a new user using al_draw_bitmap should be right to
assume that
similar functions would work roughly the same (al_put_pixel is similar
enough, three parameter, one is a pointer). If the above syntax was
used,
he would have to make a round-trip to the manual for every single
function, because he'd never be sure what the parameter order would be
like - not good!

Not at all! As was pointed out, the convention then becomes that
primitives follow the pattern "position and geometry" followed by
"colour", while blit operations become "what to blit" followed by
"where and how". They are logically distinct.
It's a matter of how you read the code. If I draw a bitmap, I draw "a
bitmap" at "some location". If I draw a pixel, I set "a pixel
somewhere" to "a colour".


Position - Geometry - Colour	(primitive)
Position - Color		{pixel)
Bitmap   - Position - Mode	(bitmap)

This distinction is arbitrary - why should a bitmap follow a different convention from a colour? Does handling distinct 'objects' (bitmaps, colours, whatnot) differently convey some significant advantage to the developer or the user? If not, then the path of least resistance would be to treat them all the same:

Position - Colour - Geometry	(primitive)
Position - Colour - (Mode?)	{pixel)
Position - Bitmap - Mode	(bitmap)

or maybe

Geometry - Colour - Position
Colour   - Position
Mode     - Bitmap - Position

I think the second is the easiest to use: you can automatically type in x, y and the object/mode, whereas in the first you have to make a conscious distinction between colours and bitmaps (muscle memory fails!). The third one *seems* a bit stranger than the second, but I've never actually used it so I can't make a decision.

What is the advantage of the first proposal over the second or third?


Stephen A





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/